38 views
 in ‘Chiluvuru’ village there are many mathematicians and algorithm experts. They are always playing with numbers. In that village there is a young student and his name is Bahubali. He is interested in sorting algorithms. So, he taken a sorted array of n elements which has been circularly shifted. For example, {20,25,1,5,10,15} is a sorted array that has been circularly shifted by 2 positions. He want to find the largest element in a circularly shifted array. Here, there is a small constraint that the number of positions through which it has been shifted is unknown. He confuse to get a time complexity, so, try to help him to find time complexity. 1. O(nlogn)   2.  O(logn)   3. O($n^2$)   4.  O(n)
| 38 views
0
is it O(n)?
0
can't we use binary search ?
0
how?
0
Take the middle element, check with adjacents.. If it is not maximum, then compare with starting element of array to traverse either left or right but need not to both sides
0
but, there is a shift operation, which means largest element could be any place.
0
I also gave modified binary search, right?
Take with examples.
0

@Shaik Masthan

U mean it is left shift, yes great then

But if shift also unknown.

I mean this example $5,4,3,1,7,8$

In this case ??

0
0
Can we apply max-min algorithm?