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(log⁡n)O(\log n) new nodes
  • mm updates: O(n+mlog⁡n)O(n + m \log n) total nodes

For persistent array (as balanced tree):

  • Same analysis: O(n+mlog⁡n)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(log⁡n)O(\log n)O(n+mlog⁡n)O(n + m \log n)

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