

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Please refer to the general information handout for the full homework policy and options.
Reminders
Exercises These should not be handed in, but the material they cover may appear on exams: problems in Chapter 4.
Problems to be handed in
(a) f (n) = O(g(n)) implies g(n) = Ω(f (n)). (b) f (n) = Θ(f (n/2)). (c) f (n) = O(g(n)) implies log(f (n)) = O(log g(n)), when log(g(n)) ≥ 1 and f (n) ≥ 1 for all sufficiently large n.
(a) How would you represent a d-ary heap in an array? (b) Implement Parent(i) that, given the index i of a node, returns the index of its parent and Child(i, k) that, given the index i of a node, returns the index of its kth child. (c) What are the minimum and the maximum number of elements in a d-ary heap of height h? (d) Design an efficient implementation of Heapify-Up in a d-ary min-heap, analogous to the procedure on page 61 of KT. Analyze the running time of your algorithm in terms of d and n.
(e) Design an efficient implementation of Heapify-Down in a d-ary min-heap, analogous to the procedure on page 63 of KT. Analyze the running time of your algorithm in terms of d and n. (f) Suppose we implement a priority queue using a d-ary heap. Give the running times of all operations, described on pages 64–65 of KT, in terms of d and n.