Reqflow
Searching·Beginner

Linear Search

Time O(n)Space O(1)
·

Linear search scans the array from left to right, comparing each element to the target until it finds a match or exhausts the list. It works on any array — sorted or unsorted — but it is slow on large inputs because in the worst case every element must be checked. It is the baseline every faster search algorithm is measured against.

Example: Find 19 in an unsorted array of 8 numbers.

When to use this

See also

← All algorithms