18.04.2013 Views

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Lecture 6 - linear sorting<br />

Next: Lecture 7 - elementary Up: No Title Previous: Lecture 5 - quicksort<br />

Lecture 6 - linear sorting<br />

Listen To Part 6-1<br />

7.1-2: Show that an n-element heap has height .<br />

Since it is balanced binary tree, the height of a heap is clearly , but the problem asks for an exact<br />

answer.<br />

<strong>The</strong> height is defined as the number of edges in the longest simple path from the root.<br />

<strong>The</strong> number of nodes in a complete balanced binary tree of height h is .<br />

Thus the height increases only when , or in other words when is an integer.<br />

Listen To Part 6-2<br />

7.1-5 Is a reverse sorted array a heap?<br />

In a heap, each element is greater than or equal to each of its descendants.<br />

In the array representation of a heap, the descendants of the ith element are the 2ith and (2i+1)th<br />

elements.<br />

If A is sorted in reverse order, then implies that .<br />

file:///E|/LEC/LECTUR17/NODE6.HTM (1 of 7) [19/1/2003 1:34:38]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!