CoursesSearch & Priority Patterns

Binary Search

Lessons
9
Exercises
56
Minutes
56
  1. 1

    Halve the Search Space

    Spot the problems where one comparison can safely throw away half the candidates.

    Multiple choiceTap
    5 exercises
    4 min
  2. 2

    Binary Search

    Keep the target trapped in [lo, hi] until you find it — or the window empties.

    Complete codeDebugMultiple choiceTrace
    6 exercises
    6 min
  3. 3

    Search Insert Position

    When the loop misses, lo is already standing on the insertion point.

    Complete codeDebugMultiple choiceTrace
    6 exercises
    6 min
  4. 4

    First Bad Version

    Binary search a yes/no boundary: keep every 'bad' candidate in range until the pointers pinch the first one.

    Complete codeDebugMultiple choiceTrace
    6 exercises
    6 min
  5. 5

    First and Last Position

    On equal, don't stop — bias the search left or right so duplicates can't hide the true boundary.

    Complete codeMultiple choiceTrace
    6 exercises
    6 min
  6. 6

    Minimum in Rotated Array

    Compare mid against the RIGHT end — that one comparison always reveals which side hides the drop.

    Complete codeDebugMultiple choiceTrace
    6 exercises
    6 min
  7. 7

    Binary Search CheckpointCheckpoint

    No new concepts — combine the island's variants: picking exact-match vs boundary vs biased searches, the containment invariant, safe mid, and loop progress.

    DebugCode orderFill blankMultiple choiceTrace
    6 exercises
    6 min
  8. 8

    Binary Search ReviewReview

    Mixed recap of the island: when halving applies, exact-match vs boundary moves, the insertion point, biased searches, rotated minimums, and why log n is so fast.

    Complete codeMultiple choiceTapTrace
    7 exercises
    6 min
  9. 9

    Boss: Search in Rotated ArrayBoss

    The island's final test: binary search an array whose order is bent. At every mid exactly one half is properly sorted — identify it, range-test the target against it, and discard half the array anyway.

    Complete codeCode orderMultiple choiceTrace
    8 exercises
    10 min
AlgoFox Pro

Search & Priority Patterns is part of AlgoFox Pro

You can read the whole course outline here. The exercises are in the app, along with your streak, your mistake review, and the progress that carries across your devices.

Pro starts with a 3 day free trial. The app store decides who is eligible for an introductory offer, and a lapsed subscription does not get another one.

Download AlgoFox on the App StoreGet AlgoFox on Google Play

Already subscribed in the app? Sign in with the same account and Pro works here too. Quick Play and Battle are free on the web, and so is the first course in every subject.