# Question: A d ary heap is like a binary heap but with one possible

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 first sets A[i] ← max (A[i], k) and then updates the d-ary max-heap structure appropriately. Analyze its running time in terms of d and n.

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 first sets A[i] ← max (A[i], k) and then updates the d-ary max-heap structure appropriately. Analyze its running time in terms of d and n.

**View Solution:**## Answer to relevant Questions

The QUICKSORT algorithm of Section 7.1 contains two recursive calls to itself. After the call to PARTITION, the left subarray is recursively sorted and then the right subarray is recursively sorted. The second recursive call ...For n distinct elements x1, x2, ..., xn with positive weights w1, w2, ..., wn such that Σni =1 wi = 1, the weighted (lower) median is the element xk satisfying a. Argue that the median of x1, x2, ..., xn is the ...a. Suppose that m is a constant. Describe an O (n)-time algorithm that, given an integer n, outputs the (n, m)-Josephus permutation.b. Suppose that m is not a constant. Describe an O (n lg n)-time algorithm that, given ...Consider the problem of neatly printing a paragraph on a printer. The input text is a sequence of n words of lengths l1, l2, ..., ln, measured in characters. We want to print this paragraph neatly on a number of lines that ...Professor Midas drives an automobile from Newark to Reno along Interstate 80. His car's gas tank, when full, holds enough gas to travel n miles, and his map gives the distances between gas stations on his route. The ...Post your question