Data Structures19 sections · 729 units
Open in Course

Full Persistence

Branching version history

Full persistence allows updates to any version, creating branches:

Version 0 (root)
    |
Version 1 (update from 0)
   / \
v2   v3 (both branch from 1)

Implementation is more complex:

  • Fat node method works naturally
  • Path copying requires careful version tracking
function update(version, index, value)
    oldRoot := roots[version]
    newRoot := pathCopyUpdate(oldRoot, index, value)
    newVersion := len(roots)
    roots.append(newRoot)
    return newVersion

Same implementation as partial persistence! The only difference is which version you pass to update.