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, making the search efficient.
Click to reveal answer
beginner
What does 'sorted order' mean in the context of binary search?
Sorted order means the data elements are arranged in increasing or decreasing order, which allows binary search to quickly eliminate half of the remaining elements at each step.
Click to reveal answer
intermediate
How does binary search reduce the search space after each comparison?
After comparing the target with the middle element, binary search discards the half where the target cannot be, focusing only on the other half.
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, quickly narrowing down to the target or concluding it is not present.
Click to reveal answer
Why can't binary search be used on unsorted data?
✗ Incorrect
Binary search needs sorted data to know if it should look left or right after comparing with the middle element.
What happens to the search space after each comparison in binary search?
✗ Incorrect
Binary search halves the search space after each comparison, making it efficient.
What is the best case time complexity of binary search?
✗ Incorrect
If the middle element is the target, binary search finds it immediately in O(1) time.
Which of these is a requirement for binary search?
✗ Incorrect
Binary search requires sorted data to function correctly.
What does sorted order allow binary search to do?
✗ Incorrect
Sorted order lets binary search skip half the data after each comparison.
Explain why binary search requires sorted data and how it uses this property to find an element quickly.
Think about how knowing order helps decide where to look next.
You got /4 concepts.
Describe the main difference in performance between linear search and binary search and why binary search is faster on sorted data.
Compare how many steps each search takes in the worst case.
You got /4 concepts.