Question

Question 1 (CLO-4, PLo-3) Figure 1 show an input tree T. 1. Analyze the tree and mention weather the tree is a heap or not by

need full solution of this question plz help me

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

Answer 1:

Answer 1. Yes, Given tree is heap.

Justification:

As we know that

the min-heap property: the value of each node is greater than or equal to the value of its parent, with the minimum-value element at the root.

the max-heap property: the value of each node is less than or equal to the value of its parent, with the maximum-value element at the root.

As we can easily observe given tree, it follows the property of max-heap.

Answer 2.

After altering the value of T[11] to 100,

(i) Tree is not a Heap now, because it violates the property of max heap, as 55 < 100.

(ii) I will select Percolation algorithm to make it a heap.

(iii) Percolation algorithm: The heap property is repaired by comparing the added element with its parent and moving the added element up a level (swapping positions with the parent). This process is called "percolation up". The comparison is repeated until the parent is larger than or equal to the percolating element.

For the heap, please refer the following figure:

04 84 Aftes 2 benc olaten 61 31) (5D

Answer 3.

From the heap made in part (ii), the maximum value will be 100 that is root element.

Answer 4.

CAI 84 19 41 81 6lAnswer 5.

Insert a une l . 6 4 70 19 tin (62) 31) (SD

Answer 2:

e aivem Мад 21 lo 21 31 31 4 2 at 3) 31 !스

As we can sort all elements one by one as i did in above figure. I have sort two elements, you can continue like this. At last step we would get sorted array in ascending order.

Please give thumbsup, if you like it. Thanks.

Add a comment
Know the answer?
Add Answer to:
need full solution of this question plz help me Question 1 (CLO-4, PLo-3) Figure 1 show an input tree T. 1. Analyze the tree and mention weather the tree is a heap or not by checking heap's pr...
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