Awesome q2a theme
0 votes
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)

in Compiler Design by (613 points) | 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?

Please log in or register to answer this question.

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Welcome to GATE CSE Doubts, where you can ask questions and receive answers from other members of the community.
Top Users Jan 2020
  1. shashin

    1163 Points

  2. Vimal Patel

    306 Points

  3. Deepakk Poonia (Dee)

    305 Points

  4. Debapaul

    237 Points

  5. Satbir

    192 Points

  6. SuvasishDutta

    137 Points

  7. Pratyush Priyam Kuan

    118 Points

  8. tp21

    108 Points

  9. DukeThunders

    96 Points

  10. pranay562

    95 Points

Monthly Top User and those within 60% of his/her points will get a share of monthly revenue of GO subject to a minimum payout of Rs. 500. Current monthly budget for Top Users is Rs. 75.
2,989 questions
1,509 answers
8,935 comments
89,814 users