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

Method main

java/Chapter 4/Question4_8/Question.java:43–65  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

41 }
42
43 public static void main(String[] args) {
44 // t2 is a subtree of t1
45 int[] array1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
46 int[] array2 = {2, 4, 5, 8, 9, 10, 11};
47
48 TreeNode t1 = AssortedMethods.createTreeFromArray(array1);
49 TreeNode t2 = AssortedMethods.createTreeFromArray(array2);
50
51 if (containsTree(t1, t2))
52 System.out.println("t2 is a subtree of t1");
53 else
54 System.out.println("t2 is not a subtree of t1");
55
56 // t4 is not a subtree of t3
57 int[] array3 = {1, 2, 3};
58 TreeNode t3 = AssortedMethods.createTreeFromArray(array1);
59 TreeNode t4 = AssortedMethods.createTreeFromArray(array3);
60
61 if (containsTree(t3, t4))
62 System.out.println("t4 is a subtree of t3");
63 else
64 System.out.println("t4 is not a subtree of t3");
65 }
66
67}

Callers

nothing calls this directly

Calls 2

createTreeFromArrayMethod · 0.95
containsTreeMethod · 0.95

Tested by

no test coverage detected