Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions