You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -85,14 +85,14 @@ public static void main(String[] args) {
85
85
treeRoot.right.right = newTreeNode(9);
86
86
treeRoot.right.left.right = newTreeNode(7);
87
87
88
-
System.out.println("LCA of 0 and 7 is: " + findLCA(treeRoot, treeRoot.left.left.left, treeRoot.right.left.right).val);
89
-
System.out.println("LCA of 0 and 9 is: " + findLCA(treeRoot, treeRoot.left.left.left, treeRoot.right.right).val);
90
-
System.out.println("LCA of 0 and 1 is: " + findLCA(treeRoot, treeRoot.left.left.left, treeRoot.left.left).val);
91
-
System.out.println("LCA of 1 and 2 is: " + findLCA(treeRoot, treeRoot.left.left, treeRoot.right.left).val);
92
-
System.out.println("LCA of 1 and 7 is: " + findLCA(treeRoot, treeRoot.left.left, treeRoot.right.left.right).val);
93
-
System.out.println("LCA of 4 and 7 is: " + findLCA(treeRoot, treeRoot, treeRoot.right.left.right).val);
94
-
System.out.println("LCA of 5 and 2 is: " + findLCA(treeRoot, treeRoot.left, treeRoot.right.left).val);
95
-
System.out.println("LCA of 7 and 9 is: " + findLCA(treeRoot, treeRoot.right.left.right, treeRoot.right.right).val);
96
-
System.out.println("LCA of 7 and 10 is: " + findLCA(treeRoot, treeRoot.right.left.right, newTreeNode(10)).val); // this use case does not work with the above algorithm
88
+
System.out.println("FCA of 0 and 7 is: " + findFCA(treeRoot, treeRoot.left.left.left, treeRoot.right.left.right).val);
89
+
System.out.println("FCA of 0 and 9 is: " + findFCA(treeRoot, treeRoot.left.left.left, treeRoot.right.right).val);
90
+
System.out.println("FCA of 0 and 1 is: " + findFCA(treeRoot, treeRoot.left.left.left, treeRoot.left.left).val);
91
+
System.out.println("FCA of 1 and 2 is: " + findFCA(treeRoot, treeRoot.left.left, treeRoot.right.left).val);
92
+
System.out.println("FCA of 1 and 7 is: " + findFCA(treeRoot, treeRoot.left.left, treeRoot.right.left.right).val);
93
+
System.out.println("FCA of 4 and 7 is: " + findFCA(treeRoot, treeRoot, treeRoot.right.left.right).val);
94
+
System.out.println("FCA of 5 and 2 is: " + findFCA(treeRoot, treeRoot.left, treeRoot.right.left).val);
95
+
System.out.println("FCA of 7 and 9 is: " + findFCA(treeRoot, treeRoot.right.left.right, treeRoot.right.right).val);
96
+
System.out.println("FCA of 7 and 10 is: " + findFCA(treeRoot, treeRoot.right.left.right, newTreeNode(10)).val); // this use case does not work with the above algorithm
0 commit comments