This preview shows page 1. Sign up to view the full content.
Unformatted text preview: gth and differ only in the last bit. Rephrased: the greedy choice property (of picking
the two lowestfrequency nodes) will yield an optimal
tree On board > 76 Step 2
• Lemma 16.3: Let C be a given alphabet with frequency
c.freq defined for each character c C. Let x and y be two
characters in C with minimum frequency. Let C’ be the
alphabet C with the characters x and y removed and a new
character z added, so that C’ = C{x,y}{z}. Define f for C’
as for C, except that x.freq = x.freq + y.freq. Let T’ be any
tree representing an optimal prefix code for the alphabet
C’. Then the tree T, obtained from T’ by replacing the leaf
node for z with an internal node having x and y as children,
represnts an optimal prefix code for the alphabet C. Rephrased: constructing prefix codes has the
optimal substructure property 77 Dijkstra’s Shortest Path 78 Weighted Shortest Path no negative weight edges. Dijkstra’s algorithm: uses similar ideas as the
unweighted case. Greedy algorithms:
do what seems to be best at every decision
point. s 79 S
“known” v
VS
“unknown” Dijkstra’s algori...
View
Full
Document
This note was uploaded on 02/25/2014 for the course CS 4102 taught by Professor Horton during the Spring '10 term at UVA.
 Spring '10
 HORTON
 Algorithms

Click to edit the document details