LowestCommonAncestorOfBSTree.js

@@ -1,32 +1,725 @@
-L
+// Given a binary search tree (BST), find the l
 owest
-C
+ c
 ommon
-A
+ a
 ncestor
-OfBSTree.js
+ (LCA) of two given nodes in the BST.%0A%0A// According to the definition of LCA on Wikipedia:%0A// %E2%80%9CThe lowest common ancestor is defined between two nodes v and w as the lowest node in T%0A// that has both v and w as descendants (where we allow a node to be a descendant of itself).%E2%80%9D%0A%0A//         _______6______%0A//        /              %5C%0A//     ___2__          ___8__%0A//    /      %5C        /      %5C%0A//    0      _4       7       9%0A//          /  %5C%0A//          3   5%0A// For example, the lowest common ancestor (LCA) of nodes 2 and 8 is 6.%0A// Another example is LCA of nodes 2 and 4 is 2, since a node can be a descendant of itself according to the LCA definition.
 %0A

add desc