Question discussion

Consider the following array of elements: 89, 19, 50, 17, 12, 15, 2, 5, 7, 11, 6, 9, 100. What is the minimum number of interchanges needed…

5247Medium DSSSB TGT Computer Science 0 replies 0 views
0
Consider the following array of elements: 89, 19, 50, 17, 12, 15, 2, 5, 7, 11, 6, 9, 100. What is the minimum number of interchanges needed to convert it into a max-heap?
  • A2
  • B3
  • C5
  • D4
Correct answer: B

Explanation

Taking the intended array 89, 19, 50, 17, 12, 15, 2, 5, 7, 11, 6, 9, 100 (the digits are garbled in the paper), building a max-heap needs 3 swaps: 15↔100, 50↔100 and 89↔100.

Discussion 0

Nobody has replied yet. Start the discussion!