Recall & Review
beginner
What is a peak element in an array?
A peak element is an element that is greater than its neighbors. For the first or last element, only one neighbor is considered.
Click to reveal answer
intermediate
Why use binary search to find a peak element?
Binary search helps find a peak element in O(log n) time by checking the middle element and deciding which half to search next based on neighbors.
Click to reveal answer
intermediate
In the binary search for a peak element, if the middle element is less than its right neighbor, which side do we search next?
We search the right half because a peak must exist there due to the increasing slope.
Click to reveal answer
beginner
What is the time complexity of finding a peak element using binary search?
The time complexity is O(log n) because the search space is halved in each step.
Click to reveal answer
beginner
Show the base condition to stop the binary search when finding a peak element.
When the search space reduces to one element, that element is a peak and the search stops.
Click to reveal answer
What defines a peak element in an array?
✗ Incorrect
A peak element is greater than its neighbors.
If mid element is less than its right neighbor, where should binary search continue?
✗ Incorrect
The peak lies in the right half if mid is less than right neighbor.
What is the time complexity of binary search for peak element?
✗ Incorrect
Binary search halves the search space each step, so O(log n).
What happens if the middle element is greater than both neighbors?
✗ Incorrect
If mid is greater than neighbors, it is a peak.
Which of these arrays definitely has a peak element?
✗ Incorrect
Every array has at least one peak element.
Explain how binary search helps find a peak element in an array.
Think about how the array slope guides the search direction.
You got /4 concepts.
Describe the conditions that determine if the middle element is a peak or which side to search next.
Focus on comparisons with neighbors.
You got /3 concepts.