Question

Consider the following max-heap: i 0 1 2 3 4 5 6 7 8 pq[i] -...

Consider the following max-heap:

i 0 1 2 3 4 5 6 7 8
pq[i] - 30 18 28 17 6 20 2 9

Show the resulting heap as array after performing delmax().

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Given heap:

In order to delete 30, we replace 9 i.e. the last node with it and then delete 30:

Then we swap the value 9 with the immediate maximum child:

Further we again swap 9 with the immediate child 20 as:

This results in the final heap!

Please find the required resulting heap as an array as the following:

28 18 20 17 6 9 2
Add a comment
Know the answer?
Add Answer to:
Consider the following max-heap: i 0 1 2 3 4 5 6 7 8 pq[i] -...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT