Two sets A and B, whose elements fulfill a total order on operator ≤, can have a binary relation R ⊆ A × B represented by the k 2 -tree compact data structure, which greatly improves storage space. Currently, Count query is managed by either using Range query or to modify the structure to have aggregate information, implying additional time or space in order to perform the query. This article presents Compact Count, which exploits the k 2 -tree properties to reduce the paths to be scanned to count the numbers in a range r, thus ensuring an expected runtime of O(log k r log k n) and storage of O(log k r) with the k 2 -tree parameters n and k. Our algorithm was compared through a series of experiments that consider both synthetic data with different distributions and real data, with a solution based on the Range algorithm. Experimental results show that Compact Count is 250 to 1,000 times faster than Range on synthetic and real data, respectively, with a small additional storage cost, as expected by the theoretical analysis.
scite is a Brooklyn-based organization that helps researchers better discover and understand research articles through Smart Citations–citations that display the context of the citation and describe whether the article provides supporting or contrasting evidence. scite is used by students and researchers from around the world and is funded in part by the National Science Foundation and the National Institute on Drug Abuse of the National Institutes of Health.