• retagged by
713 views
0 0 votes

https://gateoverflow.in/18752/tifr2010-b-29

IN THIS QUESTION WHY WE CANT NOT APPLY SINGLE BINARY SEARCH ON ENTIRE ARRAY ???

BECAUSE LET WE HAVE ARRAY 1 14 3 12  5 10 7 8 9 6 11 4 13 2 

SUPPOSE WE NEED TO FIND 4

MID =7 AT MID THERE IS ODD NUMBER SO EITHER CHECK TO LEFT OR RIGHT SUPPOSE TO LEFT  IT IS 10 AND WE KNOW EVEN NUMBER ARE ARRANGED IN DESCENDING ORDER SO 4 WILL BE ON RIGHT OF 7 SO SIMILARLY WE CAN DO LIKE THAT.....IOS THIS APPROACH CORRECT??

 

1 Answer

1 1 vote
1. Even numbers are not arranged in Descending , question is saying "The numbers in even positions are sorted in descending order"

2. For binary search we need complete array to be  sorted.
Position:
Show:

Related questions

7 7 votes
3 3 answers
2.5k
2.5k views
just_bhavana asked Aug 22, 2017
2,541 views
Which of the following is exact recurrence relation for binary search (in terms of number of comparisons) ?1. T(n) = 2T(n/2) + 12. T(n) = 2T(n/2) + 2Please specify releva...
11 11 votes
2 answers 2 answers
14.1k
14.1k views
Shubhanshu asked Jun 5, 2017
14,092 views
The average successful search time taken by binary search on a sorted array of $10$ items?$2.6$$2.7$$2.8$$2.9$Answer is $2.9$My doubt:- But when I am using $log_2n$ for $...
1 1 vote
1 1 answer
216
216 views
GO Classes asked Aug 26
216 views
Which of the following cannot be a sequence of keys compared during a binary search for some target key?$500,200,450,180$ $500,450,200,180$ $180,500,200,450$ $180,200,500...
2 2 votes
2 2 answers
227
227 views
GO Classes asked Aug 12
227 views
Suppose Binary Search is used in Insertion Sort to locate where the $i$th element should be inserted among the first $i-1$ elements.What is the worst-case running time of...