-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.java
54 lines (44 loc) · 925 Bytes
/
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
/*
This is a standard node class that contains its
parent and children as well as its height and balance
*/
public class Node<T> {
// declare instace variables
private Node<T> left;
private Node<T> right;
private Node<T> parent;
private T data;
// constructor
public Node(T d, Node<T> p) {
data = d;
parent = p;
}
// getting value of node
public T getData() {
return data;
}
// getting left child of node
public Node<T> getLeft() {
return left;
}
// getting right child of node
public Node<T> getRight() {
return right;
}
// getting parent of node
public Node<T> getParent() {
return parent;
}
// setting value of node
public void setData(T d) {
data = d;
}
// setting left child of node
public void setLeft(Node<T> l) {
left = l;
}
// setting right child of node
public void setRight(Node<T> r) {
right = r;
}
}