[algogeeks] Find min after rotating an array

2011-05-28 Thread Dumanshu
Find an elegant way of getting the minimum value in a sorted array but it has been rotated by some number. say u had the array as 4 , 5, 6, 7, 8,9 and u rotate it by 2. u get 6,7,8,9,4,5. Now u have to find minimum number in this modified array. -- You received this message because you are

Re: [algogeeks] Find min after rotating an array

2011-05-28 Thread Piyush Sinha
The main idea is to get the point at which the the rotation is made...It can be done in O(lgN) time complexity... int get_pivot(int a [ ],int low, int high) { int mid = (low+high)/2; if(a[mid]a[mid+1]) return (a[mid+1]); if(a[low]a[mid]) return