Skip to main content

optimal_code_lengths

Function optimal_code_lengths 

Source
pub fn optimal_code_lengths(freqs: &[u32], max_length: u8) -> Vec<(usize, u8)>
Expand description

Compute optimal code lengths for a set of symbol frequencies.

Uses the package-merge algorithm to compute length-limited Huffman codes. max_length limits the maximum code word length.

Returns a vector of (symbol_index, code_length) pairs for non-zero-frequency symbols.