Concepts5
⚙️AlgorithmIntermediate
Small-to-Large Merging
Small-to-large merging is a technique where you always merge the smaller container into the larger one to guarantee low total work.
#small-to-large merging#dsu on tree#sack technique+11
⚙️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 DP - Matching and Covering
Tree DP solves matching, vertex cover, and independent set on trees in linear time using small state transitions per node.
#tree dp#maximum matching#vertex cover+12
⚙️AlgorithmIntermediate
DP on Trees
DP on trees is a technique that computes answers for each node by combining results from its children using a post-order DFS.
#tree dp#post-order dfs#rerooting+12
⚙️AlgorithmAdvanced
Virtual Tree (Auxiliary Tree)
A Virtual Tree (Auxiliary Tree) compresses a large tree into a much smaller tree that contains only the k important nodes and the LCAs needed to keep them connected.
#virtual tree#auxiliary tree#lca+12