In-Place Binary Counters

We introduce a binary counter that supports increments and decrements in O(1) worst-case time per operation. (We assume that arithmetic operations on an index variable that is stored in one computer word can be performed in O(1) time each.) To represent any integer in the range from 0 to 2 n − 1, our counter uses an array of at most n bits plus few words of \(\lceil \lg (1 + n) \rceil\) bits each. Extended-regular and strictly-regular counters are known to also support increments and decrements in O(1) worst-case time per operation, but the implementation of these counters would require O(n) words of extra space, whereas our counter only needs O(1) words of extra space. Compared to other space-efficient counters, which rely on Gray codes, our counter utilizes codes with binary weights allowing for its usage in the construction of efficient data structures.

[1]  Amr Elmasry,et al.  Two-tier relaxed heaps , 2006, Acta Informatica.

[2]  Paz Carmi,et al.  Improved Methods For Generating Quasi-Gray Codes , 2010, SWAT.

[3]  Peter Brass Advanced Data Structures , 2008 .

[4]  J. Ian Munro,et al.  Integer Representation and Counting in the Bit Probe Model , 2007, ISAAC.

[5]  S. Srinivasa Rao,et al.  Integer representations towards efficient counting in the bit probe model , 2014, J. Discrete Algorithms.

[6]  Robert E. Tarjan,et al.  Relaxed heaps: an alternative to Fibonacci heaps with applications to parallel computation , 1988, CACM.

[7]  Bruno R. Preiss,et al.  Data Structures and Algorithms with Object-Oriented Design Patterns in Java , 1999 .

[8]  Haim Kaplan,et al.  Meldable heaps and boolean union-find , 2002, STOC '02.

[9]  Sankardeep Chakraborty,et al.  Advanced Data Structures , 2019 .

[10]  Amr Elmasry,et al.  Strictly-Regular Number System and Data Structures , 2010, SWAT.

[11]  Amr Elmasry,et al.  Multipartite priority queues , 2008, TALG.

[12]  Amr Elmasry,et al.  Worst-Case Optimal Priority Queues via Extended Regular Counters , 2011, CSR.

[13]  Jeffrey D. Ullman,et al.  A programming and problem solving seminar. , 1991 .

[14]  Donald E. Knuth,et al.  A Programming and Problem-Solving Seminar , 1981 .

[15]  Amr Elmasry,et al.  Two new methods for constructing double-ended priority queues from priority queues , 2008, Computing.

[16]  Haim Kaplan Algorithm Theory - SWAT 2010, 12th Scandinavian Symposium and Workshops on Algorithm Theory, Bergen, Norway, June 21-23, 2010. Proceedings , 2010, SWAT.

[17]  Juhani Karhumäki,et al.  Computer Science - Theory and Applications , 2014, Lecture Notes in Computer Science.

[18]  Torben Hagerup,et al.  Sorting and Searching on the Word RAM , 1998, STACS.

[19]  Jean Vuillemin,et al.  A data structure for manipulating priority queues , 1978, CACM.

[20]  Chris Okasaki,et al.  Purely functional data structures , 1998 .