Skip to main content

compute_huffman_codes

Function compute_huffman_codes 

Source
pub fn compute_huffman_codes(
    node: &HuffmanNode,
    prefix: Vec<u8>,
) -> Vec<(u8, Vec<u8>)>
Expand description

Traverses the Huffman tree depth-first, collecting (symbol, code_bits) pairs at each leaf.

prefix is the bit-path from the root to the current node (each u8 is 0 or 1).