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 triangle longest side is shorter than the sum of the other two sides. Each such triple defines an integer triangle that is unique up to congruence. So the number of integer triangles (up to congruence) with perimeter "p" is the number of partitions of "p" into three positive parts that satisfy the triangle inequality. This is the integer closest to when "p" is even and to when "p" is odd. It also means that the number of integer triangles with even numbered perimeters "p" = 2"n" is the same as the number of integer triangles with odd numbered perimeters "p" =