A New Algorithm for Updating and Querying Sub-arrays of Multidimensional Arrays
Abstract
Given a -dimensional array , an update operation adds a given constant to each element within a continuous sub-array of . A query operation computes the sum of all the elements within a continuous sub-array of . The one-dimensional update and query handling problem has been studied intensively and is usually solved using segment trees with lazy propagation technique. In this paper, we present a new algorithm incorporating Binary Indexed Trees and Inclusion-Exclusion Principle to accomplish the same task. We extend the algorithm to update and query sub-matrices of matrices (two-dimensional array). Finally, we propose a general form of the algorithm for -dimensions which achieves time complexity for both updates and queries. This is an improvement over the previously known algorithms which utilize hierarchical data structures like quadtrees and octrees and have a worst-case time complexity of per update/query.
Keywords
Cite
@article{arxiv.1311.6093,
title = {A New Algorithm for Updating and Querying Sub-arrays of Multidimensional Arrays},
author = {Pushkar Mishra},
journal= {arXiv preprint arXiv:1311.6093},
year = {2016}
}
Comments
14 Pages, 3 Figures, 1 Table