Question

Heaps: Show by hand the Insertion of the following into a Max Binary Heap (aka, a...

  1. Heaps:
  1. Show by hand the Insertion of the following into a Max Binary Heap (aka, a Max Heap): 150, 166, 75, 20, 175, 111, 80, 95, 90, 25, 50, 92, 200, 5, 6. Show any steps that involve swapping nodes.

Theory here

  1. Show the heap you generated in (a) in array form.

Array here

  1. How could you use a heap to help you efficiently merge many (n> 2) sorted arrays into one sorted array?

Theory here

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

Solution:-

Max heap construction with possible swapping is done and can be seen below.

1050) 150 150 166 166 166 75 (166 75 150 TS 150 20 166 166 (175 735 (150 크 150) 175. 16 (150 20 15 1/1 80) 20 175 20 175 175(175. 175. 773 IEE 150 (166 (20) 166 ㅋ 150 (43) 15 75 75 15 0 AD 12.00 CO 95 5 No (20) 250 (3) (25 5) (32) (it) Re (ia) (25)

Max heap in array form:-

200 166 175 95 75 150 80 20 90 25 50 92 111 5 6

A heap can be used to efficiently merge sorted arrays into one sorted array. The methodology involves the usage of a min heap from which smaller elements are discarded till all the elements of arrays are inserted and you get the desired array. If there are m elements to be inserted in the min heap so the height of the heap would be logm , n*m will be the number of elements in total through all the arrays. Therefore the time taken would be O(n*m*logm).

Add a comment
Know the answer?
Add Answer to:
Heaps: Show by hand the Insertion of the following into a Max Binary Heap (aka, a...
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
ADVERTISEMENT