Search Menu


Heap Sort Problems

Heap Sort Problems

Heap Sort Problems

Heap Sort Problems

Problem : In terms of space, why is heap sort attractive?

Heap sort does not require any temporary space to store values; the only space needed is the list itself.

Problem : Does the following array represent a heap?

{8, 5, 9, 3, 6, 2, 1}

No. You can easily tell that this array does not represent a proper heap by noticing that the largest element is not in the first position (the root node).

Problem : What is the maximum depth of a heap with n elements?


Problem : Imagine that instead of using an array to represent the heap, we use a singly linked list. Why might this be innefficient? (Hint: Consider the insertions that must be done).

Heap sort requires that we repeatedly insert the largest element in the heap at the end of the usorted portion of the list. If the singly linked list implementation we use doesn't keep a pointer to the end of the list, this operation could be as costly as O(n) .