Copied huffman coding implementation from my old university assignment.