Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started