Binary Search Tree : Lowest Common Ancestor

  • + 2 comments

    for example, for a tree: 4 2 3 1 7 6 8

    if you want to find the lowest common ancestor of 6 and 8, your code outputs 7, but the correct answer should be 4!

    • + 0 comments
                  4
               /    \
              2       7
            /   \    / \
          1       3  6  8
      

      This will be the tree, don't know what you did.

    • + 0 comments

      Correct answer should be 7, as tree has been presented by @latishk