0

I need to find a tight bound on the number of comparisons in a d-ary heapsort, in terms of d and n (the length of the array we want to sort).

Since inserting n items to a heap takes O(n) , and each delete-min takes O(d log n/ log d), I was thinking the bound is O(n d log n / log d). Am I right? If so, how do I prove that it is indeed a tight bound?

Thanks.

Jaja
  • 39
  • 3

1 Answers1

1

Inserting $n$ items to a heap takes $\Theta(n)$.

You probably mean that "building" a heap takes $\Theta(n)$.

Each delete-min takes $\Theta(d \lg n/ \lg d)$, I was thinking the bound is $\Theta(n d \lg n / \lg d)$.

I agree with you.

How do I prove that it is indeed a tight bound?

How tight do you want to prove it is? Do you want to show that the worst-case running time of $d$-ary heap-sort is $\Omega(n d \lg n / \lg d)$? If so, I tend to think it is indeed tight.

For a hint, this paper: The Analysis of Heapsort mentions that (in Abstract)

The number of keys moved during $2$-ary heap-sort when sorting a random file of $n$ distinct elements is $n \lg n + O(n)$ in the worst case.

It even further proves that (Notice that it is for the best case)

Theorem 1 (Page 7): Heap-sort ($2$-ary) requires at least $\frac{1}{2} n \lg n- O(n)$ data moves for any heap composed of distinct keys.

Maybe you can adapt it to $d$-ary heap-sort.

hengxin
  • 9,541
  • 3
  • 36
  • 73