C Programming MCQ

1:

Minimum number of interchange needed to convert the array 89,19,40,14,17,12,10,2,5,7,11,6,9,70, into a heap with the maximum element at the root is

A.

0

B.

1

C.

2

D.

3

 

Answer : C

Explanation :

Only element 70 violates the rule. Hence, it must be shifted to its proper position.
Step1: swap(10, 70)
Step2: swap(40, 70)
Hence, only 2 interchanges are required.

Anoop Rekha said: (10:41am on Tuesday 7th May 2013)
Element 70 and 40 violates the rule. Hence they must be shifted to its proper position. first swap 70 with 10 2nd swap 70 with 14then from other side swap 40 with 19. So three interchanges required. Ans should be three
Mayank said: (6:09pm on Tuesday 7th May 2013)
I m getting three (3)
ruchi said: (8:57pm on Monday 22nd June 2015)
not understandexplain with to draw the heap structure

Write your comments here:


Report Error
 

Option: A

Explanation : Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here.