|
Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Stooge sort implementation in C++ More...
#include <vector>#include <cassert>#include <algorithm>#include <iostream>Functions | |
| void | stoogeSort (std::vector< int > *L, size_t i, size_t j) |
| for IO operations | |
| void | test1 () |
| Function to test sorting algorithm. | |
| void | test2 () |
| Function to test sorting algorithm, one element. | |
| void | test3 () |
| Function to test sorting algorithm, repeating elements. | |
| int | main () |
| Main function. | |
Stooge sort implementation in C++
Stooge sort is a recursive sorting algorithm. It divides the array into 3 parts and proceeds to:
| int main | ( | void | ) |
Main function.
| argc | commandline argument count (ignored) |
| argv | commandline array of arguments (ignored) |
| void stoogeSort | ( | std::vector< int > * | L, |
| size_t | i, | ||
| size_t | j ) |
for IO operations
for vector for assert for std::is_sorted
The stoogeSort() function is used for sorting the array.
| L | - vector of values (int) to be sorted in in place (ascending order) |
| i | - the first index of the array (0) |
| j | - the last index of the array (L.size() - 1) |
| void test1 | ( | ) |
Function to test sorting algorithm.
| void test2 | ( | ) |
Function to test sorting algorithm, one element.
| void test3 | ( | ) |
Function to test sorting algorithm, repeating elements.