forked from adnanaziz/EPIJudge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BstFromSortedArray.java
37 lines (33 loc) · 1.21 KB
/
BstFromSortedArray.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
package epi;
import epi.test_framework.BinaryTreeUtils;
import epi.test_framework.EpiTest;
import epi.test_framework.GenericTest;
import epi.test_framework.TestFailure;
import epi.test_framework.TestUtils;
import epi.test_framework.TimedExecutor;
import java.util.List;
public class BstFromSortedArray {
public static BstNode<Integer>
buildMinHeightBSTFromSortedArray(List<Integer> A) {
// TODO - you fill in here.
return null;
}
@EpiTest(testDataFile = "bst_from_sorted_array.tsv")
public static int
buildMinHeightBSTFromSortedArrayWrapper(TimedExecutor executor,
List<Integer> A) throws Exception {
BstNode<Integer> result =
executor.run(() -> buildMinHeightBSTFromSortedArray(A));
List<Integer> inorder = BinaryTreeUtils.generateInorder(result);
TestUtils.assertAllValuesPresent(A, inorder);
BinaryTreeUtils.assertTreeIsBst(result);
return BinaryTreeUtils.binaryTreeHeight(result);
}
public static void main(String[] args) {
System.exit(
GenericTest
.runFromAnnotations(args, "BstFromSortedArray.java",
new Object() {}.getClass().getEnclosingClass())
.ordinal());
}
}