The minimum number of comparisons required to find the minimum and the maximum…
2014
The minimum number of comparisons required to find the minimum and the maximum of 100 numbers is _________________.
Attempted by 101 students.
Show answer & explanation
Correct answer: 148
Key idea: use pairwise comparisons to reduce the total number of comparisons.
If n is even: Compare the first two elements (1 comparison) to initialize the current minimum and maximum. Then process the remaining n−2 elements in pairs. Each pair requires 3 comparisons (compare the two elements, then compare the larger to the current max and the smaller to the current min). Total = 1 + 3*(n−2)/2 = 3n/2 − 2.
If n is odd: Initialize min and max using the first element (0 comparisons). Process the remaining n−1 elements in pairs, each requiring 3 comparisons. Total = 3*(n−1)/2.
Apply to n = 100 (even):
Comparisons = 3*100/2 − 2 = 150 − 2 = 148.
Therefore the minimum number of comparisons required to find both the minimum and maximum of 100 numbers is 148.
A video solution is available for this question — log in and enroll to watch it.