This preview shows page 1. Sign up to view the full content.
Unformatted text preview: > + = = ∞= 1 ) ( ) ) ( ), ( max( 1 1 ) ( ) ( ) ( T n R h L h T n T n T h Here ) ( T n denotes the number of nodes in a binary tree T , ) ( T h denotes its height, L denotes its left subtree, and R its right subtree. Note that this proof can be phrased equally well as an induction on ) ( T n or on ) ( T h . Hint: use (and prove) the following fact: ) 2 lg( ) 1 2 lg( k k = + for any positive integer k . 4. (1 Point) p.132: 6.25 The code for MaxHeapify is quite efficient in terms of constant factors, except possibly for the recursive call in line 10, which might cause some compilers to produce inefficient code. Write an efficient MaxHeapify that uses an iterative control construct (a loop) instead of recursion....
View
Full
Document
This note was uploaded on 12/03/2009 for the course CS CS101 taught by Professor Agoreback during the Spring '09 term at American College of Gastroenterology.
 Spring '09
 AgoreBack
 Sort

Click to edit the document details