What is the main idea behind the Binary Search Recursive Approach?
It divides the sorted list into two halves and recursively searches the half where the target value could be, reducing the search space by half each time.
Click to reveal answer
beginner
In the recursive binary search, what are the base cases?
1. When the start index is greater than the end index (target not found). 2. When the middle element is equal to the target (target found).
Click to reveal answer
beginner
Why must the input array be sorted for binary search to work?
Because binary search compares the target with the middle element to decide which half to search next, sorting ensures the halves are ordered and the search logic is valid.
Click to reveal answer
beginner
What is the time complexity of the Binary Search Recursive Approach?
O(log n), where n is the number of elements in the array, because the search space halves with each recursive call.
Click to reveal answer
intermediate
Show the recursive call pattern for searching target 7 in array [1,3,5,7,9].
1. Check middle element 5 (index 2): 7 > 5, search right half. 2. Check middle element 7 (index 3): found target. Recursive calls reduce search space from 5 to 2 elements, then to 1 element.
Click to reveal answer
What happens if the target is less than the middle element in recursive binary search?
AReturn -1 immediately
BSearch the right half of the array
CSearch the left half of the array
DSearch the entire array again
✗ Incorrect
If the target is less than the middle element, binary search continues recursively on the left half.
What is the stopping condition when the target is not found in recursive binary search?
AWhen start index is greater than end index
BWhen array is empty
CWhen middle element equals target
DWhen start index equals end index
✗ Incorrect
The search stops when the start index becomes greater than the end index, meaning the target is not in the array.
Which of these is required for binary search to work correctly?
AArray must be sorted
BArray must have unique elements
CArray must be unsorted
DArray must be reversed
✗ Incorrect
Binary search requires the array to be sorted to decide which half to search next.
What is the time complexity of recursive binary search?
AO(1)
BO(n)
CO(n log n)
DO(log n)
✗ Incorrect
Binary search reduces the search space by half each time, leading to O(log n) time complexity.
In recursive binary search, what parameters are typically passed in each recursive call?
AArray, target only
BArray, target, start index, end index
CArray, target, middle index
DTarget, start index, end index
✗ Incorrect
Each recursive call passes the array, target, and updated start and end indices to narrow the search.
Explain how the recursive binary search algorithm works step-by-step.
Think about how the array is split and how recursion narrows down the search.
You got /4 concepts.
Describe the base cases in recursive binary search and why they are important.
Base cases prevent infinite recursion and signal success or failure.
You got /3 concepts.
Practice
(1/5)
1. What is the main idea behind the binary search recursive approach when searching for a value in a sorted array?
easy
A. Check every element one by one from start to end
B. Sort the array first and then search linearly
C. Divide the array into halves and search recursively in the half where the value may exist
D. Use a stack to store all elements and pop until the value is found
Solution
Step 1: Understand binary search logic
Binary search works by dividing the sorted array into two halves and deciding which half to search next based on comparison.
Step 2: Apply recursion in binary search
The recursive approach calls the same function on the half where the target value could be, reducing the search space each time.
Final Answer:
Divide the array into halves and search recursively in the half where the value may exist -> Option C