Date post: | 15-Oct-2015 |
Category: |
Documents |
Upload: | oanh-lem-linh |
View: | 123 times |
Download: | 13 times |
of 79
5/26/2018 Adaptive Huffman
1/79
ADAPTIVE HUFFMAN
David A. Huffman
(9/8/19257/10/1999)
5/26/2018 Adaptive Huffman
2/79
Topic 9: Adaptive Huffman
Nhm thc hin:L Cao Tin 0612444
Nguyn Khc Tip 0612449
L Phc Trung 0612461
Lu c Tr 0612484
5/26/2018 Adaptive Huffman
3/79
Adaptive Huffman
Gii thiu: Hn ch ca thut ton Huffman tnh.
tng.
Lch s hnh thnh.
u im.
Thut ton tng qut.
Cy Huffman (ng).
Tnh cht anh em (Sibling property)
Hnh thnh v cp nht cy.
Cc vi phm v cch gii quyt
Thut ton nn (Encoding)
Thut ton gii nn (Decoding)
Demo minh ha.
5/26/2018 Adaptive Huffman
4/79
Adaptive Huffman - Gii thiu:
Gii thiu: Hn ch ca thut ton Huffman tnh. tng. Lch s hnh thnh. u im.
Thut ton tng qut. Cy Huffman (ng). Tnh cht anh em (Sibling property) Hnh thnh v cp nht cy. Cc vi phm v cch gii quyt
Thut ton nn (Encoding) Thut ton gii nn (Decoding) Demo minh ha.
5/26/2018 Adaptive Huffman
5/79
Adaptive Huffman - Gii thiu (tt):
Hn ch ca thut ton Huffman tnh. Trong qu trnh nn cn n 2 ln duyt File
Chi ph nn cao.
Cn phi lu tr thng tin gii nn
Lm tng kch thc d liu nn.
D liu nn cn phi c sn
Khng nn c d liu pht sinh theo thigian thc.
5/26/2018 Adaptive Huffman
6/79
Adaptive Huffman - Gii thiu (tt):
tng: Thut ton ny vn da trn tng ca Huffman l
s dng mt vi bit (bit code) biu din mt k t.
di m bit cho cc k t khng ging nhau:o K t xut hin nhiu lnbiu din bng m ngn.
o K t xut hin t biu din bng m di.
To sn mt cy ti thiu ban u, d liu nn sc cp nht dn vo cy.
5/26/2018 Adaptive Huffman
7/79
Gii thiu (tt):
Lch s hnh thnh: c xut (c lp) bi Faller (1973) v
Gallager (1978)
Nm 1985 Knuth a ra mt s ci tin v honchnh thut ton. V vy thut ton ny cn cgi l thut ton FGK.
Nm 1987 Vitter trnh by cc ci tin lin quan tivic ti u cy Huffman.
5/26/2018 Adaptive Huffman
8/79
Gii thiu (tt):
u im: Khng cn tnh trc s ln xut hin ca cc k t.
Qu trnh nn ch cn mt ln duyt file.
Khng cn lu thng tin phc v cho vic gii nn.
Nn online trn d liu pht sinh theo thi gian thc.
5/26/2018 Adaptive Huffman
9/79
Adaptive Huffman
Gii thiu: Hn ch ca thut ton Huffman tnh. tng. Lch s hnh thnh.
u im. Thut ton tng qut. Cy Huffman (ng). Tnh cht anh em (Sibling property)
Hnh thnh v cp nht cy. Cc vi phm v cch gii quyt
Thut ton nn (Encoding) Thut ton gii nn (Decoding)
5/26/2018 Adaptive Huffman
10/79
Adaptive Huffman - Thut ton tng qut:
Static Huffman:
o Cy Huffman c to thnh t bng thng k sln xut hin ca cc k t.
Adaptive Huffman:
o Nn online khng c trc bn thng k.
o Phng php: khi to cy ti thiu ban u,
cy s c cp nht dn dn da trn d liu phtsinh trong qu trnh nn hoc gii nn.
5/26/2018 Adaptive Huffman
11/79
Adaptive Huffman - Thut ton tng qut:
D liupht sinh
Cy
Huffman
D liunn/gii
nn
Khi to cyti thiu
Cp nht cy
Nn/ gii nn
S phi hp gia vic dng cy (cho thut ton nn/gii nn) v cp nht cy
5/26/2018 Adaptive Huffman
12/79
Adaptive Huffman - Thut ton tng qut:
Cp nht
k t c vo cy
Cy
Huffman
D liunn
c k t c
M ha
(nn k t c)
c != EOF
Khi to cy tithiu
Kt thc
Yes
No
Thut ton nn
5/26/2018 Adaptive Huffman
13/79
Adaptive Huffman - Thut ton tng qut:
Cy
Huffman
D liugii nn
c
c d liu nnb
Cp nht
k t c vo cy
Gii nn bthnh c
b != EOF
Khi to cyti thiu
Kt thc
Yes
No
Thut ton gii nn
5/26/2018 Adaptive Huffman
14/79
Adaptive Huffman
Gii thiu: Hn ch ca thut ton Huffman tnh. tng. Lch s hnh thnh. u im.
Thut ton tng qut. Cy Huffman (ng). Tnh cht anh em (Sibling property) Hnh thnh v cp nht cy. Cc vi phm v cch gii quyt
Thut ton nn (Encoding) Thut ton gii nn (Decoding) Demo minh ha.
5/26/2018 Adaptive Huffman
15/79
Adaptive Huffman - Cy Huffman (ng):
Mt cy nh phn c n node l c gi l cyHuffman nu tha: Cc node l c trng s wi0, i [1,n] Cc node nhnh c trng s bng tng trng s
ca cc node con ca n. Tnh cht Anh/ em (Sibling Property):o Mi node, ngoi tr node gc u tn ti mt
node Anh/ em (c cng node cha).
o Khi sp xp cc node trong cy theo th ttng dn ca trng s th mi node lun k vinode anh em ca n.
5/26/2018 Adaptive Huffman
16/79
Adaptive Huffman - Cy Huffman (ng):
V d:
W=3
#5
D
W=2
#4
C
W=2
#3
B
W=2
#2
A
W=1
#1
W=4
#6
W=7
#7
E
W=10
#8
RootW=17
#9
Th t #1 #2 #3 #4 #5 #6 #7 #8 #9
Wi 1 2 2 2 3 6 7 10 17
Gi tr A B C D E Root
5/26/2018 Adaptive Huffman
17/79
Adaptive Huffman - Cy Huffman (ng):
Cch thc to cy:b1: Khi to cy ti thiu, ch c node Escape (node 0)
b2: Cp nht tng k t vo trong cy theo qui tc:
Nu k t cha c trong cythm mi node l
Nu k t c trong cytng trng s node ln 1
Cp nht trng s ca cc node lin quan trong cy
Escap
eW = 0
5/26/2018 Adaptive Huffman
18/79
Adaptive Huffman - Cy Huffman (ng):
Thut ton cp nht trng s:
Tng trng s ca node l ln 1.
i t node l n node gc tng trng s cacc node ln 1. Kim tra tnh cht anh em vhiu chnh li cy nu c vi phm.
5/26/2018 Adaptive Huffman
19/79
Adaptive Huffman - Cy Huffman (ng):
W=11
#9
B
W=11
#7
W=25
#10
W=14
#8
L
W=5
#4
W=9
#6
D
W=4
#3
W=5
#5
T
W=3
#2
C
W=2
#1
Tng trng s (1)
Tng trng s (cui)
Tng trng s (2)
Tng trng s (3)
C
W=3
#1
W=15
#8
W=6
#5
W=26
#10
5/26/2018 Adaptive Huffman
20/79
Adaptive Huffman - Cy Huffman (ng):
Khi thm mt node mi hoc tng trng s:
Vi phm tnh cht anh em.
Trn s.
5/26/2018 Adaptive Huffman
21/79
Adaptive Huffman - Cy Huffman (ng):
Vi phm tnh cht anh em:
B
W=17#8
W=29
#9
W=12
#7
L
W=3
#4
W=6
#6
D
W=3
#3
W=6
#5
T
W=3
#2
C
W=3
#1
Tng trng s (1) DW=4
#1
5/26/2018 Adaptive Huffman
22/79
Adaptive Huffman - Cy Huffman (ng):
Hiu chnh cy thatnh cht anh em:
B
W=17#8
W=29
#10
W=12
#8
L
W=3
#4
W=6
#6
D
W=3
#3
W=6
#5
T
W=3
#2
C
W=4
#1
W=6
#5
W=7
#6
W=13
#7
W=30
#9
#1 #4
5/26/2018 Adaptive Huffman
23/79
Adaptive Huffman - Cy Huffman (ng):
Thut ton xc nh node vi phm: Gi x l node hin hnh. So snh x vi cc node tip theo sau (theo th t t
tri sang phi, t di ln trn).
Nu tn ti y sao cho y.Weight < x.Weight th x lnode vi phm. Thut ton hiu chnh cy tha tnh cht anh em:
Gi x l node vi phm. Tm node y xa nht, c trng s cao nht tha
y.Weight < x.Weight
Hon i x v node y trn cy. Cp nht li cc node cha tng ng. Lp li b1 cho n khi khng cn node vi phm.
5/26/2018 Adaptive Huffman
24/79
Adaptive Huffman - Cy Huffman (ng):
Vn trn s:
Qu trnh cp nht cy lm tng trng s cc node.
Trng s node gc tng nhanh c th vt qu khnng lu tr ca kiu d liu.
oKiu int gi tr max = 215- 1
oKiu unsigned int gi tr max = 2161
oKiu long gi tr max = 231 - 1
5/26/2018 Adaptive Huffman
25/79
Adaptive Huffman - Cy Huffman (ng):
V d v trn s:
Node gc ang c gi tr
trng s ti a m kiu dliu c th biu din.
Hintngtrn s
sxuthinkhi ta
tngtrngsca
btk node l no
W=120
#7
L
W=35
#4
W=65
#6
D
W=30
#3
W=55
#5
T
W=30
#2
C
W=25
#1
B
W=135
#8
W=255
#9
5/26/2018 Adaptive Huffman
26/79
Adaptive Huffman - Cy Huffman (ng):
Thut ton x l trn s:
Khi cp nht trng s, kim ta trng s node gc.
Nu trng s node gc > MAX_VALUE:o Gim trng s cc node l trong cy (chia cho 2).
o Cp nht lai trng s cac node nhnh.
o Kim tra tnh cht anh em v hiu chnh li cy.
(Do php chia cho 2 lm mt phn d ca s nguyn)
5/26/2018 Adaptive Huffman
27/79
Adaptive Huffman - Cy Huffman (ng):
X l trn s: (tt)
W=120
#7
L
W=35
#4
W=65
#6
D
W=30
#3
W=55
#5
T
W=30
#2
C
W=25
#1
B
W=135#8
W=255
#9
W=12 W=15 W=15 W=17
W=27W=32
W=67
W=116
W=59
5/26/2018 Adaptive Huffman
28/79
Adaptive Huffman
Gii thiu: Hn ch ca thut ton Huffman tnh.
tng.
Lch s hnh thnh.
u im. Thut ton tng qut.
Cy Huffman (ng).
Tnh cht anh em (Sibling property)
Hnh thnh v cp nht cy.
Cc vi phm v cch gii quyt
Thut ton nn (Encoding)
Thut ton gii nn (Decoding)
Demo minh ha.
5/26/2018 Adaptive Huffman
29/79
Adaptive Huffman
Thut ton nn:
initialize_model();
while(c != EOF)
{
c = getchar(inputfile);
encode(c, outputfile);
update_model(c);}
5/26/2018 Adaptive Huffman
30/79
Adaptive Huffman
Thutton m ha k tc:
encode (c, outputfile)
Nuc chac trong cy
oDuytcy T tm m bit caEscape ghi lnoutputfile.
oGhi tip8 bit m ASCII cac ln outputfile.
oThm node c vo cy v cpnhtlicy.
Nuc c trong cy:
o Duytcy T tm m bit cac v ghi ln outputfile
o Tngtrngscanode c ln 1 v cpnhtlicy
5/26/2018 Adaptive Huffman
31/79
Adaptive Huffman
Gii thiu: Hn ch ca thut ton Huffman tnh.
tng.
Lch s hnh thnh.
u im. Thut ton tng qut.
Cy Huffman (ng).
Tnh cht anh em (Sibling property)
Hnh thnh v cp nht cy.
Cc vi phm v cch gii quyt
Thut ton nn (Encoding)
Thut ton gii nn (Decoding)
Demo minh ha.
5/26/2018 Adaptive Huffman
32/79
Adaptive Huffman
Thut ton gii nn:
inputfile: d liu dng nn
outputfile: d liu gii nn
initialize_model();
while((c = decode(inputfile)) != EOF)
{putchar(c, outputfile);
update_model(c);
}
5/26/2018 Adaptive Huffman
33/79
Adaptive Huffman
Thut ton gii m k t c:decode(inputfile)
b = getchar(inputfile);
Bt u t v tr hin ti trn inputfile.
Ly tng bit ca b, duyt trn cy (b==0: tri, b==1:phi).
o Nu i n node l x, return x.char
o Nu i n node Escape: c = ly 8 bit tip theo t inputfile
Thm c vo cy, cp nht li cy.
return c
5/26/2018 Adaptive Huffman
34/79
DEMO MINH HA
5/26/2018 Adaptive Huffman
35/79
Adaptive HuffmanV d
Gisc dliunhsau:
f = abacbdc
5/26/2018 Adaptive Huffman
36/79
Adaptive HuffmanV d (tt)
B1: Khi to cy v a k t a vo cy:a
a
W=1E#1
#3
#2
W = 1
input = 01100001
5/26/2018 Adaptive Huffman
37/79
Adaptive HuffmanV d (tt)
B2: Thm k t b vo trong cyb cha c trong cy
Ta thm b vo thnh node l
trn cy
input = 01100001
a
W=1E
W=1 #3
#2#1
0
0 01100010
5/26/2018 Adaptive Huffman
38/79
Adaptive HuffmanV d (tt)
b
a
W=1E
W=1 #3
#2#1
b
W=1
#3
#1 #2
W = 1
5/26/2018 Adaptive Huffman
39/79
Adaptive HuffmanV d (tt)
a
W=1
W=1
b
W=1
#3
#1 #2
W = 1
E
#4
#5
5/26/2018 Adaptive Huffman
40/79
Adaptive HuffmanV d (tt)
Cp nht trng s ca cc node c
lin quan
a
W=1
W=1
b
W=1
#3
#1 #2
W = 1
E
#4
#5W = 2
5/26/2018 Adaptive Huffman
41/79
Adaptive HuffmanV d (tt)a
B3: thm k t a vo cy.
a tn ti trong cy
Tng trng s ca node a thm 1
Cp nht li trng s cacc node lin quan
a
W=1
W=2
b
W=1
#3
#1 #2
W = 1
E
#4
#5
W=2
W = 3
input = 01100001001100010
1
1
5/26/2018 Adaptive Huffman
42/79
Adaptive HuffmanV d (tt)
B4: thm k t c vo cy.
c cha c trong cy
Ta thm c vo thnh node l
trn cy aW=2
W=3
b
W=1
#3
#1 #2
W = 1
E
#4
#5
input = 011000010011000101
0
0
00 01100010
5/26/2018 Adaptive Huffman
43/79
Adaptive HuffmanV d (tt)
c
aW=2
W=3
#4
#5
W=1
bW=1
E#1 #2
#3
c
W=1E#1 #2
#3 W = 1
5/26/2018 Adaptive Huffman
44/79
Adaptive HuffmanV d (tt)
a
W=2
W=3
#4
#5
W=1
b
W=1#2
#3W=1
c
W=1E#1 #2
#3
#4
#6#5
#7
5/26/2018 Adaptive Huffman
45/79
Adaptive HuffmanV d (tt)
Cp nht trng s ca cc node c
lin quan aW=2
W=3
#6
#7
W=1
b
W=1#4
#5
W=1
c
W=1E#1 #2
#3
W = 2
W = 4
5/26/2018 Adaptive Huffman
46/79
Adaptive HuffmanV d (tt)b
B5: thm k t b vo cy.
b tn ti trong cy
Tng trng s ca node b thm 1
Cp nht li trng s cacc node lin quan
a
W=2
W=4
#6
#7
W=2
b
W=1#4
#5
W=1
c
W=1E#1 #2
#3
W = 2
W = 3
input = 0110000100110001010001100010
0
1
01
5/26/2018 Adaptive Huffman
47/79
Adaptive HuffmanV d (tt)
Vi phm tnh cht anh em
Ta phi xoay li cyCp nht li trng s ca cc
Node lin quan.
a
W=2
W=4
#6
#7
#5
#4
W=3
b
W=2W=1
c
W=1E#1 #2
#3
W=5
5/26/2018 Adaptive Huffman
48/79
Adaptive HuffmanV d (tt)
B6: thm k t d vo cy.
d cha c trong cy
Ta thm d vo thnh node l
trn cy
W=3
W=5
#6
#7
a
W=2
b
W=2#4
#5
W=1
c
W=1E#1 #2
#3
input = 011000010011000101000110001001
1
0
0
10001100100
5/26/2018 Adaptive Huffman
49/79
Adaptive HuffmanV d (tt)d
d
W=1#1
#3
#2
W = 1
W=3
W=5
#6
#7
a
W=2
b
W=2#4
#5
c
W=1
W=1
E#1 #2
#3
E
5/26/2018 Adaptive Huffman
50/79
Adaptive HuffmanV d (tt)
W=1
d
W=1E#1 #2
#3
W=3
W=5
#6
#7
a
W=2
b
W=2#4
#5
cW=1
W=1
#2
#3
#4
#5 #6
#7#8
#9
5/26/2018 Adaptive Huffman
51/79
Adaptive HuffmanV d (tt)
W=1
d
W=1E#1 #2
#3
W=3
W=5
#8
#9
a
W=2
b
W=2#6
#7
cW=1
W=1
#4
#5
Cp nht li trng s ca ccnode c lin quan
W=4
W=6
W=2
5/26/2018 Adaptive Huffman
52/79
Adaptive HuffmanV d (tt)
W=1
d
W=1E#1 #2
#3
W=4
W=6
#8
#9
a
W=2
b
W=2#6
#7
W=2
#4
#5
B7: thm k t c vo cy.c tn ti trong cy
Tng trng s ca node c thm 1
c
cW=1W=2
input = 01100001001100010
1000110001001100
01100100
1
1
0
101
5/26/2018 Adaptive Huffman
53/79
Adaptive HuffmanV d (tt)
W=1
d
W=1E#1 #2
#3
W=4
W=6
#8
#9
a
W=2
b
W=2#6
#7
W=2
#4
#5
cW=2
Vi phm tnh cht anh emTa phi xoay li cy
Cp nht li trng s ca cc nodelin quan v hiu chnh li cy.
W=3
5/26/2018 Adaptive Huffman
54/79
Adaptive HuffmanV d (tt)
W=4
W=6
#8
#9
a
W=2
b
W=2#6
#7
#5
W=1
d
W=1E#1 #2
#3
W=3
#4c
W=2
5/26/2018 Adaptive Huffman
55/79
Adaptive HuffmanV d (tt)
W=4
W=6
#8
#9
a
W=2
b
W=2#6
#7
#5
W=1
d
W=1E#1 #2
#3
W=3
#4
c
W=2
Vi phm tnh cht anh emTa hiu chnh li cy
5/26/2018 Adaptive Huffman
56/79
Adaptive HuffmanV d (tt)
W=4
W=6
#8
#9
a
W=2
b
W=2#6
#7
#5W=1
dW=1E#1 #2
#3
W=3
#4c
W=2
kim tra trng s ca ccnode lin quan.
input = 01100001001100010100011000100110001100100101
5/26/2018 Adaptive Huffman
57/79
Adaptive Huffman
Gii nn
5/26/2018 Adaptive Huffman
58/79
Adaptive HuffmanV d (tt)
B1: c 8bit u tin t file input a
a
W=1E#1
#3
#2
W = 1
input = 01100001001100010100011000100110001100100101
a
output = a
5/26/2018 Adaptive Huffman
59/79
Adaptive HuffmanV d (tt)
B2: c bit tip theo, duyt cyCp nht k t b vo trong cy
Di chuyn u c n v tr tip theo
a
W=1E
W=1 #3
#2#1
input = 0110000100110001010001100010011000110010010
fseek
0
b
output = a b
5/26/2018 Adaptive Huffman
60/79
Adaptive HuffmanV d (tt)
b
a
W=1E
W=1 #3
#2#1
b
W=1
#3
#1 #2
W = 1
5/26/2018 Adaptive Huffman
61/79
Adaptive HuffmanV d (tt)
a
W=1
W=1
b
W=1
#3
#1 #2
W = 1
E
#4
#5
5/26/2018 Adaptive Huffman
62/79
Adaptive HuffmanV d (tt)
Cp nht trng s ca cc node c
lin quan
a
W=1
W=1
b
W=1
#3
#1 #2
W = 1
E
#4
#5W = 2
5/26/2018 Adaptive Huffman
63/79
Adaptive HuffmanV d (tt)
B3:c bit tip theo v duyt cy.Tng trng s ca node a thm 1
Cp nht li trng s ca
cc node lin quanDi chuyn u c n
v tr tip theo
a
W=1
W=2
b
W=1
#3
#1 #2
W = 1
E
#4
#5
W=2
W = 3
1
input = 0110000100110001010001100010011000110010010
fseekoutput = ab a
5/26/2018 Adaptive Huffman
64/79
Adaptive HuffmanV d (tt)
B4: c bit tip theo v duyt cy.
Ta thm c vo thnh node l
trn cy
Di chuyn u c nv tr tip theo
a
W=2
W=3
b
W=1
#3
#1 #2
W = 1
E
#4
#5
0
0
input = 0110000100110001010001100010011000110010010
fseek
c
output = aba c
5/26/2018 Adaptive Huffman
65/79
Adaptive HuffmanV d (tt)
c
aW=2
W=3
#4
#5
W=1
bW=1
E#1 #2
#3
c
W=1E#1 #2
#3 W = 1
5/26/2018 Adaptive Huffman
66/79
Adaptive HuffmanV d (tt)
a
W=2
W=3
#4
#5
W=1
b
W=1#2
#3W=1
c
W=1E#1 #2
#3
#4
#6#5
#7
5/26/2018 Adaptive Huffman
67/79
Adaptive HuffmanV d (tt)
Cp nht trng s ca cc node c
lin quan aW=2
W=3
#6
#7
W=1
b
W=1#4
#5
W=1
c
W=1E#1 #2
#3
W = 2
W = 4
5/26/2018 Adaptive Huffman
68/79
Adaptive HuffmanV d (tt)
B5: c bit tip theo v duyt cy..
Tng trng s ca node b thm 1
Cp nht li trng s ca
cc node lin quanDi chuyn u c n
v tr tip theo
a
W=2
W=4
#6
#7
W=2
b
W=1#4
#5
W=1
c
W=1E#1 #2
#3
W = 2
W = 3
0
1
input = 0110000100110001010001100010011000110010010
fseek
output = abac b
5/26/2018 Adaptive Huffman
69/79
Adaptive HuffmanV d (tt)
Vi phm tnh cht anh em
Ta phi xoay li cyCp nht li trng s ca cc
Node lin quan.
a
W=2
W=4
#6
#7
#5
#4
W=3
b
W=2W=1
c
W=1E#1 #2
#3
W=5
5/26/2018 Adaptive Huffman
70/79
Adaptive HuffmanV d (tt)
B6: c bit tip theo v duyt cy..
Ta thm d vo thnh node l
trn cy W=3
W=5
#6
#7
a
W=2
b
W=2#4
#5
W=1
c
W=1E#1 #2
#3
1
0
0
input = 0110000100110001010001100010011000110010010
fseek
d
Di chuyn u c nv tr tip theo
output = abacb d
5/26/2018 Adaptive Huffman
71/79
Adaptive HuffmanV d (tt)d
d
W=1#1
#3
#2
W = 1
W=3
W=5
#6
#7
a
W=2
b
W=2#4
#5
cW=1
W=1
E#1 #2
#3
E
5/26/2018 Adaptive Huffman
72/79
Adaptive HuffmanV d (tt)
W=1
d
W=1E#1 #2
#3
W=3
W=5
#6
#7
a
W=2
b
W=2#4
#5
c
W=1
W=1
#2
#3
#4
#5 #6
#7#8
#9
5/26/2018 Adaptive Huffman
73/79
Adaptive HuffmanV d (tt)
W=1
d
W=1E#1 #2
#3
W=3
W=5
#8
#9
a
W=2
b
W=2#6
#7
c
W=1
W=1
#4
#5
Cp nht li trng s ca ccnode c lin quan
W=4
W=6
W=2
5/26/2018 Adaptive Huffman
74/79
Adaptive HuffmanV d (tt)
W=1
d
W=1E#1 #2
#3
W=4
W=6
#8
#9
a
W=2
b
W=2#6
#7
W=2
#4
#5
B7: c bit tip theo v duyt cy...Tng trng s ca node c thm 1
c
W=1W=2
input = 01100001001100010
1000110001001100
01100100101
1
1
0
fseek
output = abacbd c
5/26/2018 Adaptive Huffman
75/79
Adaptive HuffmanV d (tt)
W=1
d
W=1E#1 #2
#3
W=4
W=6
#8
#9
a
W=2
b
W=2#6
#7
W=2
#4
#5
c
W=2
Vi phm tnh cht anh emTa phi xoay li cy
Cp nht li trng s ca cc nodelin quan v hiu chnh li cy.
W=3
5/26/2018 Adaptive Huffman
76/79
Adaptive HuffmanV d (tt)
W=4
W=6
#8
#9
a
W=2
b
W=2#6
#7
#5
W=1
d
W=1E#1 #2
#3
W=3
#4c
W=2
5/26/2018 Adaptive Huffman
77/79
Adaptive HuffmanV d (tt)
W=4
W=6
#8
#9
a
W=2
b
W=2#6
#7
#5
W=1
d
W=1E#1 #2
#3
W=3
#4c
W=2
Vi phm tnh cht anh emTa hiu chnh li cy
5/26/2018 Adaptive Huffman
78/79
Adaptive HuffmanV d (tt)
W=4
W=6
#8
#9
a
W=2
b
W=2#6
#7
#5W=1
dW=1E#1 #2
#3
W=3
#4c
W=2
kim tra trng s ca ccnode lin quan.
output = abacbdc
5/26/2018 Adaptive Huffman
79/79
Adaptive Huffman
Huffman
!!!???
Discussion
Oh! I see