Iterative Postorder Traversal algorithm for Huffman Coding
807603Oct 19 2007 — edited Oct 19 2007Hello,
I am working on an implementation of Huffman encoding. Unfortunately, the book I have is written in C so I am having a tough time working things out in Java. After a bit of struggling, I have everything working using recursive postorder traversal. Now the last step would be to use iterative postorder traversal instead. Does anyone have the algorithm on hand? I basically take my huffman tree and walk it until I hit a leaf, inserting a zero into my encoding hash map every time i go left and a one every time I go right.
I would really appreciate the help. Recursive traversal is really easy to understand, but iterative gives me a headache.
my code is at http://www.jeah.net/~blanny/huffman.tar
Thank You,
Matthew