Lesson 095

Linear Search

Sequential Scan · O(n)

1:00

Walk every element in order — linear search scans unsorted data in O(n) time using only a single loop and no extra memory.

By the end, you can

  • Trace linear search step-by-step on a concrete array and count the exact comparisons for both a hit and a miss.
  • State the best, worst, and average-case time complexities and explain when each arises.
  • Explain why linear search returns an index, not a value, and what it returns when the target is absent.
  • Describe the behavior on duplicate values and on an empty array.
  • Decide when linear search is the appropriate tool versus binary search or a hash table.
Up next in Searching & Sorting
Questions or feedback?