Data Structures19 sections · 729 units
Open in Course

Problem - Subtree Queries

Euler tour application

Given a tree with nn nodes, each with a value. Process qq queries:

1.1. Update: change node uu's value to vv

2.2. Query: return the sum of values in uu n, q \leq 2 \cdot 10^5$. You've found the perfect Euler tour problem. Subtree becomes a range. Point update on node becomes point update on tour. Subtree sum becomes range sum.s subtree

Constraints: n,q2105n, q \leq 2 \cdot 10^5. You've found the perfect Euler tour problem. Subtree becomes a range. Point update on node becomes point update on tour. Subtree sum becomes range sum.