graph/tree_utils library
Tree utilities (LCA, depth, subtree size) — roadmap #555.
Functions
-
lowestCommonAncestor(
List< int> parent, int u, int v) → int - Parent array: entry at index i is the parent of node i; root has -1. Audited: 2026-06-12 11:26 EDT
-
treeDepths(
List< int> parent) → List<int> -
Returns depth of each node (root = 0).
parentat index i is the parent of node i. Audited: 2026-06-12 11:26 EDT