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

Method main

java/Chapter 4/Question4_1/QuestionBrute.java:28–42  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

26 }
27
28 public static void main(String[] args) {
29 // Create balanced tree
30 int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
31 TreeNode root = TreeNode.createMinimalBST(array);
32 System.out.println("Root? " + root.data);
33 System.out.println("Is balanced? " + isBalanced(root));
34
35 // Could be balanced, actually, but it's very unlikely...
36 TreeNode unbalanced = new TreeNode(10);
37 for (int i = 0; i < 10; i++) {
38 unbalanced.insertInOrder(AssortedMethods.randomIntInRange(0, 100));
39 }
40 System.out.println("Root? " + unbalanced.data);
41 System.out.println("Is balanced? " + isBalanced(unbalanced));
42 }
43
44}

Callers

nothing calls this directly

Calls 4

createMinimalBSTMethod · 0.95
isBalancedMethod · 0.95
insertInOrderMethod · 0.95
randomIntInRangeMethod · 0.95

Tested by

no test coverage detected