Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Quick sort algorithm. More...
#include <cstdlib>
#include <iostream>
Namespaces | |
namespace | sorting |
for working with vectors | |
Functions | |
int | sorting::partition (int arr[], int low, int high) |
void | sorting::quickSort (int arr[], int low, int high) |
void | show (int arr[], int size) |
int | main () |
Quick sort algorithm.
Implementation Details - Quick Sort is a divide and conquer algorithm. It picks and element as pivot and partition the given array around the picked pivot. There are many different versions of quickSort that pick pivot in different ways.
The key process in quickSort is partition(). Target of partition is, given an array and an element x(say) of array as pivot, put x at it's correct position in sorted array and put all smaller elements (samller than x) before x, and put all greater elements (greater than x) after x. All this should be done in linear time
int main | ( | void | ) |