Concepts2
⚙️AlgorithmAdvanced
DSU on Tree (Sack)
DSU on Tree (also called the Sack technique) answers many subtree queries in O(n \log n) by keeping data from the heavy child and temporarily re-adding light subtrees.
#dsu on tree#sack technique#subtree queries+12
⚙️AlgorithmIntermediate
DFS - Tree and Graph Properties
Depth-First Search (DFS) assigns each vertex a discovery time and a finish time that capture a neat nesting structure of recursion.
#dfs#timestamps#discovery time+11