Huffman Tasks
Huffman Tasks
---
---
### **Tasks**
- Update the program to read input strings from a file instead of `stdin`.
- Ensure the Huffman tree is correctly built for any given input.
- Preorder traversal.
- Implement a function to encode the input string using the Huffman tree.
---
- Empty input.
- Add checks for invalid inputs (e.g., unsupported characters, invalid files).
- Free all dynamically allocated memory for the tree and heap.
---
- Implement a function to load the tree structure from a file for decoding.
- Encode the input text and save the binary output to a file.
- Implement decompression to read the binary file, decode it, and reconstruct the original text.
#### **12. Optimize for Performance**
---
### Deliverables
3. Documentation:
---
- **Error Handling**:
- **Memory Management**:
- Free dynamically allocated memory for tree nodes to avoid memory leaks.
- **Testing**:
- Use diverse test cases including empty strings, strings with repeated characters, and long inputs
to ensure robustness.
- **Optional Enhancements**:
- Support decoding from a file containing the encoded data and tree structure.
Would you like me to rewrite the code to include any of these enhancements?