On Aug 7, 4:41 pm, AlgoBoy <[email protected]> wrote: > is there a way to apply a binary search on a sorted array...with a > catch... the array is rotated k times clockwise > > Example...4,5,1,2,3... > > I heard a binary search is possible..
Of course it's possible. If the array A has N items, then just replace every reference in the normal binary search A[I] with A[(I+k) mod N] (or (I-k) mod N depending on how you define "clockwise"). The algorithm will see the "unrotated" version of the array. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
