Huffman coding is a compression method which generates variable-length codes for data – the more frequent the data item, the shorter the code generated. This allows more efficient compression than fixed-length codes. This is an implementation of the algorithm in C. The function huffman() takes arrays of letters and their frequencies, the length of the arrays, and a callback which is called for each code generated. The algorithm requires a priority queue, and I used a min-heap for the purpose.
A dynamic array is one that grows to accommodate new items, overcoming the limitations of fixed-size arrays. New items can be added at the head or tail, or inserted in the middle. Existing elements are moved to accommodate new ones as necessary.