Huffman coding: Difference between revisions
Content added Content deleted
Walterpachl (talk | contribs) m (→{{header|REXX}}: use format instead of right to diagnose size poblems) |
Walterpachl (talk | contribs) m (→{{header|REXX}}: adjust output) |
||
Line 5,147: | Line 5,147: | ||
* show all lines representing node data |
* show all lines representing node data |
||
*--------------------------------------------------------------------*/ |
*--------------------------------------------------------------------*/ |
||
Say ' i pp id c f l r d' |
Say ' i pp id c f l r d' |
||
Do i=1 To m.0 |
Do i=1 To m.0 |
||
Say format(i,3) format(m.i.0o,4) format(m.i.0id,3), |
Say format(i,3) format(m.i.0o,4) format(m.i.0id,3), |
||
Line 5,266: | Line 5,266: | ||
<pre>We encode this string: |
<pre>We encode this string: |
||
this is an example for huffman encoding |
this is an example for huffman encoding |
||
i pp id c f l r d |
|||
1 1 1 20 0 0 0 1 |
|||
2 1 9 20 0 0 1 1 |
|||
3 1 11 21 0 0 0 1 |
|||
4 1 12 21 0 0 1 1 |
|||
5 1 15 22 0 0 0 1 |
|||
6 1 16 22 0 0 1 1 |
|||
7 1 17 23 0 0 0 1 |
|||
8 1 18 23 0 0 1 1 |
|||
9 1 19 24 0 0 0 1 |
|||
10 2 23 24 17 18 1 0 |
10 2 23 24 17 18 1 0 |
||
11 2 22 25 15 16 0 0 |
11 2 22 25 15 16 0 0 |
||
12 2 21 25 11 12 1 0 |
12 2 21 25 11 12 1 0 |
||
13 2 20 26 1 9 0 0 |
13 2 20 26 1 9 0 0 |
||
14 2 2 26 0 0 1 1 |
14 2 2 26 0 0 1 1 |
||
15 2 4 27 0 0 0 1 |
15 2 4 27 0 0 0 1 |
||
16 2 10 27 0 0 1 1 |
16 2 10 27 0 0 1 1 |
||
17 2 14 28 0 0 0 1 |
17 2 14 28 0 0 0 1 |
||
18 3 24 28 19 23 1 0 |
18 3 24 28 19 23 1 0 |
||
19 3 3 29 0 0 0 1 |
19 3 3 29 0 0 0 1 |
||
20 3 6 29 0 0 1 1 |
20 3 6 29 0 0 1 1 |
||
21 3 8 30 0 0 0 1 |
21 3 8 30 0 0 0 1 |
||
22 3 13 30 0 0 1 1 |
22 3 13 30 0 0 1 1 |
||
23 4 27 31 4 10 0 0 |
23 4 27 31 4 10 0 0 |
||
24 4 26 31 20 2 1 0 |
24 4 26 31 20 2 1 0 |
||
25 4 25 32 22 21 0 0 |
25 4 25 32 22 21 0 0 |
||
26 4 7 32 0 0 1 1 |
26 4 7 32 0 0 1 1 |
||
27 5 28 33 14 24 0 0 |
27 5 28 33 14 24 0 0 |
||
28 6 30 33 8 13 1 0 |
28 6 30 33 8 13 1 0 |
||
29 6 29 34 3 6 0 0 |
29 6 29 34 3 6 0 0 |
||
30 6 5 34 0 0 1 1 |
30 6 5 34 0 0 1 1 |
||
31 8 32 35 25 7 0 0 |
31 8 32 35 25 7 0 0 |
||
32 8 31 35 27 26 1 0 |
32 8 31 35 27 26 1 0 |
||
33 11 33 36 28 30 0 0 |
33 11 33 36 28 30 0 0 |
||
34 12 34 36 29 5 1 0 |
34 12 34 36 29 5 1 0 |
||
35 16 35 37 32 31 0 0 |
35 16 35 37 32 31 0 0 |
||
36 23 36 37 33 34 1 0 |
36 23 36 37 33 34 1 0 |
||
37 39 37 0 35 36 0 0 |
37 39 37 0 35 36 0 0 |
||
--------------------- |
|||
char --> code |
char --> code |
||
--> 111 |
--> 111 |