Algorithms and Data Structures · Junior · Question 33 of 75
Roughly how many comparisons does binary search need in a sorted array of 1,000,000 elements?
- 1About 1,000
- 2About 500,000
- ✓Correct answer: About 20
Explanation
2²⁰ is about a million, so halving the range 20 times leaves one element. Linear search would need up to a million comparisons.