BeginnerAbout 15 min

    Binary Search

    Read the full article on Substack

    7 min read.

    Understand the power of O(log n). Visualize dividing the search space in half to find targets in sorted arrays instantly.

    Think of it this way: Think of looking up a word in a dictionary. You open to the middle. If your word is after the page you see, you ignore the first half completely. You keep splitting the remaining pages in half until you find it.

    search space205182123164235386567728919lohi

    Search for 23 in 10 sorted values. Each step halves the search space.

    1/7

    Check your understanding

    Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.

    Halve the search space

    Sequence

    Order the steps of binary search on a sorted array.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    1. 1Drop a step here
    2. 2Drop a step here
    3. 3Drop a step here
    4. 4Drop a step here
    5. 5Drop a step here
    5 pieces left to place

    Quiz

    20 questions
    Question 1 of 20
    Score: 0

    What precondition is REQUIRED for Binary Search?

    Done with this lesson?

    Sign in free to keep your progress, streak and quiz scores.

    Keep going