• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Anyone here have a huffman text encoding program?

cirthix

Diamond Member
I just wrote one and would like to see if it is giving the same number of bits requred for a given string. If you happen to have one, please put the same input string into your program to see if you get the same number of bits out. And yes, the string is spelled wrong.

The input string is:
WHENEVER ANY TEXT MESSAGE OF PRINTABLE ASCII CHARACTERS IS ENCODED BY THE HUFFMAN CODE PROCESS THEN THE TOTAL NUMBER OF BITS USED IS GARANTEED TO BE MINIMUM.
The bitstring is:
0011111011010001101001111110011110000010001100111100011001001010111100000001010011101110010010111010000001110110110001011111111010100011011000100110100011101000000100111001010101001010000001010101100100111100100010101100100111101110000101001110000100011001010011100101110001011000110100111100011001011010000010110001101101111011001001000110000010100111001011100000101111111100111001010100111011100001100101101000110000110010110100000110001110110001000011100000110001100010110101001111000001110110110001101010100110011100000011011101000101100010100111000010111001001111001000110110010010001011000110001110000110101000000010101000110101000010001100010101010
There were 1256 bits used by the input string and 655 bits used by the output string, which gives the compression ratio of 1.917557:1.
The data table is:
Character Frequency Next Binary Code
26 -1 000
. 1 -1 101010
A 10 -1 0100
B 5 -1 11010
C 6 -1 01010
D 5 -1 01011
E 20 -1 100
F 4 -1 11011
G 2 -1 101110
H 6 -1 10110
I 8 -1 10100
L 2 -1 001110
M 6 -1 0010
N 9 -1 0110
O 7 -1 01110
P 2 -1 101111
R 7 -1 11110
S 10 -1 1110
T 12 -1 1100
U 4 -1 00110
V 1 -1 11111
W 1 -1 001111
X 1 -1 101011
Y 2 -1 01111
 
Yeah sure, I got one here in my back pocket.

I usually only take it out when the ladies around, they can't get enough of the Huffman Algorithm
 
Originally posted by: jman19
I wrote one in college. I'm guessing Vshah did too in 15-211 😉

haha..amen

carnival is next week...sh!t is getting intense....


cirthix..i'm not home yet...but i haven't forgotten
 
Originally posted by: homercles337
I got 1256 input bits and 646 output bits. I win!

something's wrong with how i'm getting the codes, and i see where the bits are saved (take a look at the multiplicity of m and it's bit representation length against characters near it in frequency and you'll see the problem)

back to the code.. thanks for the helpful reply🙂

@ vshah, thanks, but homercles already answered it 🙂
 
Back
Top