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
Gaussian integer to 3 modulo 4 (that is, it may be written , with a nonnegative integer) . The other prime numbers are not Gaussian primes, but each is the product of two conjugate Gaussian primes. A Gaussian integer is a Gaussian prime if and only if either: In other words, a Gaussian integer is a Gaussian prime if and only if either its norm is a prime number, or it is the product of a unit () and a prime number of the form . It follows that there are three cases for the factorization of a prime number in the