Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Quick Sort without recursion. This method uses the stack instead. Both recursive and iterative implementations have O(n log n) best case and O(n^2) worst case. More...
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <cassert>
Namespaces | |
namespace | sorting |
for working with vectors | |
Functions | |
int | sorting::partition (std::vector< int > &arr, int start, int end) |
The partition function sorts the array from start to end and uses the last element as the pivot. | |
void | sorting::iterativeQuickSort (std::vector< int > &arr) |
The main sorting function. | |
void | tests () |
Self-test implementations. | |
int | main () |
Main function. | |
Quick Sort without recursion. This method uses the stack instead. Both recursive and iterative implementations have O(n log n) best case and O(n^2) worst case.
https://stackoverflow.com/questions/12553238/quicksort-iterative-or-recursive https://en.wikipedia.org/wiki/Quicksort https://www.geeksforgeeks.org/iterative-quick-sort/
int main | ( | void | ) |
void tests | ( | ) |
Self-test implementations.