-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHNode.java
More file actions
41 lines (39 loc) · 823 Bytes
/
HNode.java
File metadata and controls
41 lines (39 loc) · 823 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
public class HNode{
String c;
int count;
HNode left, right, parent;
public HNode(){
c = "";
count = 0;
}
public HNode(int size){
c = "";
count = size;
}
public HNode(char aChar, int theCount) {
c = "" + aChar;
count = theCount;
}
public HNode(HNode left, HNode right) {
System.out.println(left.toString() + right.toString());
c = left.c + right.c;
count = left.count + right.count;
this.left = left;
left.parent = this;
this.right = right;
right.parent = this;
}
public void setLeaf(){
left = null;
right = null;
}
public String toString() {
return c + ":" + count;
}
public boolean isLeaf() {
return (left == null && right == null);
}
public boolean greaterThan(HNode node){
return this.count > node.count;
}
}