-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNode.java
More file actions
26 lines (22 loc) · 487 Bytes
/
Node.java
File metadata and controls
26 lines (22 loc) · 487 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
单词查找树的节点实现
霍夫曼单词查找树
*/
private static class Node implements Comparable<Node>{
private char ch;
private int freq;
private final Node left;
private final Node right;
Node(char ch, int freq, Node left, Node right){
this.ch = ch;
this.freq = freq;
this.left = left;
this.right = right;
}
public boolean isLeaf(){
return left == null && right == null;
}
public int compareTo(Node that){
return this.freq - that.freq;
}
}