Concepts3
⚙️AlgorithmIntermediate
Tree Isomorphism
Tree isomorphism asks whether two trees have exactly the same shape, ignoring vertex names.
#tree isomorphism#ahu algorithm#canonical form+12
⚙️AlgorithmIntermediate
Tree DP - Rerooting Technique
Rerooting (a.k.a. 换根 DP) computes a per-node answer as if each node were the root, in total O(n) time on trees.
#rerooting#tree dp#prefix suffix+11
⚙️AlgorithmIntermediate
Tree Distances and Diameter
Tree diameter is the longest simple path in a tree and can be found with two BFS/DFS runs.
#tree diameter#tree center#eccentricity+12