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

math236 discrete maths with applications
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Math236 Discrete Maths with Applications

  • P. Ittmann

UKZN, Pietermaritzburg

Semester 1, 2012

Ittmann (UKZN PMB) Math236 2012 1 / 11

slide-2
SLIDE 2

Weighted leaf paths

Definition Let T be a rooted tree with root vertex r Let v1, v2, . . . , vp be the leaf vertices of T Respectively, let w1, w2, . . . , wp be the weights of the leaf vertices The weighted leaf path length of T is L(T) =

p

  • i=1

wi · d(r, vi)

Ittmann (UKZN PMB) Math236 2012 2 / 11

slide-3
SLIDE 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

slide-4
SLIDE 4

Optimal trees

Theorem Let T be a rooted binary tree which is optimal Let vi and vj be leaf vertices of T such that wi < wj Then d(r, vj) ≤ d(r, vi)

Ittmann (UKZN PMB) Math236 2012 4 / 11

slide-5
SLIDE 5

Optimal trees

Theorem In an optimal tree, if v1, v2, . . . , vp are leaf vertices with weights w1 ≤ w2 ≤ · · · ≤ wp, then d(r, vp) ≤ d(r, vp−1) ≤ · · · ≤ d(r, v1)

Ittmann (UKZN PMB) Math236 2012 5 / 11

slide-6
SLIDE 6

Optimal trees

Theorem Every Huffman tree is optimal

Ittmann (UKZN PMB) Math236 2012 6 / 11

slide-7
SLIDE 7

Optimal trees

Proof. Suppose to the contrary that some Huffman tree T with root r is not

  • ptimal

Let v1, v2, . . . , vp be the leaf vertices of T with weights w1, w2, . . . , wp where the weights represent the frequencies of the associated character Let w1 ≤ w2 ≤ · · · ≤ wp Then there exists i < j such that d(r, vi) < d(r, vj)

Ittmann (UKZN PMB) Math236 2012 7 / 11

slide-8
SLIDE 8

Optimal trees

Proof. Note that i < j implies that wi ≤ wj If wi = wj, then we can interchange the labels of vertices vi and vj This makes T comply with the definition of optimality Suppose now that wi < wj

Ittmann (UKZN PMB) Math236 2012 8 / 11

slide-9
SLIDE 9

Optimal trees

Proof. Note that d(r, vi) < d(r, vj) implies that vj is in a level “below” the level of vi This means that in the course of the algorithm which built T, vj was added to a tree S when both vi and vj were isolated vertices Let S′ be the subtree with root r′ formed by combining S and vj Let S′′ be the subtree with root r′′ formed by combining S and vi Now the frequency associated with r′ is greater than the frequency associated with r′′

Ittmann (UKZN PMB) Math236 2012 9 / 11

slide-10
SLIDE 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

slide-11
SLIDE 11

Optimal trees

We make the observation that some non-Huffman trees are optimal Consider the following trees:

T: H: 1 3 2 2 3 2 2 1

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