Recall & Review
beginner
What is the main advantage of using binary search over linear search?
Binary search is much faster because it repeatedly divides the search space in half, reducing the number of comparisons from linear (n) to logarithmic (log n).
Click to reveal answer
beginner
Why must the data be sorted to use binary search?
Binary search relies on the data being sorted so it can decide which half of the data to ignore after each comparison, ensuring the search space shrinks correctly.
Click to reveal answer
beginner
What does 'sorted order' mean in the context of binary search?
Sorted order means the elements are arranged in increasing or decreasing order, so each element is in a predictable position relative to others.
Click to reveal answer
intermediate
How does sorted order help in reducing the search time?
Sorted order allows binary search to eliminate half of the remaining elements after each comparison, quickly narrowing down the possible location of the target.
Click to reveal answer
intermediate
What is the time complexity of binary search and why?
The time complexity is O(log n) because the search space is halved with each step, leading to a logarithmic number of steps relative to the number of elements.
Click to reveal answer
Why can binary search only be used on sorted data?
✗ Incorrect
Binary search decides which half to ignore based on the order, so data must be sorted.
What happens to the search space after each step in binary search?
✗ Incorrect
Binary search halves the search space after each comparison.
What is the best case time complexity of binary search?
✗ Incorrect
If the target is found at the middle element immediately, the time is O(1).
Which of these is NOT a requirement for binary search?
✗ Incorrect
Data does not need to be unique for binary search to work.
If you have 1,000,000 sorted elements, about how many steps does binary search take in the worst case?
✗ Incorrect
Binary search takes about log2(1,000,000) ≈ 20 steps.
Explain why sorted order is essential for binary search and how it helps reduce search time.
Think about how knowing order helps decide which part to ignore.
You got /3 concepts.
Describe the step-by-step process of binary search on a sorted list.
Imagine looking for a word in a dictionary.
You got /4 concepts.