Recall & Review
beginner Click to reveal answer
What is the main idea behind the divide and conquer approach in binary search?
Divide the sorted list into two halves, compare the middle element with the target, then recursively search in the half where the target can be.
beginner Click to reveal answer
In binary search, what happens if the middle element is equal to the target?
The search stops because the target is found at the middle position.
beginner Click to reveal answer
Why must the list be sorted for binary search to work?
Because binary search decides which half to search next based on comparisons, sorting ensures the target is in one half only.
intermediate Click to reveal answer
What is the time complexity of binary search and why?
O(log n) because each step divides the search space in half, reducing the problem size exponentially.
intermediate Click to reveal answer
Show the recursive formula for binary search on an array segment [low, high].
If low > high, return not found. Else, mid = low + (high - low) / 2. If target == arr[mid], return mid. If target < arr[mid], search [low, mid-1]. Else search [mid+1, high].
What is the first step in binary search on a sorted array?
✗ Incorrect
Binary search starts by comparing the target with the middle element to decide which half to search next.
If the target is less than the middle element, which part of the array does binary search continue on?
✗ Incorrect
If the target is less than the middle element, binary search continues on the left half.
What condition ends the binary search recursion?
✗ Incorrect
The recursion ends when the search space is invalid, i.e., low > high, meaning the target is not found.
What is the worst-case time complexity of binary search?
✗ Incorrect
Binary search halves the search space each step, leading to O(log n) time complexity.
Which of these is NOT required for binary search to work correctly?
✗ Incorrect
The array size does not need to be a power of two; binary search works on any sorted array size.
Explain how binary search uses divide and conquer to find a target in a sorted array.
Think about how the problem size reduces each step.
You got /4 concepts.
Describe the base cases and recursive steps in the binary search algorithm.
Focus on when the search stops and how it continues.
You got /3 concepts.
