From 359a776425d61da15b6cdec88927883dab386549 Mon Sep 17 00:00:00 2001 From: Kaustubh J Date: Wed, 20 Feb 2019 08:54:29 +0530 Subject: [PATCH] Update index.md (#32427) Explained the space and time complexity of counting sort --- .../algorithms/sorting-algorithms/counting-sort/index.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/guide/english/algorithms/sorting-algorithms/counting-sort/index.md b/guide/english/algorithms/sorting-algorithms/counting-sort/index.md index e288383100..76d47cb169 100644 --- a/guide/english/algorithms/sorting-algorithms/counting-sort/index.md +++ b/guide/english/algorithms/sorting-algorithms/counting-sort/index.md @@ -29,6 +29,15 @@ the output sequence. next data 1 at an index 1 smaller than this index. ``` + +### Properties +- Space complexity: O(K) +- Best case performance: O(n+K) +- Average case performance: O(n+K) +- Worst case performance: O(n+K) +- Stable: Yes +(K is the number of distinct elements in the array) + ### Implementation in JavaScript ```js let numbers = [1, 4, 1, 2, 7, 5, 2];