SYAAHI / REVISION NOTES01
Binary search: halve the work
Search a sorted list by comparing the target with its middle item and keeping only the possible half.
The ordering lets you decide which half to discard. An unsorted list does not support this reasoning.
Find 8 in [2, 4, 6, 8, 10]. Compare 6; keep [8, 10]; then compare 8.
Each comparison roughly halves the remaining interval, giving logarithmic worst-case comparisons.
RECALL CHECK
Made with Syaahi · syaahii.inWhat happens when no items remain?
Reveal answer / उत्तर देखें
The target is absent. Stop rather than searching the same interval again.