Skip to content

Implementation of Huffman Coding in C#. (Inspired by a conversation after a York Code Dojo exercise.)

Notifications You must be signed in to change notification settings

DavidBetteridge/HuffmanCoding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HuffmanCoding

Huffman Coding in C#

Example program output....

Original Text

Ha ha ha ha ha Yo, I'll tell you what I want, what I really, really want So tell me what you want, what you really, really want I'll tell you what I want, what I really, really want So tell me what you want, what you really, really want I wanna, (ha) I wanna, (ha) I wanna, (ha) I wanna, (ha) I wanna really, really, really wanna zigazig ah

If you want my future, forget my past If you wanna get with me, better make it fast Now don't go wasting my precious time Get your act together we could be just fine

I'll tell you what I want, what I really, really want So tell me what you want, what you really, really want I wanna, (ha) I wanna, (ha) I wanna, (ha) I wanna, (ha) I wanna really, really, really wanna zigazig ah If you wanna be my lover, you gotta get with my friends (Gotta get with my friends) Make it last forever, friendship never ends If you wanna be my lover, you have got to give Taking is too easy, but that's the way it is

Oh, what do you think about that Now you know how I feel Say, you can handle my love, are you for real (Are you for real) I won't be hasty, I'll give you a try If you really bug me then I'll say goodbye

Yo I'll tell you what I want, what I really, really want So tell me what you want, what you really, really want I wanna, (ha) I wanna, (ha) I wanna, (ha) I wanna, (ha) I wanna really, really, really wanna zigazig ah

Letters by Frequency

H occurs 1 times j occurs 1 times M occurs 1 times T occurs 1 times O occurs 1 times A occurs 1 times Y occurs 2 times N occurs 2 times G occurs 2 times p occurs 3 times c occurs 4 times S occurs 5 times k occurs 5 times z occurs 6 times v occurs 8 times ' occurs 9 times b occurs 9 times d occurs 9 times ( occurs 14 times ) occurs 14 times m occurs 16 times f occurs 16 times s occurs 16 times g occurs 20 times i occurs 26 times occurs 33 times

occurs 33 times u occurs 34 times I occurs 36 times , occurs 45 times r occurs 47 times h occurs 51 times o occurs 59 times w occurs 66 times y occurs 67 times n occurs 74 times t occurs 85 times e occurs 85 times l occurs 89 times a occurs 150 times occurs 249 times

Huffman Codes

is 100000

is 100001 w is 10001 y is 10010 u is 100110 v is 10011100 c is 100111010 S is 100111011 ' is 10011110 b is 10011111 n is 10100 I is 101010 d is 10101100 k is 101011010 z is 101011011 g is 1010111 a is 1011 t is 11000 e is 11001 l is 11010 , is 110110 r is 110111 h is 111000 i is 1110010 ( is 11100110 ) is 11100111 o is 111010 p is 1110110000 H is 111011000100 j is 111011000101 M is 111011000110 T is 111011000111 O is 111011001000 A is 111011001001 Y is 11101100101 N is 11101100110 G is 11101100111 m is 11101101 f is 11101110 s is 11101111 is 1111

Encoded Text

