Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!csd4.csd.uwm.edu!trantow From: trantow@csd4.csd.uwm.edu (Jerry J Trantow) Newsgroups: comp.sys.amiga.tech Subject: Re: huffman encoding Message-ID: <342@uwm.edu> Date: 4 Oct 89 22:55:20 GMT References: <476@crash.cts.com> Sender: news@uwm.edu Reply-To: trantow@csd4.csd.uwm.edu (Jerry J Trantow) Organization: University of Wisconsin-Milwaukee Lines: 18 In article <476@crash.cts.com> uzun@pnet01.cts.com (Roger Uzun) writes: >do. Do you have any suggestions on an algorithm for creating >a data structre that has the bit patterns/bit lengths for a given >file? >-Roger > Create a tree, with the normal Huffman order (lowest probabilities deepest) Have a field in the node to hold the code. Starting at the root, shift a 1 into the code of the left-child and a 0 into the code of the right child. Continue this until all the leaves have been assigned a code. If you want you can have a field with the bit length, but you can also keep track of the depth which == bit length. If you are implement this correctly every child node will have the code of it's parent shifted and a 1 added if the child is left and the parent's code shifted with a 0 if it is the right child. I hope this is what you wanted.