文摘
In this paper we deal with compressed integer arrays that are equipped with fast random access. Our treatment improves over an earlier approach that used address-calculation coding to locate the elements and supported access and search operations in O(lg(n+s))O(\lg (n+s)) time for a sequence of n non-negative integers summing up to s. The idea is to complement the address-calculation method with index structures that considerably decrease access times and also enable updates. For all our structures the memory usage is n lg(1 + s/n) + O(n)n \lg(1 + s/n) + O(n) bits. First a read-only version is introduced that supports rank-based accesses to elements and retrievals of prefix sums in O(lglg(n+s)O(\lg \lg (n+s)) time, as well as prefix-sum searches in O(lgn+ lglgs)O(\lg n+ \lg \lg s) time, using the word RAM as the model of computation. The second version of the data structure supports accesses in O(lglgU)O(\lg\lg U) time and changes of element values in O(lg2 U)O(\lg^2 U) time, where U is the universe size. Both versions performed quite well in practical experiments. A third extension to dynamic arrays is also described, supporting accesses and prefix-sum searches in O(lgn + lglgU)O(\lg n + \lg\lg U) time, and insertions and deletions in O(lg2 U)O(\lg^2 U) time.