Linear search vs. binary search – counting comparisons
Computer ScienceAlgorithms & Problem SolvingAges 12–13
Loading…
Sign in to playThe same array and the same target value run through linear search (scanning from the start) and binary search (halving the range on a sorted array) side by side. Students click Step or Play to see the cell being compared, the range being ruled out, and the comparison count for each algorithm; clicking a cell changes the target value, and turning sorting off shows why binary search stops working.