Concepts3
⚙️AlgorithmIntermediate
Small-to-Large Principle
Small-to-large means always merge the smaller container into the larger one to keep total work low.
#small-to-large#sack technique#dsu on tree+11
⚙️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
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