Given a string S of distinct character size N and their corresponding frequency f[] i.e. character S[i[
Fantastic news! We've Found the answer you've been seeking!
Question:
Given a string S of distinct character size N and their corresponding frequency f[] i.e. character S[i[ has f[i] frequency.
Your task is to build a Huffman tree to print all the Huffman codes in preorder traversal of the tree.
S = "abcdef"
f[] = {5, 9, 12, 13, 16, 45}
Output:
0 100 101 1100 1101 111
Explanation:
Huffman codes will be:
f : 0
c : 100
d : 101
a : 1100
b : 1101
e : 111
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date: