-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
45 lines (38 loc) · 886 Bytes
/
Node.java
File metadata and controls
45 lines (38 loc) · 886 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
42
43
44
45
import java.io.*;
public class Node implements Serializable{
int key;
char val;
String code = "";
Node right;
Node left;
Node parent;
public Node(int k, char v){
key = k;
val = v;
}
public boolean hasChild(){
if((right != null) || (left != null))
return true;
else
return false;
}
public String toString(){
String s = "";
s += "parent = ";
if (parent == null)
s += "null ";
else
s += parent.key+" "+parent.val+" ";
s += "left = ";
if (left == null)
s += "null ";
else
s += left.key+" "+left.val+" ";
s += "right = ";
if (right == null)
s += "null ";
else
s += right.key+" "+right.val;
return s;
}
}