retagged by
647 views
2 votes
2 votes
An unordered list contains n distinct elements. Number of comparisons to find element larger than second minimum is

O(1)

O(n)

None
retagged by

1 Answer

Best answer
1 votes
1 votes

the trick here.

since it is given that the list has distinct elements

=>when we select any 3 numbers the largest of the 3 will always be greater than the second minimum.

Number of comparisons to find element larger than second minimum

  1. suppose there are numbers  2,3,8,1,4,5,9
  2. take any 3 no. lets take 3,8,1.
  3. select the greatest number from it  i.e. 8. we need only 2 comparisons (  O(1) )
  4.  8 > 2.... answer.
selected by

No related questions found