• recategorized by
1,845 views
4 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?

1 Answer

3 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)

Position:
Show:

Related questions

2 2 votes
2 2 answers
1.2k
1.2k views
ashandeep asked Dec 16, 2015
1,191 views
Consider the process of inserting an element into a max heap, where the max heap is represented by an array.Suppose we perform a binary search on the path from the new le...
0 0 votes
2 2 answers
1.5k
1.5k views
Sabir Khan asked Aug 8, 2018
1,464 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 5 votes
4 4 answers
3.7k
3.7k views
Raushank2 asked Jun 28, 2017
3,651 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 11 votes
2 answers 2 answers
13.8k
13.8k views
Shubhanshu asked Jun 5, 2017
13,791 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 $...