Data Structures19 sections · 729 units
Open in Course

Problem - Dynamic Path Queries

Sum on changing paths

Given a forest, handle:

  • link u v: Add edge (forest property maintained)
  • cut u v: Remove edge
  • add u v x: Add x to all nodes on path u to v
  • query u v: Sum of values on path u to v

This extends connectivity with path aggregates. Link-Cut trees handle this naturally with lazy propagation for updates and subtree sums for queries.