Hey,

I've gota make a program that reads characters from a text file, produces the Huffman code tree, and prints the codes for each character in the file. I've already written the code to read chars from a text file, but the Huffman code tree is the part I'm a little bit stuck with.

Is there anyone that could give me any clues on how to implement this please?

Thanks

Recommended Answers

All 10 Replies

Do you know the general idea of the algorithm? That comes first.

Hi everyone,

If i am not wrong this Huffman tree is something like a compression theory.

Anyways here is the full explanation

http://www.maths.abdn.ac.uk/~igc/tch/mx4002/notes/node59.html

Here is a sample huffman code tree program with some explanation and a complete program with source codes(click on the program hyperlink to download the jar)

http://www.huffmancoding.com/david/algorithm.html

Here is another link with huffman code sources(this one is an applet)

http://www.cis.ksu.edu/~howell/viewer/huffman.html

And here is one more but its a directory with huffman encoders and decoders

http://www.cs.duke.edu/csed/poop/huff/spring05/code/

I hope this has helped you

Yours Sincerly

Richard West

ps. Please look at the thread at the end of my signature

hello,

can somebody help me with this? actually last friday i discovered an algorithm based on huffman coding which yields a better result than the huffman coding itself. as far as i've read about this, it seems that the huffman coding is the most efficient or the optimum tree. by the way, i still need to prove my claim. ;p though i've tried it many times already with different character sequences, my algorithm is still better.

maybe somebody can help me develop the algorithm i discovered...

よろしくお願いいたします。

makkuaileron7777777

No, the huffman algorithm is the most efficient, since it assigns the most frequent characters the smallest sequences. And the algorithm already tells you what data structure you need to do to implement huffman coding. I haven't looked at it in awhile but I think its just a binary tree of 0's and 1's.

No, the huffman algorithm is the most efficient, since it assigns the most frequent characters the smallest sequences. And the algorithm already tells you what data structure you need to do to implement huffman coding. I haven't looked at it in awhile but I think its just a binary tree of 0's and 1's.

yah, i know that the huffman coding is the most efficient because i've read the theorems regarding the optimality of the algorithm. but i'm serious, i found an algorithm which yields a better result than the huffman coding. maybe i can say that the algorithm i discovered is an improved version of the huffman coding. i can prove this to you. i'm a mathematician that's why i love to solve problems like this... ;p and i need help to develop it because i'm a newbie in the field of IT. thanks... ;p

makkuaileron7777777

From the wiki

"Huffman was able to design the most efficient compression method of this type: no other mapping of individual source symbols to unique strings of bits will produce a smaller average output size when the actual symbol frequencies agree with those used to create the code"

I don't know what you mean by 'improved version' - there are already plenty of different versions out there, as far as I know, but it would only personally be of interest to me if you were disputing this claim. Anyway, if you need help writing the code, I'm happy to help, but be aware of the Daniweb rules, namely, we only give help to those who show effort (& we don't write code for people)

From the wiki

"Huffman was able to design the most efficient compression method of this type: no other mapping of individual source symbols to unique strings of bits will produce a smaller average output size when the actual symbol frequencies agree with those used to create the code"

I don't know what you mean by 'improved version' - there are already plenty of different versions out there, as far as I know, but it would only personally be of interest to me if you were disputing this claim. Anyway, if you need help writing the code, I'm happy to help, but be aware of the Daniweb rules, namely, we only give help to those who show effort (& we don't write code for people)

thanks... let me say i'm disputing the claim... will you help me? huffman coding uses the most efficient binary tree... but in my algorithm, it uses the same binary tree whose nodes consists of at pair of characters. it may look like a binary tree of arrays. that's it. if i have enough time today, i will send you all the information about my algorithm. i need critics, hopefully you can be the one...

i know the general idea behind the huffman coding.
can someone pls put the java program for huffman coding, PLS

this post died a year ago, and 5 years before that.

I started reading posts from Jul 28th, 2005. After putting some thought into things I am now annoyed that it was all pointless because I forgot to look at the dates.

Thanks

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.