Question: Exercise 1 . In this exercise, we assume arrays start at index one. Recall that heaps can be seen as binary trees: the root is

Exercise 1.
In this exercise, we assume arrays start at index one. Recall that heaps can be seen as binary trees: the root is A[1], the left child of A[i] is A[2i], and the right child of A[i] is A[2i+1].
1. Which of the following arrays are heap-structured as max-heaps? Which ones as min-heaps?
(a) A1=[0,1,2,3,4,5,6,7,8,9]
(b) A2=[9,8,5,6,7,4,3,0,1,2]
(c) A3=[0,1,3,4,5,2,6,7,8,9]
2. Draw the heap after inserting 5 into the heap A4=[0,2,1,3,6,4,8,9,7].
3. If you insert an element into a heap with 7 elements, which locations of the array could be altered (in the course of the insert operation)?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!