Unvisited
Current DFS
Target node (p or q)
Carries result up
LCA found

Controls

Time: O(n) | Post-order DFS

Steps

0 steps

Press Find LCA to trace the algorithm one step at a time.