In my program to implement huffman algorithm.I have created the huffman codes and stored the ascii values and corresponding codes in a map.While creating the encoded file I followed this approach:I firstly converted the ascii codes in to their corresponding integer values and wrote them in a file.Now ,while decoding I read each byte from that file and converted it into its binary equivalent and searched for their ascii values in the map.This approach is creating the following problem.Since,01,001,1 all have integer equivalent as 1,so when I convert the codes into integer it no longer remains unique.I have ran out of ideas. And I faled to store the actual huffman tree.So I could not follow the decoding scheme where I can traverse the tree a file the codes Help!:?:
ayanbizz
0
Newbie Poster
Recommended Answers
Jump to Post10001010 1100111 isn't 8 bytes, no matter how you count them.
I don't have time now to study your code with all those String manipulations, but the normal way to do bit-wize manipulations of the contents of an int is via boolean operations, eg// get the …
Jump to Post1 byte = 8 bits. I think you are taking the first 8 bits, not the first 8 bytes. Hence the confusion. Nevermind.
I'm still a little confused as to where Strings come into this. You are mapping a sequence of bits to an ASCII character. Assuming the sequence of …
All 6 Replies
ayanbizz
0
Newbie Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
ayanbizz
0
Newbie Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
ayanbizz
0
Newbie Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.