retagged by
8,182 views
5 votes
5 votes
You are given an array of 64 elements, minimum number of comparisons required to find out second largest element among all will be _______.
retagged by

1 Answer

Best answer
15 votes
15 votes
To find the second largest element, we need to find largest element first.

Number of comparisons to find largest number = n - 1 = 64 - 1 = 63

Now, the second largest must be in the losers of first largest i.e. it might have descended down logn levels at most.

So, number of comparisons to find second largest among logn elements = logn - 1 = log(64) - 1 = 6 - 1 = 5

So total comparisons in all = (n -1) + (logn - 1) = 63 + 5 = 68
edited by

Related questions

1 votes
1 votes
1 answer
1
mystylecse asked Aug 15, 2017
3,493 views
The minimum number of comparisons required to find the minimum and maximum of 60 numbers is..............
19 votes
19 votes
8 answers
2
piyushkr asked Dec 30, 2015
43,691 views
The minimum number of comparisons required to sort 5 elements is -4567
0 votes
0 votes
3 answers
3
pankaj_vir asked Oct 10, 2018
1,270 views
What is the total number of comparisons needed in the best case to find minimum and maximum of $300 $ elements?
2 votes
2 votes
1 answer
4
yes asked Oct 6, 2015
1,405 views
for example array contain a[1 2 3 3 3 3 3 4 5] then retun(1)