-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBSTNode.java
More file actions
37 lines (30 loc) · 724 Bytes
/
Copy pathBSTNode.java
File metadata and controls
37 lines (30 loc) · 724 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
package proj5;
/**
* A node in a BinarySearchTree.
*
* @author Chris Fernandes, Kristina Striegnitz
* @version Fall 2022
*/
public class BSTNode<T>
{
public T key;
public BSTNode<T> llink;
public BSTNode<T> rlink;
public BSTNode(T data){
key=data;
llink=null;
rlink=null;
}
public String toString() {
return "" + key;
}
public boolean isLeaf() {
return this.llink == null && this.rlink == null;
}
public boolean hasRightChildOnly() {
return this.llink == null && this.rlink != null;
}
public boolean hasLeftChildOnly() {
return this.llink != null && this.rlink == null;
}
}