Data Structures19 sections · 729 units
Open in Course

Lessons from Cut and Paste

summary

Important lessons:

1.1. Implicit treaps turn array index into a computed property from subtree sizes

2.2. Any sequence rearrangement you can do with split and merge in O(log⁡n)O(\log n)

3.3. Lazy propagation works with treaps too (for range updates, reversals)

4.4. Random priorities give expected O(log⁡n)O(\log n) height without complex balancing

Treaps are the go-to structure for dynamic sequences. Simpler than splay trees, more flexible than segment trees.