MCPcopy Create free account
hub / github.com/careercup/ctci / main

Method main

java/Chapter 4/Question4_5/QuestionB.java:84–110  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

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}

Callers

nothing calls this directly

Calls 3

createMinimalBSTMethod · 0.95
printMethod · 0.95
checkBSTMethod · 0.95

Tested by

no test coverage detected