VOOZH about

URL: https://www.geeksforgeeks.org/dsa/find-minimum-element-in-a-sorted-and-rotated-array/

⇱ Minimum in a Sorted and Rotated Array - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Minimum in a Sorted and Rotated Array

Last Updated : 20 Feb, 2026

Given a sorted array of distinct elements arr[] of size n that is rotated at some unknown point, the task is to find the minimum element in it. 

Examples:

Input: arr[] = [5, 6, 1, 2, 3, 4]
Output: 1
Explanation: 1 is the minimum element present in the array.

Input: arr[] = [3, 1, 2]
Output: 1
Explanation: 1 is the minimum element present in the array.

Input: arr[] = [4, 2, 3]
Output: 2
Explanation: 2 is the only minimum element in the array.

[Naive Approach] Linear Search - O(n) Time and O(1) Space

A simple solution is to use linear search to traverse the complete array and find a minimum


Output
1

[Expected Approach] Binary Search - O(log n) Time and O(1) Space

The array is sorted and then rotated, so it consists of two sorted parts, with the minimum element located at the rotation point.
Using Binary Search, we can efficiently narrow down the part that contains the minimum by checking whether the current range is already sorted and by comparing the middle element with the last element.

Steps for Implementation:

  • If arr[low] < arr[high], the current range is already sorted, return arr[low].
  • Compute mid.
  • If arr[mid] > arr[high], the minimum lies to the right of mid, set low = mid + 1.
  • Otherwise, the minimum lies at mid or to its left, set high = mid.
  • When low == high, that index stores the minimum element.



Output
1


Comment