Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

. A d-ary heap, d > 2 is like a heap, but instead of 2 children, nodes may have up to d children. A d-ary

. A d-ary heap, d > 2 is like a heap, but instead of 2 children, nodes may have up to d children. A d-ary heap can be viewed as a complete dary tree (just as the binary heap could be viewed as a complete binary tree). The definition of a complete or full d-ary tree, d > 2, is the same as that of a complete or full binary tree, but where each internal node (except for possibly some nodes in the second lowest level of the tree) has exactly d children instead of only two. In order to answer the questions below, you may need to first describe the functions Parent(i) and Child(i, j), 1 j d, which return, respectively, the parent of node i and the j-th child of node i in the d-ary heap. Assume that the children of a node are ordered from left to right in the d-ary tree representing the d-ary heap. Please briefly justify each of your answers.

(a) How would you represent a d-ary heap using an array ?

(b) Describe the procedures Extract-Max and Insert on a d-ary heap. Your procedures should each run in (logd n) time. Hint: What is the height of a full d-ary tree on n nodes (which will roughly be the same as the height of a complete d-ary tree on n nodes, as in the case of binary trees)?

(c) For a d-ary heap A, an index i, and a key k, describe a procedure Heap-Increase-Key(A, i, k) which sets A[i] = max(A[i], k) and updates the heap structure appropriately that runs in (logd n) time.

(d) How do you compare (in terms of efficiency) two procedures that have running times of (logd n) and (log n) (where d is a constant and log n = log2 n) respectively ?

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

Options Trading QuickStart Guide The Simplified Beginners Guide To Options Trading

Authors: Clydebank Finance

2nd Edition

1945051051, 978-1945051050

Students also viewed these Databases questions