Saturday, April 9, 2011

Find Minimum element in sorted but rotated array

Input:
6 5 4 2 3
Output:
Elements in the array:
6 5 4 2 3
Min:2


Code:

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hi,

    Input:
    6 5 4 2 3
    It seems this input is not sorted then rotated.

    if it was rotated you would not need the last else case, as by definition either [low,mid] or ]mid,high] would be sorted

    ReplyDelete