The first common ancestor of the binary tree

If I have a binary search tree like this, then what would be the lowest common ancestor of nodes 6 and 1?

Binary search tree

+3
source share
1 answer

As defined by Wikipedia The lowest common ancestor I correct myself:

The lowest common ancestor (LCA) is a concept in graph theory and computer science. Let T be a rooted tree with n nodes. The lowest common ancestor is defined between two nodes v and w as the lowest node in T, which has both v and w as descendants ( where we allow node to be a descendant of itself ).

, , , 6. , .

+4

All Articles