Quick Sort : The Quick sort Algorithm is the most popular and widely used sorting algorithm developed by C.A.R Hoare in 1992. This algorithm tends be the quickest in the average case among all the sorting technique. It works on divide and conquer strategy. In divide and conquer policy the the problem is divided into smaller subproblems repeatedly until we reach the smaller size subproblems whose solution is easy to find. #include<iostream> using namespace std; template <class T> int partition(T a[], int start, int end) { T pivot = a[end]; int pindex = start; for(int i=start;i<end;i++) { if(a[i]<=pivot) { swap(a[i],a[pindex]); pindex++; } } swap(a[pindex],a[end]); return pindex; } template<class T> int quicksort(T a[], int start, int end) { if(start<end) { int pindex = partition(a,start,end); quicksort(a,start,pindex-1); quicksort(a,pindex+1,end); } } template <class T> void read(T a[], i...
A blog for Computer engineers C,C++, Data Structure, Java, JavaFx, HTML,CSS,JS,BootStrap,PHP,Mysql,node js and more..