-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTreeNode.java
78 lines (69 loc) · 1.27 KB
/
TreeNode.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* Node class used for implementing the BST.
*
* DO NOT MODIFY THIS FILE!!
*
* @author CS 1332 TAs
* @version 1.0
*/
public class TreeNode<T extends Comparable<? super T>> {
private T data;
private TreeNode<T> left;
private TreeNode<T> right;
/**
* Constructs a TreeNode with the given data.
*
* @param data the data stored in the new node
*/
TreeNode(T data) {
this.data = data;
}
/**
* Gets the data.
*
* @return the data
*/
T getData() {
return data;
}
/**
* Gets the left child.
*
* @return the left child
*/
TreeNode<T> getLeft() {
return left;
}
/**
* Gets the right child.
*
* @return the right child
*/
TreeNode<T> getRight() {
return right;
}
/**
* Sets the data.
*
* @param data the new data
*/
void setData(T data) {
this.data = data;
}
/**
* Sets the left child.
*
* @param left the new left child
*/
void setLeft(TreeNode<T> left) {
this.left = left;
}
/**
* Sets the right child.
*
* @param right the new right child
*/
void setRight(TreeNode<T> right) {
this.right = right;
}
}