[algogeeks] Re: searching a number in circular sorted array

2011-06-10 Thread L
Use ternary search to find the minimum number. (In this case 1) Then you have two sorted arrays, one ascending and one descending. Now, you can apply binary search. First, check the number with the last element and the first element and chose the appropriate array for searching. Time complexity:

Re: [algogeeks] Re: searching a number in circular sorted array

2011-06-10 Thread Rujin Cao
Binary search is sufficient for this particular case. To help the explain, we assume the circular sorted array is ascending if probably rotated. we use *d[0..n - 1]* to represent the array with n elements and *v* to represent the searched number. Observing the circular sorted sequence d[0..n -