Question: I am having trouble going through an 2D array that represents a huffman tree. My goal is to make the Huffman code out of the
I am having trouble going through an 2D array that represents a huffman tree. My goal is to make the Huffman code out of the users input. For example:
If the input were: 6 7 119 10 -1 -1 113 12 -1 -1 104 20 -1 -1 101 58 -1 -1 45 22 0 1 45 42 2 4 45 100 5 3 The corresponding output would be: h = 00 w = 010 q = 011 e = 1
The first line is the row of the root of the tree. So it would be row 6. the second number is the number of nodes(i understand that). then each row in the array represents each node in the tree. first column is ASCII value. second column is freq(not useful) and then third column is whether it has a left child(and if its anything other than -1 that number tells you what row to go to). same goes for the fourth column.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
