Data Structures19 sections · 729 units
Open in Course

Memory Analysis

How much space?

For persistent segment tree:

  • Initial tree: O(n)O(n) nodes
  • Each update: O(logn)O(\log n) new nodes
  • mm updates: O(n+mlogn)O(n + m \log n) total nodes

For persistent array (as balanced tree):

  • Same analysis: O(n+mlogn)O(n + m \log n)

For persistent Union-Find:

  • Uses persistent array internally
  • Same bounds apply

Comparison:

StructureSpace per updateTotal for mm updates
Full copyO(n)O(n)O(nm)O(nm)
Path copyingO(logn)O(\log n)O(n+mlogn)O(n + m \log n)

Path copying saves a factor of n/lognn / \log n for large mm.