advanced
Huffman Coding for Text
Implement Huffman coding algorithm to compress a string of text.
📝 提示内容
Write a C++ program that implements Huffman coding for lossless text compression. The program should take a string as input, calculate character frequencies, build the Huffman tree, generate binary codes, and output the encoded binary string and the compression ratio. Include a function to decode the binary string back to the original text using the tree structure.