The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
33 views

For the given nodes:

$89, 19, 50, 17, 12, 15, 2, 5, 7, 11, 6, 9, 100$

minimum ______ number of interchanges are required to convert it into a max-heap.

  1. $3$
  2. $4$
  3. $5$
  4. $6$
in DS by Veteran (416k points)
retagged by | 33 views

1 Answer

0 votes

Heap formed by the given values in question is

Now the max heap property is failing on vertices $15$ and $100$

After swapping tree is 

Now the max heap property is failing on vertices $50$ and $100$

After swapping tree is 

Now the max heap property is failing on vertices $89$ and $100$

After swapping tree is 

The above tree is the final max heap binary tree. 

Minimum number of interchanges are $3$

Correct answer:  $A$

by (345 points)

Related questions

0 votes
1 answer
5
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,823 questions
54,822 answers
189,572 comments
81,055 users