Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0c97fe4

Browse files
authored
Added Counting Sort documentation. (#35)
Added Counting Sort documentation.
2 parents 199e54c + ba1fa84 commit 0c97fe4

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

‎docs/counting-sort.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,37 @@ title: Counting sort
44
sidebar_label: Counting sort
55
---
66

7-
[Open a pull request](https://github.com/AllAlgorithms/algorithms/tree/master/docs/counting-sort.md) to add the content for this algorithm.
7+
Counting sort is an algorithm for sorting a collection of objects according to keys that are small integers; that is, it is an integer sorting algorithm. It operates by counting the number of objects that have each distinct key value, and using arithmetic on those counts to determine the positions of each key value in the output sequence. Its running time is linear in the number of items and the difference between the maximum and minimum key values, so it is only suitable for direct use in situations where the variation in keys is not significantly greater than the number of items.
8+
9+
10+
## Performance
11+
12+
| Complexity | |
13+
| -------------------------- | ----------------------------------- |
14+
| Worst-case performance | O(n + k) |
15+
| Best-case performance | O(n + k) |
16+
| Average performance | O(n + k) |
17+
| Worst-case space complexity| O(n + k) |
18+
19+
Where n is the number of elements in input array and k is the range of input
20+
21+
![img](http://www-scf.usc.edu/~zhan468/public/Notes/resources/3C7DDB59DF2D21B287E42A7B908409CB.gif)
22+
23+
24+
# Implementations
25+
26+
| | Language | Link |
27+
|:-: | :-: | :-: |
28+
| <img src="https://cdn.abranhe.com/projects/algorithms/logos/python.svg" width="30px"> | Python | [counting_sort.py](https://github.com/AllAlgorithms/python/blob/master/sorting/counting_sort.py) |
29+
| <img src="https://cdn.abranhe.com/projects/algorithms/logos/cpp.svg" width="30px"> | C++ | [counting_sort.py](https://github.com/AllAlgorithms/cpp/blob/master/sorting/counting_sort.cpp) |
30+
31+
32+
33+
## Helpful Links
34+
35+
- [GeeksForGeeks](https://www.geeksforgeeks.org/counting-sort/)
36+
- [Wikipedia](https://en.wikipedia.org/wiki/Counting_sort)
37+
38+
## Videos
39+
40+
- [Youtube](https://www.youtube.com/watch?v=7zuGmKfUt7s)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /