Update index.md (#32427)

Explained the space and time complexity of counting sort
This commit is contained in:
Kaustubh J
2019-02-20 08:54:29 +05:30
committed by Randell Dawson
parent 6994353c99
commit 359a776425

View File

@ -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];