I am trying to generate inorder and preorder traversals of a Huffman Code Tree in python. I seem to have hit a wall though. I need to generate the traversals and write them to corresponding files, and then create a binary path to the locations of each node and output that to a file as well. Here is what I have so far
Here is a PDF file of a lecture given for a course at Harvard (easily found by simple google search.) It provides examples, explanations, pictures of trees, and code to do what you are asking to do. But the code is in Java. However, you should be able to translate these short programs to Python easily. Or just code Python directly from the explanations. It includes Huffman trees.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.