Counting sort initialization of the output array, each take time. Therefore, the time for the whole algorithm is the sum of the times for these steps, . Because it uses arrays of length and , the total space usage of the algorithm is also . For problem instances in which the maximum key value is significantly smaller than the number of items, counting sort can be highly space-efficient, as the only storage it uses other than its input and output arrays is the Count array which uses space . If each item to be sorted is itself an integer, and used as
Integer complexity this way was originally considered by . They asked for the largest number with a given complexity ; later, Selfridge showed that this number is For example, when , and the largest integer that can be expressed using ten ones is . Its expression is Thus, the complexity of an integer is at least . The complexity of is at most (approximately ): an expression of this length for can be found by applying Horner's method to the binary representation of . Almost all integers have a representation whose length is bounded by a logarithm with a smaller constant factor,