Is the board this lesson reads closely. Its binary search panel marks lo, mid and hi over the sorted list 1 to 15, and one line underneath warns about the off-by-one: “nail the invariant (is hi inclusive? is the answer in [lo,hi]?) or you loop forever / skip it.” This lesson is that one line, taken seriously.
Before you start.Sorting & Searching gave you binary search: on a sorted list, look at the middle, throw away the half that cannot hold what you want, repeat, so a million items takes about twenty looks. Recursion & Dynamic Programming gave you recursion: a function that calls itself on a smaller copy of the problem, stopped by a base case it can answer directly.
Lesson 12 of 96 in DSA
The rest of this lesson is part of a plan.
A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.