Algorithms: Searching
Searching algorithms are procedures used to find the position of a target value within a collection (for example, an array or list). They are fundamental because searching is performed in many everyday programs — like looking up a name, a word, or a product.
Linear Search (Sequential)
- Checks each item one-by-one from the start until it finds the target or reaches the end.
- Works with unsorted or sorted lists (no preconditions).
- Simple to teach and easy to implement.
Time: O(n) Space: O(1) Works on: unsorted or sorted
Binary Search
- Requires a sorted list.
- Each step compares with the middle element, then eliminates half the remaining search space.
- Greatly faster than linear search for large sorted lists.
Time: O(log n) Space: O(1) Works on: sorted lists only
Interactive Linear & Binary Search
Linear Search
Binary Search
Check your understanding
Download a worksheet to test your understanding and strengthen your skills!
Browse Worksheets