-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBacktrackingBST.java
More file actions
99 lines (76 loc) · 2.41 KB
/
Copy pathBacktrackingBST.java
File metadata and controls
99 lines (76 loc) · 2.41 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import java.util.NoSuchElementException;
public class BacktrackingBST implements Backtrack, ADTSet<BacktrackingBST.Node> {
private Stack stack;
private Stack redoStack;
private BacktrackingBST.Node root = null;
// Do not change the constructor's signature
public BacktrackingBST(Stack stack, Stack redoStack) {
this.stack = stack;
this.redoStack = redoStack;
}
public Node getRoot() {
if (root == null) {
throw new NoSuchElementException("empty tree has no root");
}
return root;
}
public Node search(int k) {
// TODO: implement your code here
return null; // temporal return command to prevent compilation error
}
public void insert(Node node) {
// TODO: implement your code here
}
public void delete(Node node) {
// TODO: implement your code here
}
public Node minimum() {
// TODO: implement your code here
return null; // temporal return command to prevent compilation error
}
public Node maximum() {
// TODO: implement your code here
return null; // temporal return command to prevent compilation error
}
public Node successor(Node node) {
// TODO: implement your code here
return null; // temporal return command to prevent compilation error
}
public Node predecessor(Node node) {
// TODO: implement your code here
return null; // temporal return command to prevent compilation error
}
@Override
public void backtrack() {
// TODO: implement your code here
}
@Override
public void retrack() {
// TODO: implement your code here
}
public void printPreOrder(){
// TODO: implement your code here
}
@Override
public void print() {
printPreOrder();
}
public static class Node {
// These fields are public for grading purposes. By coding conventions and best practice they should be private.
public BacktrackingBST.Node left;
public BacktrackingBST.Node right;
private BacktrackingBST.Node parent;
private int key;
private Object value;
public Node(int key, Object value) {
this.key = key;
this.value = value;
}
public int getKey() {
return key;
}
public Object getValue() {
return value;
}
}
}