Lowest common ancestor
From Wikipedia, the free encyclopedia
Let T be a rooted tree with n nodes. The lowest common ancestor (LCA) is defined between two nodes v and w as the lowest node in T that has both v and w as descendents (where we allow a node to be a descendent of itself).
The LCA of v and w in T is the shared ancestor of v and w that is located farthest from the root.