Question discussion

What is the minimum number of comparisons needed to find both the largest and the smallest of 8 distinct numbers?

1720Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the minimum number of comparisons needed to find both the largest and the smallest of 8 distinct numbers?

  • A12
  • B10
  • C14
  • D7
Correct answer: B

Explanation

Comparing the numbers in pairs (4 comparisons) and then finding the maximum among the 4 winners (3) and the minimum among the 4 losers (3) needs 3n/2 − 2 = 10 comparisons.

Discussion 0

Nobody has replied yet. Start the discussion!