edited by
54,020 views
89 votes
89 votes
The minimum number of comparisons required to find the minimum and the maximum of $100$ numbers is ________
edited by

16 Answers

5 votes
5 votes

Minimum no of comparisions =148

1 votes
1 votes

Simple and brute force approach

Since, we have 100 elements and initially min=max=0, first two elements are chosen and compare them and update the value of min and max. So, 1 comparison here.

For the next 2 elements, we’ve to compare them first, then the minimum value from them is compared to min, similarly the maximum value from them is compared to max. Therefore, 3 comparisons are required.

Similarly, for the next 2 elements, 3 comparisons are required.

We can observe a pattern here like

2 elements → 3 comparisons

4 elements → 6 comparisons

.

.

.

98 elements → 98*(3/2) = 147 comparisons

(98 here because first two elements are compared once, and we started comparing 3 times from the third element. So, 3rd and 4th element constitute 2 elements, similarly, 3rd,4th,5th and 6th constitute 4 elements and so on.)

Therefore, total number of comparisons  = 147 + 1 = 148 

(1 is added because first two elements are compared once at beginning)

Answer:

Related questions

0 votes
0 votes
1 answer
10
Raghav Khajuria asked Oct 13, 2018
338 views
Minimum no of comparisons required to find the minimum and maximum of n distinct elements
1 votes
1 votes
1 answer
11
mystylecse asked Aug 15, 2017
3,475 views
The minimum number of comparisons required to find the minimum and maximum of 60 numbers is..............
0 votes
0 votes
1 answer
12
Aspi R Osa asked Dec 14, 2015
1,548 views
Consider a set of 20 elements.To find maximum and minimum element in the given set, the minimum number of comparisons required is _________? (using DAC Max-Min algorithm)...