Bug 1: Modifying shared nodes Never modify a node that might be shared.
Always create a new node. ```pseudocode // WRONG node.value := newValue
// RIGHT newNode := copy(node) newNode.value := newValue
After $k$ updates, latest is version $k$. **Bug 3: Forgetting to store roots** Each version needs its root stored.
Don't overwrite the roots array. **Bug 4: Null pointer in queries** Persistent trees can have null children (sparse). Handle in queries. Time: $O(n)$. Space: $O(n)$.