Skip to content

Persistent Treap Hot Sheet

Use this sheet when the statement keeps many list or sequence versions alive and the real edits are still split / merge sequence surgery.

Do Not Use When

Choose By Signal

Core Invariants

  • one version is one immutable treap root
  • implicit positions still come from subtree sizes
  • merge and split_prefix clone only the touched recursion path
  • untouched subtrees are shared safely between versions
  • subtree sum means the sum of exactly that version's represented sequence

Main Traps

  • mutating a shared node during split/merge
  • forgetting this first route is sequence/list persistence, not fixed-array persistence
  • assuming the starter already supports lazy reversal, affine tags, or key-based maps
  • mixing "first k elements" semantics with key-based split semantics

Exact Starter Route

Reopen Paths