|
| template<typename T , size_t N> |
| std::array< T, N > | shuffle (std::array< T, N > arr) |
| |
| template<typename T , size_t N> |
| std::array< T, N > | randomized_bogosort (std::array< T, N > arr) |
| |
| template<typename T > |
| void | gnomeSort (T *arr, int size) |
| |
| template<typename T , size_t size> |
| std::array< T, size > | gnomeSort (std::array< T, size > arr) |
| |
| template<typename T > |
| void | insertionSort (T *arr, int n) |
| | Insertion Sort Function. More...
|
| |
| template<typename T > |
| void | insertionSort (std::vector< T > *arr) |
| |
| template<class Iterator > |
| void | merge (Iterator l, Iterator r, const Iterator e, char b[]) |
| | merges 2 sorted adjacent segments into a larger sorted segment More...
|
| |
| template<class Iterator > |
| void | non_recursive_merge_sort (const Iterator first, const Iterator last, const size_t n) |
| | bottom-up merge sort which sorts elements in a non-decreasing order More...
|
| |
| template<class Iterator > |
| void | non_recursive_merge_sort (const Iterator first, const size_t n) |
| | bottom-up merge sort which sorts elements in a non-decreasing order More...
|
| |
| template<class Iterator > |
| void | non_recursive_merge_sort (const Iterator first, const Iterator last) |
| | bottom-up merge sort which sorts elements in a non-decreasing order More...
|
| |
| template<std::size_t N> |
| std::array< int, N > | pigeonSort (std::array< int, N > arr) |
| |
| int | partition (int arr[], int low, int high) |
| |
| void | quickSort (int arr[], int low, int high) |
| |
| template<typename T > |
| void | quicksort (std::vector< T > *arr, int32_t low, int32_t high) |
| |
| template<typename T > |
| std::vector< T > | quicksort (std::vector< T > arr, int32_t low, int32_t high) |
| |
| template<typename T > |
| void | recursive_bubble_sort (std::vector< T > *nums, uint64_t n) |
| | This is an implementation of the recursive_bubble_sort. A vector is passed to the function which is then dereferenced, so that the changes are reflected in the original vector. It also accepts a second parameter of type int and name n, which is the size of the array. More...
|
| |
| template<typename T > |
| void | shell_sort (T *arr, size_t LEN) |
| |
| template<typename T , size_t N> |
| void | shell_sort (T(&arr)[N]) |
| |
| template<typename T > |
| void | shell_sort (std::vector< T > *arr) |
| |
Sorting algorithms.
for io operations
for std::is_sorted
Sorting Algorithms.
for std::vector
for assert for typedef datatype uint64_t for IO operations
Sorting algorithms
for std::is_sorted, std::swap for assert for io operations
Sorting algorithms
Sorting algorithms
header files for collection of functions for a macro called assert which can be used to verify assumptions for io operations
Sorting algorithms
for assert for IO operations for std::vector for std::array
Sorting algorithms
template<class Iterator >
| void sorting::non_recursive_merge_sort |
( |
const Iterator |
first, |
|
|
const Iterator |
last, |
|
|
const size_t |
n |
|
) |
| |
bottom-up merge sort which sorts elements in a non-decreasing order
sorts elements non-recursively by breaking them into small segments, merging adjacent segments into larger sorted segments, then increasing the sizes of segments by factors of 2 and repeating the same process. best-case = worst-case = O(n log(n))
- Parameters
-
| first | points to the first element |
| last | points to 1-step past the last element |
| n | the number of elements |
29 char* buffer =
new char[n *
sizeof(*first)];
33 for (
size_t length(1); length < n; length <<= 1) {
36 for (
size_t counter(n / (length << 1)); counter; --counter) {
37 Iterator
right(left + length),
end(right + length);
38 merge(left, right, end, buffer);
43 if ((n & ((length << 1) - 1)) > length)
44 merge(left, left + length, last, buffer);
void merge(int *arr, int l, int m, int r)
Definition: merge_sort.cpp:33
template<typename T >
| void sorting::recursive_bubble_sort |
( |
std::vector< T > * |
nums, |
|
|
uint64_t |
n |
|
) |
| |
This is an implementation of the recursive_bubble_sort. A vector is passed to the function which is then dereferenced, so that the changes are reflected in the original vector. It also accepts a second parameter of type int and name n, which is the size of the array.
- Template Parameters
-
| T | type of data variables in the array |
- Parameters
-
| nums | our array of elements. |
| n | size of the array |
< base case; when size of the array is 1
< iterating over the entire array
< if a larger number appears before the smaller one, swap them.
79 for (uint64_t i = 0; i < n - 1; i++) {
81 if ((*nums)[i] > (*nums)[i + 1]) {
void recursive_bubble_sort(std::vector< T > *nums, uint64_t n)
This is an implementation of the recursive_bubble_sort. A vector is passed to the function which is t...
Definition: recursive_bubble_sort.cpp:74