SCHOOL OF CODE BUILDERS
Learn To CODE. Become A DEVELOPER.
Pages
HOME
DATA STRUCTURES
STRINGS
ARRAYS
MATRIX
BINARY TREES
LINKED LIST
STACK
QUEUE
SORTING
SEARCHING
C
PYTHON
PSEUDOCODE
CONTEST PROBLEMS
ALGORITHMS
PATTERNS
PHP
C PUZZLES
C INTERVIEW QUESTIONS
JAVA
C++
HASHING
RECURSION
BASIC C PROGRAMS
TCS-CODEVITA
FACEBOOK
CONTACT US
Quick sort - choosing last element as pivot element
Quick sort - choosing last element as pivot element
#include
#include
/* function to swap two elements in the array */ void swap(int *x,int *y) { int temp; temp=*x; *x=*y; *y=temp; } /* function partition which 1. Select the pivot element 2. sort the smaller elements to left of pivot 3. sort the larger elements to right of pivot 4. merge the left part, pivot, & right part */ int partition(int *a,int start,int end) { /* selecting the last element to be pivot element */ int pivot=a[end]; int pindex=start; int i; for(i=start;i
PREVIOUS
NEXT
HOME