math236 discrete maths with applications
play

Math236 Discrete Maths with Applications P. Ittmann UKZN, - PowerPoint PPT Presentation

Math236 Discrete Maths with Applications P. Ittmann UKZN, Pietermaritzburg Semester 1, 2012 Ittmann (UKZN PMB) Math236 2012 1 / 11 Weighted leaf paths Definition Let T be a rooted tree with root vertex r Let v 1 , v 2 , . . . , v p be the


  1. Math236 Discrete Maths with Applications P. Ittmann UKZN, Pietermaritzburg Semester 1, 2012 Ittmann (UKZN PMB) Math236 2012 1 / 11

  2. Weighted leaf paths Definition Let T be a rooted tree with root vertex r Let v 1 , v 2 , . . . , v p be the leaf vertices of T Respectively, let w 1 , w 2 , . . . , w p be the weights of the leaf vertices The weighted leaf path length of T is p � L ( T ) = w i · d ( r , v i ) i = 1 Ittmann (UKZN PMB) Math236 2012 2 / 11

  3. Optimal trees Definition A rooted binary tree T is a optimal if L ( T ) is less than L ( S ) for all rooted binary trees S with the same set of leaf vertices and leaf weights Ittmann (UKZN PMB) Math236 2012 3 / 11

  4. Optimal trees Theorem Let T be a rooted binary tree which is optimal Let v i and v j be leaf vertices of T such that w i < w j Then d ( r , v j ) ≤ d ( r , v i ) Ittmann (UKZN PMB) Math236 2012 4 / 11

  5. Optimal trees Theorem In an optimal tree, if v 1 , v 2 , . . . , v p are leaf vertices with weights w 1 ≤ w 2 ≤ · · · ≤ w p , then d ( r , v p ) ≤ d ( r , v p − 1 ) ≤ · · · ≤ d ( r , v 1 ) Ittmann (UKZN PMB) Math236 2012 5 / 11

  6. Optimal trees Theorem Every Huffman tree is optimal Ittmann (UKZN PMB) Math236 2012 6 / 11

  7. Optimal trees Proof. Suppose to the contrary that some Huffman tree T with root r is not optimal Let v 1 , v 2 , . . . , v p be the leaf vertices of T with weights w 1 , w 2 , . . . , w p where the weights represent the frequencies of the associated character Let w 1 ≤ w 2 ≤ · · · ≤ w p Then there exists i < j such that d ( r , v i ) < d ( r , v j ) Ittmann (UKZN PMB) Math236 2012 7 / 11

  8. Optimal trees Proof. Note that i < j implies that w i ≤ w j If w i = w j , then we can interchange the labels of vertices v i and v j This makes T comply with the definition of optimality Suppose now that w i < w j Ittmann (UKZN PMB) Math236 2012 8 / 11

  9. Optimal trees Proof. Note that d ( r , v i ) < d ( r , v j ) implies that v j is in a level “below” the level of v i This means that in the course of the algorithm which built T , v j was added to a tree S when both v i and v j were isolated vertices Let S ′ be the subtree with root r ′ formed by combining S and v j Let S ′′ be the subtree with root r ′′ formed by combining S and v i Now the frequency associated with r ′ is greater than the frequency associated with r ′′ Ittmann (UKZN PMB) Math236 2012 9 / 11

  10. Optimal trees Proof. This contradicts the rule used in construction of Huffman trees regarding the minimality of a root’s frequency Hence, the result follows Ittmann (UKZN PMB) Math236 2012 10 / 11

  11. Optimal trees We make the observation that some non-Huffman trees are optimal Consider the following trees: 3 T: H: 1 3 2 2 2 1 2 Now, L ( T ) = 16 and L ( H ) = 16 Both T and H are optimal, since H is a Huffman tree However, not every Huffman tree is optimal Ittmann (UKZN PMB) Math236 2012 11 / 11

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend