![]() |
VOOZH | about |
You are given a Bitonic Sequence, the task is to find Bitonic Point in it. A Bitonic Sequence is a sequence of numbers which is first strictly increasing then after a point strictly decreasing.
A Bitonic Point is a point in bitonic sequence before which elements are strictly increasing and after which elements are strictly decreasing.
Note:- Given Sequence will always be a valid bitonic sequence.
Examples:
Input: arr[] = {8, 10, 100, 200, 400, 500, 3, 2, 1}
Output: 500
Input: arr[] = {10, 20, 30, 40, 30, 20}
Output: 40
Input: arr[] = {60, 70, 120, 100, 80}
Output: 120
Table of Content
A simple approach is to iterate through the array and keep track of the maximum element occurred so far. once the traversal is complete, return the maximum element.
500
The input array follows a monotonic pattern. If an element is smaller than the next one, it lies in the increasing segment of the array, and the maximum element will definitely exist after it. Conversely, if an element is greater than the next one, it lies in the decreasing segment, meaning the maximum is either at this position or earlier. Therefore, we can use binary search to efficiently find the maximum element in the array.
500