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](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f2fe6a3acfa_87366f2fe69a45ce.jpg)
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 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-GRANDPARENT15) outputs "2 PRINT-GRANDPARENTS(8) outputs "6 21" 18 23". Also b) Write a pseudocode for a method called PRINT-ANTi). 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 23 21 20 18 13 12 10 15
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
