-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node.java
66 lines (51 loc) · 1.3 KB
/
Node.java
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* Created by menna on 10/23/16.
*/
public class Node {
int nodeNum;
int counter;
char symbol;
Node parent;
String binarycode;
Node right;
Node left;
//methods:
// swap (exchange nodeNum only)
public Node(int num, int count, char s, Node p, String bcode) {
this.nodeNum = num;
this.counter = count;
this.symbol = s;
this.parent = p;
this.binarycode = bcode;
this.right = null; this.left = null;
}
public Node() {
this.nodeNum = 0;
this.counter = 0;
this.symbol = ' ';
this.parent = null;
this.right = null;
this.binarycode = " ";
this.right = null; this.left = null;
}
public Boolean swapConditions(Node x) {
if (this.nodeNum > x.nodeNum && this.counter <= x.counter && x.parent != this && !this.isRoot() && !x.isRoot())
return true;
else return false;
}
public void setLeft(Node l) {
this.left = l;
}
public void setRight(Node r) {
this.right = r;
}
public Boolean isRoot() {
return (this.parent == null);
}
public Boolean isLeft() {
return (this.parent.left == this);
}
public Boolean isRight() {
return (this.parent.right == this);
}
}