I am attempting to build a Huffman encoding package and need help with building the tree and then encoding a text file to a compressed state. Can anyone assist me please? Thanks in advance.
There are a several ways of coding a tree, depending on which version of Fortran you're using. Say you want to code a tree like this where each node can have two children
1) If you are using F77, there are no structures so use a 2D array. eg
Dynamic memory allocation has its own breed of problems. eg when assigning pointers, if you use = instead of => the compiler doesn't moan but the program doesn't work.
Use the Fortran 90 structure to start with. When you've got the algorithm working then you can try the Fortran 95 structure. Keep a count of how many nodes you have used and when you need a new one just increment the count.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.