Algorithm visualizer
Pick an algorithm, enter your own numbers or use a preset, then step through the run. The pseudocode and the explanation follow each step.
Store block sums so a prefix sum or a point change touches only about log n cells. Each index covers the block of values below its lowest set bit.
Add 1 at index 1 and then query 8. Which cells did the query add, and why those cells?
Step 1 of 29
Index 0 is unused. Build the tree by adding each value at its own index.