Recall & Review
beginner Click to reveal answer
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.
intermediate Click to reveal answer
Why is binary search useful for finding a peak element?
Binary search helps find a peak element in O(log n) time by comparing middle elements with neighbors and deciding which half to search next.
beginner Click to reveal answer
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 since the right neighbor is greater.
beginner Click to reveal answer
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.
beginner Click to reveal answer
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.
What defines a peak element in an array?
✗ Incorrect
A peak element is greater than its neighbors.
If the middle element is less than its left neighbor, where should the binary search continue?
✗ Incorrect
Search left half because a peak exists there.
What is the time complexity of the binary search approach to find a 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 middle element is greater than neighbors, it is a peak.
Which of these is NOT true about peak elements?
✗ Incorrect
A peak element is not necessarily the maximum element overall.
Explain how binary search is used to find a peak element in an array.
Think about how to decide which half to search next based on neighbors.
You got /5 concepts.
Describe what a peak element is and why it always exists in any array.
Consider edges and local comparisons.
You got /4 concepts.
