Skip to content

Commit 6c7e9de

Browse files
authored
Fix alignment
1 parent d9e36fa commit 6c7e9de

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Huffman Coding/README.markdown

+11-11
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ Although any type of objects can be encoded with this scheme, it is common to co
99
If you count how often each byte appears, you can see some bytes occur more than others:
1010

1111
space: 5 u: 1
12-
o: 5 h: 1
13-
s: 4 d: 1
14-
m: 3 a: 1
15-
w: 3 y: 1
16-
c: 2 p: 1
17-
r: 2 e: 1
18-
n: 2 i: 1
12+
o: 5 h: 1
13+
s: 4 d: 1
14+
m: 3 a: 1
15+
w: 3 y: 1
16+
c: 2 p: 1
17+
r: 2 e: 1
18+
n: 2 i: 1
1919

2020
We can assign bit strings to each of these bytes. The more common a byte is, the fewer bits we assign to it. We might get something like this:
2121

2222
space: 5 010 u: 1 11001
2323
o: 5 000 h: 1 10001
2424
s: 4 101 d: 1 11010
2525
m: 3 111 a: 1 11011
26-
w: 3 0010 y: 1 01111
27-
c: 2 0011 p: 1 11000
28-
r: 2 1001 e: 1 01110
29-
n: 2 0110 i: 1 10000
26+
w: 3 0010 y: 1 01111
27+
c: 2 0011 p: 1 11000
28+
r: 2 1001 e: 1 01110
29+
n: 2 0110 i: 1 10000
3030

3131
Now if we replace the original bytes with these bit strings, the compressed output becomes:
3232

0 commit comments

Comments
 (0)