Linear vs Binary Search
Generate a sorted list of random numbers, pick a target, and compare time and comparisons.
1 · Generate list
2 · Search
Results
Linear search
Result
Comparisons
Time / search
Binary search
Result
Comparisons
Time / search
Times are averaged over many repeated runs (a single search is too fast for the browser’s clock to measure reliably). Comparisons count one equality/ordering check per element examined; the timed runs don’t include the counting overhead.