Graph Theory37 sections · 1633 units
Open in Course

Update Operation

(Changing a node value)

To update node vv to value xx, follow these steps: Find the chain vv belongs to with c = chain[v]. Find the position in the chain with p = pos[v]. Update the segment tree at position pp to value xx. This takes O(logn)O(\log n) time per update, the same as a standard segment tree update.

The update propagates up the segment tree to maintain range maximums. Updates are fast because each node has a fixed position in the segment tree. You do not need to rebuild any structure.

Space complexity is O(n)O(n) for the data structures used.