Page 1 of 1

Please do all part as it's of same questions . And solve it clearly please Question 5: Heap (20 pts). A max-heap is a da

Posted: Fri May 20, 2022 4:56 pm
by answerhappygod
Please do all part as it's of same questions .
And solve it clearly please
Question 5: Heap (20 pts). A max-heap is a data structure
wherein each node’s value is larger than both of its children. A
max-heap is stored in an array and can also be logically
represented by a complete binary tree. We showed two ways to build
a max-heap. One is to assume the array is empty and to insert the
values one by one. The other is to assume the values are already
stored in an array and build the max-heap accordingly. Consider the
followings values: 5, 7, 8, 1, 2, 3, 12.
a.If the array initially stores the values in the order as
above, draw the complete binary tree and the array of the max-heap
once it is constructed.
b. If the array is initially empty, draw the complete binary
tree as well as the array of the max-heap once it is
constructed.
c . After deleting the maximum value, draw the complete binary
tree as well as the array of the max-heap.
d. After inserting a new value 15, draw the complete binary tree
as well as the array of the max-heap.