Starting from:
$19.99

$17.99

CSCI 305, Homework # 5



1. Analysis of d-ary heaps (problem 6-2 in the text).
A d-ary heap is like a binary heap, but (with one possible exception) non-leaf nodes have d children
instead of 2 children.
(a) How would you represent a d-ary heap in an array?
(b) What is the height of a d-ary heap of n elements in terms of n and d?
(c) Give an efficient implementation of Extract-Max in a d-ary max-heap. Analyze its running
time in terms of d and n.
(d) Give an efficient implementation of Insert in a d-ary max-heap. Analyze its running time in
terms of d and n.
(e) Give an efficient implementation of Increase-Key(A; i; k), which flags an error if k < A[i], but
otherwise sets A[i] = k and then updates the d-ary max-heap structure appropriately. Analyze
its running time in terms of d and n.
1

More products