Template Function ADS::limitedLengths

Function Documentation

template<class C, class F>
std::map<C, int> ADS::limitedLengths(const std::map<C, F> &freq, int L)

the lengths of a code of Huffman of no length above L, by halving the frequencies (rounding up) until the code of Huffman of the halved ones has no length above L

Pre:

freq not empty, the frequencies integers and positive, 1 <= L <= 63 and 2^L >= the number of symbols

Post:

no length above L