[algogeeks] Re: Find min after rotating an array

2011-06-05 Thread Dan
It depends "highly" on the language used doesn't it? Based on the problem as stated I'd assume no prior knowledge of the rotation amount or direction. Unless the array is known/assumed to be very large, the simplest solution is likely the best. Anything else may not qualify under the "elegan

Re: [algogeeks] Re: Find min after rotating an array

2011-05-28 Thread immanuel kingston
Modified Piyush's soln to handle the above case. int get_pivot(int a [ ],int low, int high) { if (low < high) { int mid = (low+high)/2; if(a[mid]>a[mid+1]) return mid+1; if(a[low]>a[mid]) return (get_pivot(a,low,mid-1)); else

[algogeeks] Re: Find min after rotating an array

2011-05-28 Thread Dumanshu
It won't work if we rotate the array by 0. So is that the xtra case do we have to consider??? On May 28, 7:18 pm, Piyush Sinha wrote: > 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

[algogeeks] Re: Find min after rotating an array

2011-05-28 Thread Dumanshu
ok... seems fine. thanx! On May 28, 7:18 pm, Piyush Sinha wrote: > 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]) >