Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Implementation of [Pigeonhole Sort algorithm] (https://en.wikipedia.org/wiki/Pigeonhole_sort) More...
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
Namespaces | |
namespace | sorting |
for working with vectors | |
Functions | |
template<std::size_t N> | |
std::array< int, N > | sorting::pigeonSort (std::array< int, N > arr) |
static void | test_1 () |
static void | test_2 () |
static void | test_3 () |
int | main () |
Implementation of [Pigeonhole Sort algorithm] (https://en.wikipedia.org/wiki/Pigeonhole_sort)
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)\).
int main | ( | void | ) |
|
static |
Test function 1 with unsorted array {8, 3, 2, 7, 4, 6, 8}
|
static |
Test function 2 with unsorted array {802, 630, 20, 745, 52, 300, 612, 932, 78, 187}
|
static |
Test function 1 with unsorted array {11,13,12,14}