Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your HuffmanTree class should have the following functions, each implemented as

ID: 3546383 • Letter: Y

Question

Your HuffmanTree class should have the following functions, each implemented as a method or inner class:
  1. Read a text file, and count the number of occurrence of each character (including the special symbols and spaces). Use a HashMap to keep the count, that is, using each character as the key, and the number of occurrence of that character in the given file as the value. After the whole text file is processed, use an iterator to write the content of the HashMap into an output file, where each line has the "character, count" format.

  2. The Node of the HuffmanTree should contain a character (only used in the leaves) , an integer (the count),  and two references to its left and right child, respectively. The node should implement the Comparable interface, so that comparing two nodes means to compare their count values. The node class should have (at least) two constructors, for the creation of the external nodes (the leaves) and the internal nodes, respectively, with different signatures.

  3. The building process of a HuffmanTree is maintained using a PriorityQueue of Nodes. Initially, each entry in the HashMap is used to build a node, which is added into the PriorityQueue. Then, the two nodes with the smallest count values are removed from the PriorityQueue and used as children to build a nodes that is the root of a large subtree, with the sum of two count values as count. The new node is added into the PriorityQueue (as the root of a corresponding HuffmanTree). Repeat the above step until all the nodes are merged into a single one (as the root of a Huffman tree). Properly display the Huffman tree.

  4. Generating a Huffman code table according to the above Huffman tree, by giving each character a binary code that corresponds to the path from the root of the tree to the leaf corresponding to the character. Save the code table in a HashMap, and write it into a text file.

  5. Use the Huffman code table in HashMap to encode a given string by translating it into a binary string.

  6. Use the HuffmanTree to decode a binary string by translating it back into a character string.
I need specific code for this. Depending on the answer i'll provide more points. Up to 3,150 pts. I need specific code for this. Depending on the answer i'll provide more points. Up to 3,150 pts.

Explanation / Answer

Your HuffmanTree class should have the following functions, each implemented as

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote