Algorithmic methods, properties, and standard problems.
Test your knowledge with these top questions!
Which item does binary search check in the remaining sorted list?
When the remaining list has an even number of items, the algorithm rounds the midpoint up or down to pick one of the two center items.
What is the worst-case time complexity of binary search in a sorted array?
Each comparison rules out half the remaining options, so searching one million sorted array entries takes at most 20 steps.
After a missed match, binary search rules out roughly what share of the remaining sorted list?
For a higher target, the search drops the lower half; for a lower target, it drops the upper half.
Which bug did Joshua Bloch expose in Java's binary search code in 2006?
Adding two huge array indexes to find the midpoint could exceed Java's maximum integer limit and produce a negative index.
Which condition must hold for binary search to work correctly?
Binary search repeatedly halves a sorted list, locating a target in about log2(n) comparisons.