Pick an algorithm, enter your own numbers or use a preset, then step through the run. The pseudocode and the explanation follow each step.
Segment tree: range minimum
Each node stores the minimum of a range, and the root covers everything. A query combines a few nodes that exactly cover the range, and an update recomputes only the nodes above one leaf.
Try it yourself
Query the range [1, 2] after an update at index 1 to a small value. Which node's stored value changes first?
Step through the run
Step 1 of 29
Array528193
waiting
current
finished
Leaf [0, 0] stores a[0] = 5.
Labels under values name their role, such as lo, hi, mid, i, j, min, L and R. Faded items are already ruled out or already in place.