RK DSA Studio

Lowest common ancestor

Find the deepest node that is an ancestor of both existing target nodes. In a BST, it is their first split point.

Remember: Together down; split means found.

Example: Root 20, children 10 and 30 → their LCA is 20.

Time: O(h), worst O(n). Auxiliary space: O(1) iterative search.

Complexities describe the underlying algorithm; tutorial snapshots and rendering can use additional resources.

The interactive workspace loads here when JavaScript is available. You can still browse the learning notes and links above without it.