recategorized by
1,211 views
4 votes
4 votes

There are two sorted list each of length $n$. An element to be searched in the both the lists. The lists are mutually exclusive. The maximum number of comparisons required using binary search is?

Their solution : $logn + logn = 2*logn = logn^{2}$.

My Solution : $min(logn_{1}, logn_{2}) = logn$ as $n1 = n2$. The intuition behind my solution is that we can do binary search in both the lists in parallel, we return from the search the moment we find the element.

 

So tell me whose solution is correct? Why my solution should be incorrect?

recategorized by

1 Answer

3 votes
3 votes

Two sorted list, each of length n.

Another point is both are mutually exclusive , means every element of one list is different from every element of other list.

  • So, first do binary search on list1
  • if element is found then stop

         here maximum comparison will be log n

  • if element not found , go to second list and find element in log n time

      So,total number of comparison O(2log n)=O(log n)

Related questions

0 votes
0 votes
1 answer
2
Sabir Khan asked Aug 8, 2018
1,092 views
The minimum number of comparisons required to determine if an integer appears more than n/2 times in a sorted array of n integers is(A) (n)(B) (logn)(C) (log*n)(D) (1)
5 votes
5 votes
4 answers
3
Raushank2 asked Jun 28, 2017
2,701 views
I/p - Sorted array of n elementO/p- find any two elements a and b such that (a+b)>1000if lenear search is possible then go to Binary Search and Find time complexity ..?
11 votes
11 votes
2 answers
4
Shubhanshu asked Jun 5, 2017
11,212 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 $...