517 views
5 votes
5 votes

Which of the following statements is/are TRUE? (Mark all CORRECT choices)

  1. The expected number of comparisons in a successful linear search is $n$
  2. The expected number of comparisons in a successful binary search is $O(\log n)$
  3. The best case runtime of linear search is asymptotically better than binary search
  4. In worst case binary search can lead to $\Omega(n)$ comparisons

1 Answer

Best answer
5 votes
5 votes
Only B option is true here.

The expected number of comparisons in a successful linear search is $\lceil n/2 \rceil$ as the successful item is equally likely to be in any of the $n$ locations.

In best case both linear search and binary search can work in $O(1)$ time as the searched item should be the first element.

In worst case also binary search can work in $\Omega(\log n) $ comparisons as after each search half the elements get eliminated.
selected by
Answer:

Related questions