GATE Papers >> CSE >> 2015 >> Question No 230

Question No. 230 CSE | GATE 2015

Consider the following array of elements
89, 19, 50, 17, 12, 15, 2, 5, 7, 11, 6, 9, 100
The minimum number of interchanges needed to convert it into a max-heap is


Answer : (D) 3


Solution of Question No 230 of GATE 2015 CSE Paper

Array:

0 1 2 3 4 5 6 7 8 9 10 11 12
89 19 50 17 12 15  2   5   7  11 6 9 100

1st interchange : 100 & 15 (A[12] & A[5])

⇒ 2nd interchange : 100 % 50 (A[5] & A[27])

⇒ 3rd interchange  : 100 & 89 (A[2] & A[0])

Maxheap Array:

100 19 89 17 12 50  2  5  7 11 6 9 15
0 1 2 3 4 5 6 7 8 9 10 11 12
Comments
Zg8e03 http://pills2sale.com/ viagra cialis buy

Posted on  01/11/2020 19:22:21  by  johnanx
Leave a comment