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 square root which makes a general multiplication step unnecessary. Integer square root In number theory, the integer square root (isqrt) of a positive integer "n" is the positive integer "m" which is the greatest integer less than or equal to the square root of "n", For example, formula_2 because formula_3 and formula_4. One way of calculating formula_5 and formula_6 is to use Newton's method to find a solution for the equation formula_7, giving the iterative formula The sequence formula_9 converges quadratically to formula_5 as formula_11. It can be proven that if formula_12 is chosen as the initial guess, one can stop as