July 2018
Beginner
202 pages
5h 4m
English
To gain more insight about greedy algorithms, let's look at another problem that is solvable by a greedy algorithm.
Huffman codes represent a way of compressing data effectively. Data is considered to be a sequence of characters. Huffman's greedy algorithm uses a table with the frequency of each character to build up an optimal way of representing each character as a binary string.
To illustrate this, imagine we have a 1,00,000 character data file that we wish to store in a compressed fashion. The frequency of each character in the data file is given by the following table:
| Character | a | b | c | d | e | f |
| Frequency | 45,000 | 13,000 | 12,000 | 16,000 | 9,000 | 5,000 |
There are various ...
Read now
Unlock full access