Sorting algorithms/Counting sort: Difference between revisions

→‎{{header|jq}}: space requirement is O(length)
(→‎{{header|jq}}: space requirement is O(length))
Line 889:
The task description points out the disadvantage of using an array
to hold the counts, so in the following implementation, a JSON
object is used instead. This ensures the space requirement is just O(length). In jq, this approach is both time and space
efficient, except for the small cost of converting integers to strings, which is necessary because JSON keys must be strings.
<lang jq>def countingSort(min; max):
2,489

edits