In-Place Binary Counters Amr Elmasry 1,2 and Jyrki Katajainen 2 1 Department of Computer Engineering and Systems, Alexandria University Alexandria 21544, Egypt 2 Department of Computer Science, University of Copenhagen Universitetsparken 5, 2100 Copenhagen East, Denmark Abstract. 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 lg(1 + n)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 Introduction A numeral system provides a specification for how to represent integers. In a positional numeral system, a string d = d n-1 ,...,d 1 ,d 0 of digits is used to represent an integer, n being the length of the representation. As in the decimal system, d 0 denotes the least-significant digit, d n-1 the most-significant digit, and d n-1 = 0. If w i is the weight of d i , the string represents the decimal number value (d)= n-1 i=0 d i w i . (An empty string can be used to represent zero.) A numeral system comprises four components: 1. The digit set specifies the values that the digits can take. For example, in a redundant binary system the digit set is {0, 1, 2}. 2. The weight set specifies the weights that the digits represent when deter- mining the decimal value of the underlying integer. For example, a binary system uses the binary weights w i =2 i where i ∈{0, 1,...,n 1}. 3. The rule set specifies the rules that the representation of each integer must obey. For example, the regular system [3] is a redundant binary system where every two 2’s have at least one 0 in between. 4. The operation set specifies the operations that are to be supported. In this paper we only consider in details increment (increase the value by one) and decrement (decrease the value by one) operations. However, it is also relevant to support other arithmetic operations like additions and subtractions. c 2013 Springer-Verlag GmbH Berlin Heidelberg. This is the authors’ version of the work. The final publication is available at link.springer.com.