finding the min element in it.
Answer:
Let original array be 10 20 30 40 50 , so on rotation it become 40 50 10 20 30
40 50 10 20 30
^ ^
Up Down
up = array.begin();
down = Up+1;
while(down != array.end() )
{
if(*down < *up ) then *down is the smallest element
++up;
++down;
}
No comments:
Post a Comment