You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Data Structures and Algorithms/Sorting Algorithms/README.md
+24
Original file line number
Diff line number
Diff line change
@@ -23,3 +23,27 @@ print("Original array:", arr)
23
23
writes = cycle_sort(arr)
24
24
print("Sorted array:", arr)
25
25
print("Number of writes performed:", writes)
26
+
```
27
+
# Pigeonhole Sort Algorithm
28
+
29
+
## Overview
30
+
Pigeonhole Sort is a sorting algorithm that works well for sorting lists where the range of values (i.e., the difference between the maximum and minimum values) is not significantly larger than the number of elements in the list. It is a non-comparison-based sorting algorithm.
31
+
32
+
The algorithm works by placing each element into its corresponding "pigeonhole" (a slot or bucket) and then iterating through the pigeonholes in order to reconstruct the sorted list.
33
+
34
+
## Complexity
35
+
-**Time Complexity**:
36
+
- The time complexity of Pigeonhole Sort is O(n + range), where n is the number of elements in the list and range is the difference between the maximum and minimum values.
37
+
38
+
- This makes it efficient for lists with a small range of values.
39
+
-**Space Complexity**: The space complexity is O(range), as it requires additional space for the holes list.
40
+
-**Limitations**: Pigeonhole Sort is not suitable for lists with a large range of values, as it would require a lot of memory for the holes list.
0 commit comments