(String[] args)
| 82 | } |
| 83 | |
| 84 | public static void main(String[] args) { |
| 85 | /* Simple test -- create one */ |
| 86 | int[] array = {Integer.MIN_VALUE, 3, 5, 6, 10, 13, 15, Integer.MAX_VALUE}; |
| 87 | TreeNode node = TreeNode.createMinimalBST(array); |
| 88 | //node.left.data = 6; // "ruin" the BST property by changing one of the elements |
| 89 | node.print(); |
| 90 | boolean isBst = checkBST(node); |
| 91 | System.out.println(isBst); |
| 92 | |
| 93 | /* More elaborate test -- creates 100 trees (some BST, some not) and compares the outputs of various methods. */ |
| 94 | /*for (int i = 0; i < 100; i++) { |
| 95 | TreeNode head = createTestTree(); |
| 96 | |
| 97 | // Compare results |
| 98 | boolean isBst1 = checkBST(head); |
| 99 | boolean isBst2 = checkBSTAlternate(head); |
| 100 | |
| 101 | if (isBst1 != isBst2) { |
| 102 | System.out.println("*********************** ERROR *******************"); |
| 103 | head.print(); |
| 104 | break; |
| 105 | } else { |
| 106 | System.out.println(isBst1 + " | " + isBst2); |
| 107 | head.print(); |
| 108 | } |
| 109 | }*/ |
| 110 | } |
| 111 | } |
nothing calls this directly
no test coverage detected