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
Nearest integer function Nearest integer function In computer science, the nearest integer function of real number "x" denoted variously by formula_1, formula_2, formula_3, nint("x"), or Round("x"), is a function which returns the nearest integer to "x". To avoid ambiguity when operating on half-integers, a rounding rule must be chosen. On most computer implementations, the selected rule is to round half-integers to the nearest even integer—for example, This is in accordance with the IEEE 754 standards and helps reduce bias in the result. There are many other possible rules for tie breaking when rounding a half integer include rounding up, rounding down, rounding to