Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A d-ary max-heap, d-heap for short, is the generalization of a binary heap to a d-ary tree, for a fixed d greaterthanorequalto 2. Every node
A d-ary max-heap, d-heap for short, is the generalization of a binary heap to a d-ary tree, for a fixed d greaterthanorequalto 2. Every node can have up to d children, the tree has to be almost complete, and the max-heap property is fulfilled. (a) For given fixed h greaterthanorequalto 0 and d greaterthanorequalto 2, give a formula for the number n of nodes in a complete d-ary tree of height h. Your formula should depend on n and d. Justify its correctness. (b) Suppose a d-heap is stored in an array that begins with index 0. For an entry located at index i, in which location is its parent and in which locations are its children? (No formal proof necessary.) (c) What is the height of a d-heap that contains n elements? The height should be a function of n and d. Shortly justify your answer: a formal proof is not necessary. (d) Shortly explain how the insertion procedure works for d-heaps (you do not have to give pseudocode). What is the runtime of inserting an element into a d-heap of n elements? The runtime should be a function of n and d. (e) Shortly explain how the extract_max procedure works for d-heaps (you do not have to give pseudocode). What is the runtime in terms of n and d, where n is the number of elements in the heap
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