Data Structures19 sections · 729 units
Open in Course

The Fat Node Method

Alternative to path copying

Another persistence technique: store all versions of each field in the node itself.

class FatNode:
    versions: list of (timestamp, value)
    leftVersions: list of (timestamp, Node)
    rightVersions: list of (timestamp, Node)

    function getValue(time)
        // Binary search for latest version <= time
        return latest entry in versions with timestamp <= time

Pros:

  • Simpler for some structures
  • No tree shape required

Cons:

  • Access time includes binary search: O(logm)O(\log m) where mm is modifications to that node
  • Can be O(lognlogm)O(\log n \cdot \log m) total

Path copying is usually preferred for trees. Fat nodes work well for simpler structures.