Binary Search

    Binary Search

    Narrow a sorted range by half at each step to find a target in O(log n).

    target
    low=0, high=10, mid=5 → arr[5]=23
    L
    2
    0
    5
    1
    8
    2
    12
    3
    16
    4
    M
    23
    5
    38
    6
    45
    7
    56
    8
    72
    9
    H
    91
    10
    Step 0/1