forked from adnanaziz/EPIJudge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DescendantAndAncestorInBst.java
38 lines (35 loc) · 1.48 KB
/
DescendantAndAncestorInBst.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
package epi;
import epi.test_framework.BinaryTreeUtils;
import epi.test_framework.EpiTest;
import epi.test_framework.GenericTest;
import epi.test_framework.TimedExecutor;
public class DescendantAndAncestorInBst {
public static boolean
pairIncludesAncestorAndDescendantOfM(BstNode<Integer> possibleAncOrDesc0,
BstNode<Integer> possibleAncOrDesc1,
BstNode<Integer> middle) {
// TODO - you fill in here.
return true;
}
@EpiTest(testDataFile = "descendant_and_ancestor_in_bst.tsv")
public static boolean pairIncludesAncestorAndDescendantOfMWrapper(
TimedExecutor executor, BstNode<Integer> tree, int possibleAncOrDesc0,
int possibleAncOrDesc1, int middle) throws Exception {
final BstNode<Integer> candidate0 =
BinaryTreeUtils.mustFindNode(tree, possibleAncOrDesc0);
final BstNode<Integer> candidate1 =
BinaryTreeUtils.mustFindNode(tree, possibleAncOrDesc1);
final BstNode<Integer> middleNode =
BinaryTreeUtils.mustFindNode(tree, middle);
return executor.run(()
-> pairIncludesAncestorAndDescendantOfM(
candidate0, candidate1, middleNode));
}
public static void main(String[] args) {
System.exit(
GenericTest
.runFromAnnotations(args, "DescendantAndAncestorInBst.java",
new Object() {}.getClass().getEnclosingClass())
.ordinal());
}
}