In
graph theory and
computer science, the
lowest common ancestor (
LCA) of two nodes and in a
tree or
directed acyclic graph (DAG) is the lowest (i.e. deepest) node that has both and as descendants, where we define each node to be a descendant of itself (so if has a direct connection from , is the lowest common ancestor).