Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2.Suppose we implement a d-ary heap in an array (see the book, d is a small integer, d 2). Suppose we store the root

image text in transcribed

Problem 2.Suppose we implement a d-ary heap in an array (see the book, d is a small integer, d 2). Suppose we store the root item at index 0 of the array, its leftmost child at 1, its next child at 2, and so on. (The book likes to put the root at index 1, but we will put it at 0.) Suppose the heap stores n 2 1 items. 2(a). Suppose an item is at array index k. What is the index of its leftmost child? 2(b). Supposing k > 0, what is the index of its parent? 2(c). Suppose we want to start the first phase of heapsort (putting the given array into max-heap order). What is the largest index k, so that k has at least one child? 2(d). Give an exact formula for the tree height h, in terms of the size n. (Check your base cases: when n = 1 you should have h 0, and when 2 n-d+ 1 you should have Remark: Each answer is just an integer-valued formula, you may need to round up or round down (like Lk/2] or h/2). You do not need to prove anything

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

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions

Question

2. How were various roles filled?

Answered: 1 week ago