-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreeUtils.java
More file actions
executable file
·44 lines (37 loc) · 1.28 KB
/
Copy pathTreeUtils.java
File metadata and controls
executable file
·44 lines (37 loc) · 1.28 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
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS info.picocli:picocli:4.5.0
import java.util.*;
import java.util.concurrent.Callable;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Parameters;
import static java.lang.System.*;
@Command(
name = "TreeUtils",
mixinStandardHelpOptions = true,
version = "TreeUtils 0.1",
description = "Intersting things with Trees")
class TreeUtils implements Callable<Integer> {
@Parameters(index = "0", arity = "0..*", description = "Initial set of values to load")
private List<String> inputStrings;
public static void main(String... args) {
int exitCode = new CommandLine(new TreeUtils()).execute(args);
exit(exitCode);
}
@Override
public Integer call() throws Exception {
if (inputStrings == null) {
inputStrings = List.of(
// Valid Binary Search Tree
"50 10,10 5,10 30,30 20,30 40,50 80,80 70,80 90,90 85",
// InValid Binary Search Tree (because of last node)
"50 10,10 5,10 30,30 20,30 40,50 80,80 70,80 90,10 75"
);
}
inputStrings.forEach( str -> {
Tree<Integer> myTree = new Tree<>(str);
out.println(str + " : Is Valid BST? " + myTree.isValidIntegerBST());
});
return 0;
}
}