Question: 2. [20 marks] Assume that we have a binary heap that we are representing as a 0-based index array. (Similar to the binary heap in

 2. [20 marks] Assume that we have a binary heap that

2. [20 marks] Assume that we have a binary heap that we are representing as a 0-based index array. (Similar to the binary heap in class with the difference that indices start from 0). Use these three methods below to answer to parts (a) and (b) ParenT(i) LEFT(i) RICHT(i) return L(i -1)/2 return 2i + 1 return 2i + 2 a) Write a recursive pseudocode for a method called PRINT-GRANDPARENTS(i). For a given index i, this method prints i, then parent-of-parent of i, and so on. For example, on the following heap PRINT-GRANDPARENTS (15) outputs "2 PRINT-GRANDPARENTS (8) outputs "6 21". Write a pseudocode for a method called PRINT-AuNT(i). For a given index i, this method prints the sibling of the node's parent For example, on the following heap PRINT-AUNT 5) outputs 21, and PRINT-AuNT(7) outputs 14 18 23". Also, b) 0 23 21 4 18 14 6 (11 12 1 15

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 Databases Questions!