Huffman tree content does not explain here, please search yourself. The following gives the Java implementation of the Huffman tree construction process.
Node class:
1./** 2. * Binary tree Node 3. */4.public class node implements comparable {5.
6. private int value; 7.8.
Private Node leftchild; 9.10.
Private Node Rightchild; 11.12. public Node (int value) {13.
This.value = value;
14.} 15. public int GetValue () {17.
return value;
18.} 19. public void SetValue (int value) {21.
This.value = value;
22.} 23. Public Node Getleftchild () {25.
return leftchild;
26.} 27. public void Setleftchild (Node leftchild) {29.
This.leftchild = Leftchild;
30.} 31. Public Node Getrightchild () {33.
return rightchild;
34.} 35. public void Setrightchild (Node rightchild) {37.
This.rightchild = Rightchild;
38.} 39. Public String toString (int level) {41.
String indent = ""; for (int i = 0; I < level; i++) {43.
Indent + = "";
44.} 45. Return indent + value + "\ n" + 47.(Leftchild!= null leftchild.tostring (Level + 1): "") + 48.
(Rightchild!= null rightchild.tostring (Level + 1): "");
49.} 50. A. public int compareTo (Object o) {52.
node that = (node) o;
Double result = This.value-that.value; Return result > 0? 1:result = 0?
0:-1; .}