English

A New Algorithm for Updating and Querying Sub-arrays of Multidimensional Arrays

Data Structures and Algorithms 2016-08-05 v6

Abstract

Given a dd-dimensional array AA, an update operation adds a given constant CC to each element within a continuous sub-array of AA. A query operation computes the sum of all the elements within a continuous sub-array of AA. 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 dd-dimensions which achieves O(4dlogdn)\mathcal{O}(4^d*\log^{d}n) 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 Ω(nd1)\Omega(n^{d-1}) 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