Other/Huffman Coding.cpp
// We use the sample string to calculate freqs and avg entropy
We use the sample string to calculate freqs and avg entropy
We use the sample string to calculate freqs and avg entropy
void freq_analysis(string sample)
{
    for(char &ch : sample)
    {
        freq[ch]++;
    }
    for(auto &x : freq)
    {
        freq[x.first] /= sample.size();
        H += x.second * log2(1 / x.second);
    }
}
void freq_analysis ( string sample ) { for ( char & ch : sample ) { freq [ ch ] ++ ; } for ( auto & x : freq ) { freq [ x . first ] /= sample . size ( ) ; H += x . second * log2 ( 1 / x . second ) ; } }
We use the sample string to calculate freqs and avg entropy
We use the sample string to calculate freqs and avg entropy