For which of the following cases, binary search is not suitable?
For which of the following cases, binary search is not suitable?
Solution
Binary search works by comparing the target with the middle element and discarding half the list each time. This only works if the data is sorted, because the comparison tells you which half can be dropped. On an unsorted dataset, that comparison tells you nothing, so binary search fails regardless of the size.
Option 2: binary search does work on sorted data, even small data, though a linear scan is just as fast there.
Option 3: this is the ideal case, as the time is .
Option 4: binary search is fast for quick lookups, but only when the data is already sorted.
Sorting first costs , so for a single search on unsorted data, linear search at is cheaper.
Related questions:
2026: 20 May Shift 1
2026: 11 May Shift 2
2026: 26 May Shift 1
2025: 16 May Shift 1