Core Concept Mastery • DSA Module
Use linear search when the list is unsorted or small. Use binary search when the list is sorted and you want fewer steps. Binary search needs random access (jump to the middle). Arrays have that; a plain linked list does not, so on a linked list you use linear search only.
When to use which?
| Feature | Linear Search | Binary Search |
|---|---|---|
| Pre-requisite | None (Unsorted OK) | Must be Sorted |
| Time Complexity | O(n) | O(log n) |
| Speed | Slow for large data | Extremely Fast |
| Implementation | Simple Loop | Divide & Conquer |
When to use which
Arrays vs linked list
Picking the right search saves time. On a sorted array of a million items, binary search is about 50,000 times faster than linear in the worst case. On an unsorted list, you have no choice but linear (or sort first, then binary).