TheAlgorithms/C++ 1.0.0
All the 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>
Go to the source code of this file.
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/
Definition in file quick_sort_iterative.cpp.
int main | ( | void | ) |
Main function.
Definition at line 128 of file quick_sort_iterative.cpp.
void tests | ( | ) |
Self-test implementations.
Definition at line 94 of file quick_sort_iterative.cpp.