DevPrep
  • Interview Prep
  • Projects
  • Resources
  • Pricing
  • About Us
Submit Question
DevPrep
  • Pricing
  • About Us
Submit Question
  1. Home
  2. Tools
  3. Algorithm Visualizer
  4. Linear Search

Linear Search

Searchingeasy#8

Check each element sequentially until target is found

Ready

Step 1 of 0

Speed

Input Data

Comma-separated numbers (0-999). Min 2 values.

Algorithm Code

1function linearSearch(arr, target) {
2 for (let i = 0; i < arr.length; i++) {
3 if (arr[i] === target) return i;
4 }
5 return -1;
6}
Best

O(1)

Average

O(n)

Worst

O(n)

Space

O(1)

About Linear Search

Linear Search sequentially checks each element of the list until a match is found or the whole list has been searched. It works on unsorted arrays and is the simplest search algorithm. Best suited for small datasets or unsorted collections.

Time Complexity: Best: O(1), Average: O(n), Worst: O(n). Space: O(1).

Practice

  • JavaScript
  • DSA
  • Machine Coding
  • System Design

Resources

  • Learning Tracks
  • Articles
  • Roadmaps
  • Compare Concepts
  • Glossary
  • Developer Tools
  • All Questions

Company

  • About
  • Pricing

Legal

  • Privacy Policy
  • Terms of Service
DevPrep

© 2026 DevPrep. All rights reserved.