Implementation of Pigeonhole Sort algorithm
More...
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
Implementation of Pigeonhole Sort algorithm
- Author
- Lownish Pigeonhole sorting is a sorting algorithm that is suitable for sorting lists of elements where the number of elements and the number of possible key values are approximately the same. It requires O(n + Range) time where n is number of elements in input array and ‘Range’ is number of possible values in array.
The time Complexity of the algorithm is \(O(n+N)\).
◆ main()
◆ test_1()
Test function 1 with unsorted array {8, 3, 2, 7, 4, 6, 8}
- Returns
- none
72 test_array = sorting::pigeonSort<n>(test_array);
77 for (
int i = 0; i < n; i++) {
◆ test_2()
Test function 2 with unsorted array {802, 630, 20, 745, 52, 300, 612, 932, 78, 187}
- Returns
- none
91 300, 612, 932, 78, 187};
93 test_array = sorting::pigeonSort<n>(test_array);
98 for (
int i = 0; i < n; i++) {
◆ test_3()
Test function 1 with unsorted array {11,13,12,14}
- Returns
- none
113 test_array = sorting::pigeonSort<n>(test_array);
118 for (
int i = 0; i < n; i++) {