Sample Output of Program: Welcome to Text/Huffman Code Conversion Choose below (Enter Numbers Only) 1. Text to Huffman Code 2. Huffman Code to Text 3. Exit 1 --Text to Huffman Code-- Enter a text: abc Huffman code: 01001100 Would you like to convert again? (Y/N) y Choose below (Enter Numbers Only) 1. Text to Huffman Code 2. Huffman Code to Text 3. Exit 2 --Huffman Code to Text- Enter a Huffman Code: 000100101 Text: hed Would you like to convert again? (Y/N) Y Choose below (Enter Numbers Only) 1. Text to Huffman Code 2. Huffman Code to Text 3. Exit 3 Process finished with exit code 0
This is the Java code that needs to be edited.
import java.util.*;
public class BTNode<T> {
private T element;
private BTNode<T> left;
private BTNode<T> right;
/**Constructs a binary tree node that stores the specified element. */
public BTNode(T element) {
this.element = element;
left = right = null;
}
/** Returns the element stored in this node. */
public T getElement() {
return element;
}
/** Sets the element stored in this node.*/
public void setElement (T element) {
this.element = element;
}
/** Returns the left subtree of this node.*/
public BTNode<T> getLeft() {
return left;
}
/** Sets the left child of this node. */
public void setLeft (BTNode<T> left) {
this.left = left;
}
/** Returns the right subtree of this node. */
public BTNode<T> getRight() {
return right;
}
/**Sets the right child of this node. */
public void setRight (BTNode<T> right) {
this.right = right;
}
//...
} // end of class
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images