The scenario
A string is compressed using Huffman coding, which builds a frequency-based binary tree to assign shorter codes to more frequent characters.
What is in this drawing
Read the decisions behind it.
01
Calculate character frequencies from input string
02
Build priority queue and iteratively combine lowest-frequency nodes
03
Assign binary codes by tree traversal
Applicable for lossless text compression when character frequency distribution is skewed; used in many file formats.
More like this