Question: 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

 Problem 2.Suppose we implement a d-ary heap in an array (see

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

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!