Bitonic Point - Maximum in Increasing Decreasing Array
Last Updated :
23 Jul, 2025
Given an array arr[] of integers which is initially strictly increasing and then strictly decreasing, the task is to find the bitonic point, that is the maximum value in the array.
Note: Bitonic Point is a point in bitonic sequence before which elements are strictly increasing and after which elements are strictly decreasing.
Examples:
Input: arr[] = [1, 2, 4, 5, 7, 8, 3]
Output: 8
Explanation: 8 is the maximum element in the array.
Input: arr[] = [10, 20, 30, 40, 50]
Output: 50
Explanation: 50 is the maximum element in the array.
Input: arr[] = [120, 100, 80, 20, 0]
Output: 120
Explanation: 120 is the maximum element in the array.
[Naive Approach] Using Linear Search - O(n) Time and O(1) Space
A simple approach is to traverse the array and keep track of maximum element. Finally return the maximum element.
C++
// C++ program to find bitonic point in an array
// using linear search
#include <iostream>
#include <vector>
using namespace std;
// function to find the maximum element
int findMaximum(vector<int>& arr) {
int mx = arr[0];
for (int i = 1; i < arr.size(); i++) {
// update max when found greater value
if (arr[i] > mx)
mx = arr[i];
// break when once an element is smaller than
// the max then it will go on decreasing
// and no need to check after that
else
break;
}
return mx;
}
int main() {
vector<int> arr = {1, 2, 4, 5, 7, 8, 3};
cout << findMaximum(arr);
return 0;
}
C
// C program to find bitonic point in an array
// using linear search
#include <stdio.h>
int findMaximum(int arr[], int n) {
int mx = arr[0];
for (int i = 1; i < n; i++) {
// update max when found greater value
if (arr[i] > mx)
mx = arr[i];
// break when once an element is smaller than
// the max then it will go on decreasing
// and no need to check after that
else
break;
}
return mx;
}
int main() {
int arr[] = {1, 2, 4, 5, 7, 8, 3};
int n = sizeof(arr) / sizeof(arr[0]);
printf("%d", findMaximum(arr, n));
return 0;
}
Java
// Java program to find bitonic point in an array
// using linear search
import java.util.*;
class GfG {
// function to find the maximum element
static int findMaximum(int[] arr) {
int mx = arr[0];
for (int i = 1; i < arr.length; i++) {
// update max when found greater value
if (arr[i] > mx)
mx = arr[i];
// break when once an element is smaller than
// the max then it will go on decreasing
// and no need to check after that
else
break;
}
return mx;
}
public static void main(String[] args) {
int[] arr = {1, 2, 4, 5, 7, 8, 3};
System.out.println(findMaximum(arr));
}
}
Python
# Python program to find bitonic point in an array
# using linear search
# function to find the maximum element
def findMaximum(arr):
mx = arr[0]
for i in range(1, len(arr)):
# update max when found greater value
if arr[i] > mx:
mx = arr[i]
# break when once an element is smaller than
# the max then it will go on decreasing
# and no need to check after that
else:
break
return mx
if __name__ == "__main__":
arr = [1, 2, 4, 5, 7, 8, 3]
print(findMaximum(arr))
C#
// C# program to find bitonic point in an array
// using linear search
using System;
using System.Collections.Generic;
class GfG {
// function to find the maximum element
static int findMaximum(int[] arr) {
int mx = arr[0];
for (int i = 1; i < arr.Length; i++) {
// update max when found greater value
if (arr[i] > mx)
mx = arr[i];
// break when once an element is smaller than
// the max then it will go on decreasing
// and no need to check after that
else
break;
}
return mx;
}
static void Main() {
int[] arr = { 1, 2, 4, 5, 7, 8, 3 };
Console.WriteLine(findMaximum(arr));
}
}
JavaScript
// JavaScript program to find bitonic point in an array
// using linear search
// function to find the maximum element
function findMaximum(arr) {
let mx = arr[0];
for (let i = 1; i < arr.length; i++) {
// update max when found greater value
if (arr[i] > mx)
mx = arr[i];
// break when once an element is smaller than
// the max then it will go on decreasing
// and no need to check after that
else
break;
}
return mx;
}
let arr = [1, 2, 4, 5, 7, 8, 3];
console.log(findMaximum(arr));
[Expected Approach] Using Binary Search - O(log n) Time and O(1) Space
We can optimize the maximum element searching by using Binary Search where we find the mid element and then decide whether to stop or to go to left half or right half. How do we decide in this case.
- If the mid element is greater than both of its adjacent elements, then mid is the maximum.
- If the mid element is smaller than its next element then we should try to search on the right half of the array. So, update low = mid + 1.
- If the mid element is greater than the next element, then we should try to search on the left half. So, update high = mid - 1.
C++
// C++ program to find bitonic point in an array
// using Binary Search
#include <iostream>
#include <vector>
using namespace std;
int findMaximum(vector<int> &arr) {
int n = arr.size();
// Check if the first element is maximum
if (n == 1 || arr[0] > arr[1])
return arr[0];
// Check if the last element is maximum
if (arr[n - 1] > arr[n - 2])
return arr[n - 1];
// Search Space for binary Search
int lo = 1, hi = n - 2;
while (lo <= hi) {
int mid = lo + (hi - lo) / 2;
// If the element at mid is maximum then return it
if (arr[mid] > arr[mid - 1] && arr[mid] > arr[mid + 1])
return arr[mid];
// If next element is greater, then maximum
// element will exist in the right subarray
if (arr[mid] < arr[mid + 1])
lo = mid + 1;
// Otherwise, it will exist in left subarray
else
hi = mid - 1;
}
return arr[hi];
}
int main() {
vector<int> arr = {1, 2, 4, 5, 7, 8, 3};
cout << findMaximum(arr);
return 0;
}
C
// C++ program to find bitonic point in an array
// using Binary Search
#include <stdio.h>
int findMaximum(int arr[], int n) {
// Check if the first element is maximum
if (n == 1 || arr[0] > arr[1])
return arr[0];
// Check if the last element is maximum
if (arr[n - 1] > arr[n - 2])
return arr[n - 1];
// Search Space for binary Search
int lo = 1, hi = n - 2;
while (lo <= hi) {
int mid = lo + (hi - lo) / 2;
// If the element at mid is maximum then return it
if (arr[mid] >= arr[mid - 1] && arr[mid] > arr[mid + 1])
return arr[mid];
// If next element is greater, then maximum
// element will exist in the right subarray
if (arr[mid] < arr[mid + 1])
lo = mid + 1;
// Otherwise, it will exist in left subarray
else
hi = mid - 1;
}
return arr[hi];
}
int main() {
int arr[] = {1, 2, 4, 5, 7, 8, 3};
int n = sizeof(arr) / sizeof(arr[0]);
printf("%d\n", findMaximum(arr, n));
return 0;
}
Java
// Java Program to find bitonic point in an array
// using Binary Search
import java.util.*;
class GfG {
static int findMaximum(int[] arr) {
int n = arr.length;
// Check if the first element is maximum
if (n == 1 || arr[0] > arr[1])
return arr[0];
// Check if the last element is maximum
if (arr[n - 1] > arr[n - 2])
return arr[n - 1];
// Search Space for binary Search
int lo = 1, hi = n - 2;
while (lo <= hi) {
int mid = lo + (hi - lo) / 2;
// If the element at mid is maximum then return it
if (arr[mid] >= arr[mid - 1] && arr[mid] > arr[mid + 1])
return arr[mid];
// If next element is greater, then maximum
// element will exist in the right subarray
if (arr[mid] < arr[mid + 1])
lo = mid + 1;
// Otherwise, it will exist in left subarray
else
hi = mid - 1;
}
return arr[hi];
}
public static void main(String[] args) {
int[] arr = {1, 2, 4, 5, 7, 8, 3};
System.out.println(findMaximum(arr));
}
}
Python
# Python program to find bitonic point in an array
# using Binary Search
def findMaximum(arr):
n = len(arr)
# Check if the first element is maximum
if n == 1 or arr[0] > arr[1]:
return arr[0]
# Check if the last element is maximum
if arr[n - 1] > arr[n - 2]:
return arr[n - 1]
# Search Space for binary Search
lo, hi = 1, n - 2
while lo <= hi:
mid = lo + (hi - lo) // 2
# If the element at mid is maximum then return it
if arr[mid] > arr[mid - 1] and arr[mid] > arr[mid + 1]:
return arr[mid]
# If next element is greater, then maximum
# element will exist in the right subarray
if arr[mid] < arr[mid + 1]:
lo = mid + 1
# Otherwise, it will exist in left subarray
else:
hi = mid - 1
return arr[hi]
if __name__ == "__main__":
arr = [1, 2, 4, 5, 7, 8, 3]
print(findMaximum(arr))
C#
// C# program to find bitonic point in an array
// using Binary Search
using System;
class GfG {
static int findMaximum(int[] arr) {
int n = arr.Length;
// Check if the first element is maximum
if (n == 1 || arr[0] > arr[1])
return arr[0];
// Check if the last element is maximum
if (arr[n - 1] > arr[n - 2])
return arr[n - 1];
// Search Space for binary Search
int lo = 1, hi = n - 2;
while (lo <= hi) {
int mid = lo + (hi - lo) / 2;
// If the element at mid is a
// maximum element then return mid
if (arr[mid] > arr[mid - 1] && arr[mid] > arr[mid + 1])
return arr[mid];
// If next element is greater, then maximum
// element will exist in the right subarray
if (arr[mid] < arr[mid + 1])
lo = mid + 1;
// Otherwise, it will exist in left subarray
else
hi = mid - 1;
}
return arr[hi];
}
static void Main() {
int[] arr = {1, 2, 4, 5, 7, 8, 3};
Console.WriteLine(findMaximum(arr));
}
}
JavaScript
// JavaScript program to find bitonic point in an array
// using Binary Search
function findMaximum(arr) {
let n = arr.length;
// Check if the first element is maximum
if (n === 1 || arr[0] > arr[1])
return arr[0];
// Check if the last element is maximum
if (arr[n - 1] > arr[n - 2])
return arr[n - 1];
// Search Space for binary Search
let lo = 1, hi = n - 2;
while (lo <= hi) {
let mid = lo + Math.floor((hi - lo) / 2);
// If the element at mid is a
// maximum element then return mid
if (arr[mid] > arr[mid - 1] && arr[mid] > arr[mid + 1])
return arr[mid];
// If next element is greater, then maximum
// element will exist in the right subarray
if (arr[mid] < arr[mid + 1])
lo = mid + 1;
// Otherwise, it will exist in left subarray
else
hi = mid - 1;
}
return arr[hi];
}
let arr = [1, 2, 4, 5, 7, 8, 3];
console.log(findMaximum(arr));
Bitonic Point – Maximum in Increasing Decreasing Array
Visit Course
Explore
DSA Fundamentals
Data Structures
Algorithms
Advanced
Interview Preparation
Practice Problem