Lowest Common Ancestor

Domain: Algorithms

🎯 Motivation

In a tree, the LCA of two nodes is the deepest node that is an ancestor of both. Essential for tree queries and distance calculations.

📋 Concrete Example

In a family tree, the LCA of two cousins is their shared grandparent. In a file system, the LCA of two files is their deepest common parent folder.

🔗 Analogy

Two students tracing their family trees upward until they find a common ancestor. The first (deepest) shared ancestor is the LCA — like finding a shared grandparent rather than a shared great-great-grandparent.