Short answer: Square-root decomposition breaks an array into contiguous blocks of length about √n. Each block stores the sum of its cells. A point update changes one cell and one block sum. A range sum adds the complete blocks in the middle and walks the loose cells at each…
Category: Range Queries
How Mo’s algorithm orders offline range queries
Short answer: Mo’s algorithm answers a batch of range queries offline when a window can grow or shrink by one cell at a known cost. Sort the queries by the block of the left endpoint and, inside a block, by the right endpoint. Move the current window’s ends to…
