Recall & Review
beginner
What is the main idea behind the binary search iterative approach?
It repeatedly divides the sorted list in half to find the target value, by comparing the middle element and narrowing the search range until the target is found or the range is empty.
Click to reveal answer
beginner
In binary search iterative approach, what happens if the middle element is less than the target?
The search continues in the right half of the list, so the start index is moved to mid + 1.
Click to reveal answer
beginner
Why is binary search only applicable on sorted lists?
Because it relies on comparing the target with the middle element to decide which half to search next, which only works if the list is sorted.
Click to reveal answer
intermediate
What is the time complexity of the binary search iterative approach?
O(log n), where n is the number of elements in the list, because the search space halves each step.
Click to reveal answer
beginner
Show the key variables used in the binary search iterative approach and their roles.
start: the beginning index of the current search range; end: the ending index of the current search range; mid: the middle index calculated as start + (end - start) / 2; target: the value to find.
Click to reveal answer
What does the binary search iterative approach do when the middle element equals the target?
✗ Incorrect
When the middle element matches the target, the search is successful and the middle index is returned.
Which condition ends the binary search iterative loop without finding the target?
✗ Incorrect
The loop ends when the start index passes the end index, meaning the target is not in the list.
How is the middle index calculated in binary search iterative approach to avoid overflow?
✗ Incorrect
Calculating mid as start + (end - start) / 2 prevents integer overflow in some languages.
What is the first step in the binary search iterative approach?
✗ Incorrect
The algorithm starts by setting start to 0 and end to the last index of the list.
If the target is smaller than the middle element, what does the binary search iterative approach do?
✗ Incorrect
If target is less than middle element, the search continues in the left half by moving end to mid - 1.
Explain step-by-step how the binary search iterative approach finds a target in a sorted list.
Think about how the search range changes each step.
You got /5 concepts.
Describe why binary search iterative approach is more efficient than linear search on large sorted lists.
Consider how many elements are checked in each method.
You got /4 concepts.