-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmptyBST.java
63 lines (46 loc) · 1.09 KB
/
EmptyBST.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
package assn04;
import java.util.Queue;
public class EmptyBST<T extends Comparable<T>> implements BST<T> {
@Override
public BST<T> insert(T element) {
return new NonEmptyBST<T>(element);
}
@Override
public BST<T> remove(T element) {
return this;
}
@Override
public int getHeight() {
return -1;
}
@Override
public void printPreOrderTraversal() {
return;
}
@Override
public void printPostOrderTraversal() {
return;
}
@Override
public void printBreadthFirstTraversal() {
}
@Override
public BST<T> getLeft() {
throw new UnsupportedOperationException();
}
@Override
public BST<T> getRight() {
throw new UnsupportedOperationException();
}
@Override
public T getElement() {
throw new UnsupportedOperationException();
}
@Override
public boolean isEmpty() {
return true;
}
@Override
public void printBreadthFirstTraversal2(Queue<BST<T>> q) {
}
}