111011000100101111111110001011111111100010111111111000101111111110001011100000100001111011001011110101101101111101010100111101101011010111111000110011101011010111110010111010100110111110001111000101111000111110101011111000110111010011000110110111110001111000101111000111110101011111101111100110111101011010100101101101111110111110011011110101101010010111110001101110100110001000001000011001110111110101111110001100111010110101111111011011100111111000111100010111100011111001011101010011011111000110111010011000110110111110001111000101111000111110010111010100110111111011111001101111010110101001011011011111101111100110111101011010100101111100011011101001100010000010000110101010011110110101101011111100011001110101101011111001011101010011011111000111100010111100011111010101111100011011101001100011011011111000111100010111100011111010101111110111110011011110101101010010110110111111011111001101111010110101001011111000110111010011000100000100001100111011111010111111000110011101011010111111101101110011111100011110001011110001111100101110101001101111100011011101001100011011011111000111100010111100011111001011101010011011111101111100110111101011010100101101101111110111110011011110101101010010111110001101110100110001000001000011010101111100011011101001010010111101101111111001101110001011111001111111101010111110001101110100101001011110110111111100110111000101111100111111110101011111000110111010010100101111011011111110011011100010111110011111111010101111100011011101001010010111101101111111001101110001011111001111000001000011010101111100011011101001010010111111110111110011011110101101010010110110111111011111001101111010110101001011011011111101111100110111101011010100101111100011011101001010010111111101011011111001010101111011101011011111001010101111111101111100010000010000110000010000110101011101110111110010111010100110111110001101110100110001111111011011001011111110111010011011000100110110111110011101101111111011101110101101111010111110011100011111110110110010111111101100001011111011111100010000010000110101011101110111110010111010100110111110001101110100101001011111110101111100111000111110001111001011000111000111111101101110011101101111100111111100111000110001100111011111111110110110111010110101100111111110010110001111111011101011111011111100010000010000111101100110111010100011111101011001110101010010011110110001111101011111101011111000110111110111111000111001010100101011111111110110110010111111101100001101111100110011101011100101110101001101110111111111100011100101110110111001100000100001111011001111100111000111110010111010100110110111111110111001110101100011111100011101010101111100111000111000110011101111111100011100111111001110101110101001101101010101100111110011111110011111111011000101100110111011111100011111110111011100101010011001100000100001100000100001101010100111101101011010111111000110011101011010111110010111010100110111110001111000101111000111110101011111000110111010011000110110111110001111000101111000111110101011111101111100110111101011010100101101101111110111110011011110101101010010111110001101110100110001000001000011001110111110101111110001100111010110101111111011011100111111000111100010111100011111001011101010011011111000110111010011000110110111110001111000101111000111110010111010100110111111011111001101111010110101001011011011111101111100110111101011010100101111100011011101001100010000010000110101011111000110111010010100101111011011111110011011100010111110011111111010101111100011011101001010010111101101111111001101110001011111001111111101010111110001101110100101001011110110111111100110111000101111100111111110101011111000110111010010100101111011011111110011011100010111110011110000010000110101011111000110111010010100101111111101111100110111101011010100101101101111110111110011011110101101010010110110111111011111001101111010110101001011111000110111010010100101111111010110111110010101011110111010110111110010101011111111011111000100000100001101010111011101111100101110101001101111100011011101001010010111111100111111100111111110110110010111111010111010100111001100111011111011011111001011101010011011111010111111010110001100010111111101011111001110001111100011110010110001110001111111011011001011111110111011011111100101100110100101011001110111110000010000111100110111011001111110101100011000101111111010111110011100011111000111100101100011100011111110110110010111111101110110111111001011001101001010110011101111111001111000001000011110110001101011101011010110011111111001011000111111010101111101111110001111111011101110101101111100110011100110011101111101101111111011101101111110010110011010010101100111011111110001110010111011000011111010011001100111001100111011111111100110100101011001110111110000010000110101011101110111110010111010100110111110001101110100101001011111110011111110011111111011011001011111101011101010011100110011101111101101111100101110101001101111111000101110011100110011111101011111101011000111111000111010111110101111110010100111001100110000010000111101100011110111010110101110010101001010111111111100101110111111111100011101011101011111100110111110111110010110110111110011111100110110001111110001110001011110001001111011101111111111000111000110011111100011011100101111111001011000111111100101110111110000010000110000010000111101100100011100011011011111000111100010111100011111010110011101011111001011101010011011111100011100011100101010010101101011111011100111111110101001101100011111100011100010111100010000010000111101100110111010100011111100101110101001101111101011010101001110101000111111110001110101000111111010101111111011101100111001110101000001000011001110111011100101101101111100101110101001101111100111010101110100111111100010111010010101100110101100111111110110110010111111010111010100111001100111011011111011110111110011111100101110101001101111111011101110101101111111110111110011011110101000001000011110011011101100100111011111001111110010111010100110111111101110111010110111111111011111001101111010111001111000001000011010101111100011110101010010011110110001111100111111100111111110001011111011111100010010110110111110101010011110110101101011111010111111001010011100110011111100101110101001101111101111111100011011110010100000100001101010111011101111100101110101001101111110111110011011110101101010010111110011111100110101011111111110110111001111111000111000110011010011111010101001111011010110101111111011111011100101111101011111101011101010101100100111111001011001100000100001100000100001111011001011110101111101010100111101101011010111111000110011101011010111110010111010100110111110001111000101111000111110101011111000110111010011000110110111110001111000101111000111110101011111101111100110111101011010100101101101111110111110011011110101101010010111110001101110100110001000001000011001110111110101111110001100111010110101111111011011100111111000111100010111100011111001011101010011011111000110111010011000110110111110001111000101111000111110010111010100110111111011111001101111010110101001011011011111101111100110111101011010100101111100011011101001100010000010000110101011111000110111010010100101111011011111110011011100010111110011111111010101111100011011101001010010111101101111111001101110001011111001111111101010111110001101110100101001011110110111111100110111000101111100111111110101011111000110111010010100101111011011111110011011100010111110011110000010000110101011111000110111010010100101111111101111100110111101011010100101101101111110111110011011110101101010010110110111111011111001101111010110101001011111000110111010010100101111111010110111110010101011110111010110111110010101011111111011111000

Decoded Text

Ha ha ha ha ha Yo, I'll tell you what I want, what I really, really want So tell me what you want, what you really, really want I'll tell you what I want, what I really, really want So tell me what you want, what you really, really want I wanna, (ha) I wanna, (ha) I wanna, (ha) I wanna, (ha) I wanna really, really, really wanna zigazig ah

If you want my future, forget my past If you wanna get with me, better make it fast Now don't go wasting my precious time Get your act together we could be just fine

I'll tell you what I want, what I really, really want So tell me what you want, what you really, really want I wanna, (ha) I wanna, (ha) I wanna, (ha) I wanna, (ha) I wanna really, really, really wanna zigazig ah If you wanna be my lover, you gotta get with my friends (Gotta get with my friends) Make it last forever, friendship never ends If you wanna be my lover, you have got to give Taking is too easy, but that's the way it is

Oh, what do you think about that Now you know how I feel Say, you can handle my love, are you for real (Are you for real) I won't be hasty, I'll give you a try If you really bug me then I'll say goodbye

Yo I'll tell you what I want, what I really, really want So tell me what you want, what you really, really want I wanna, (ha) I wanna, (ha) I wanna, (ha) I wanna, (ha) I wanna really, really, really wanna zigazig ah

About

Implementation of Huffman Coding in C#. (Inspired by a conversation after a York Code Dojo exercise.)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages