Saturday, January 5, 2013

Search in Sorted but Rotated Array

Given a sorted array that is sorted by rotated, find a given number. For example take an array: 1 3 8 10 12 56 and rotate it so you have 10 12 56 1 3 8 and then find a candidate e.g. 3 in it.


Input/Ouput:

Array:
10 12 56 2 3 8 9
3 is present at index: 4

No comments:

Post a Comment