A decimal counter stores a nonnegative integer using an array of base-ten digits, with the least significant digit first. Increment resets trailing nines and increases the next digit, or wraps modulo if all digits are nines. Starting at zero, the exact number of digit changes in increments is . This is an aggregate analysis proving a constant amortized cost per increment under unit-cost digit updates. An arbitrary initial value contributes an additional in Big O notation.
Articles by others on the same topic
There are currently no matching articles.