Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please write the code to create a Huffman Encoding Tree, as discussed in class. The tree should encode strings of vowels, with the following weights
Please write the code to create a Huffman Encoding Tree, as discussed in class. The tree should encode strings of vowels, with the following weights for each vowel A:20, E:15, 1:5, 0:5, U:10 The final tree should end up SIMILAR TO this - the bit strings may differ slightly, though the nodes should end up in the same relative positions 58 A 20 35 E 15 10 20 U 10 10 0 5 1100 101 Your Huffman Tree should be in a tree structure, using nodes and pointers to children nodes. To construct the tree, follow the general algorithm in class: 1. Make a list of nodes out of the provided vowel weight table 2. Sort the list on their weights/probabilities 3. Until the list only has one element a. Pop the two smallest b. Turn them into a subtree with a new node c. Add the new root back into the list d. Sort the list Further, you must implement code to decode and encode strings using your Huffman tree. Please make an encode and a decode method
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started