Huffman Tree and Huffman Code(Binary Tree)[Solution introduction: the fourth and fifth videos in 4.7] [Problem description] Given n characters with corresponding weights, output Huffman code of each character. The upper bound of n is 30. [Basic requirements and Example] Problem: Output Huffman code of each character. What you need to show in the terminal(the back part is outputted by you and the blue part is inputted by the user, i.e., teacher): Please input characters and weights: A:5 B:29 C:7 D:8 E:14 F:23 G:3 H:11 Huffman code is: A:0110B:10 C:1110 D:1111 E:110 F:00 G:0111 H:010
The programming language: C++
The requirements of reports:
1.The
2.The source code with necessary comments
3.Test case and results (show the screenshot of your terminal);
4.Summary
Huffman Tree and Huffman Code(Binary Tree)[Solution introduction: the
fourth and fifth videos in 4.7]
[Problem description]
Given n characters with corresponding weights, output Huffman code of each
character. The upper bound of n is 30.
[Basic requirements and Example]
Problem: Output Huffman code of each character.
What you need to show in the terminal(the back part is outputted by you
and the blue part is inputted by the user, i.e., teacher):
Please input characters and weights:
A:5
B:29
C:7
D:8
E:14
F:23
G:3
H:11
Huffman code is:
A:0110B:10
C:1110
D:1111
E:110
F:00
G:0111
H:010
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images