Math Fundamentals18 sections · 814 units
Open in Course

Lessons from Search Insert (Summary)

What you learned

1.1. Binary search works on any monotonic property (here: sorted order), not just exact matches.

2.2. The leftleft pointer after binary search points to the first position where the condition holds.

3.3. Every halving step reduces the problem by a factor of 22, giving O(logn)O(\log n) time regardless of whether you find an exact match.