Searching
Watch linear and binary search hunt for a target value step by step — comparisons, halving, and hit/miss outcomes.
Linear SearchScan the array one element at a time until the target appears.Binary SearchHalve the search window each step until the target is found.
Searching comparison
| Algorithm | Best | Average | Worst | Space | Needs sorted data? |
|---|---|---|---|---|---|
| Linear Search | O(1) | O(n) | O(n) | O(1) | No |
| Binary Search | O(1) | O(log n) | O(log n) | O(1) | Yes |