hw6 - > + = = ∞-= 1 ) ( ) ) ( ), ( max( 1 1 ) ( ) ( )...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CMPS 101 Summer 2009 Homework Assignment 6 1. (1 Point) p.551: 22.4-1 Show the ordering of vertices produced by TOPOLOGICAL-SORT when it is run on the dag of Figure 22.8, under the assumption of Exercise 22.3-2. 2. (1 Point) p.557: 22.5-2 Show how the procedure STRONGLY-CONNECTED-COMPONENTS works on the graph of Figure 22.6. Specifically, show the finishing times computed in line 1 and the forest produced in line 3. Assume that the loop of lines 5-7 of DFS considers vertices in alphabetical order and that the adjacency lists are in alphabetical order. 3. (1 Point) p.1091: B.5-4 Use induction to show that a nonempty binary tree with n nodes has height at least lg n . Hint: use the recursive definition of height discussed in class:
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

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.2-5 The code for Max-Heapify 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 Max-Heapify 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.

Ask a homework question - tutors are online