Data Structures19 sections · 729 units
Open in Course

Lessons from Path Queries

summary

Core ideas:

1.1. HLD works because heavy chains create contiguous segments in a linear array

2.2. The O(logn)O(\log n) light-edge bound ensures we don't visit too many chains

3.3. Any path operation (max, sum, min, gcd) works if the segment tree supports it

4.4. Path updates (add vv to all nodes on path) need lazy propagation in the segment tree

HLD is the standard technique for tree path queries. Learn it well, you'll use it often.