The page shows an animation about the quick sort algorithm.

You can click on the button Animation to play the process.

QuickSort uses a divide and conquer strategy to divide a list into two sub-lists. It is another typical application of divide-and-conquer in sorting algorithms. Ordering n items needs (nlogn) comparisons in the most cases.

Algorithm code:

int partion(int a[],int start,int end){
    int i=start,j=end;
    int temp=a[start];
    while(i<j){
        while(i<j && a[j]>=temp)  j--;
        a[i]=a[j];  // i are more 
        while(i<j && a[i]<=temp)  i++;
        a[j]=a[i]; // j are more
    }
    a[i]=temp;   // at end , i=j
    return i;
}
void Qsort(int a[],int start,int end){
    if(start<end){
        int d=partion(a,start,end);
        Qsort(a,start,d);
        Qsort(a,d+1,end);
    }
}

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Computer Number Terms
: You can use the tool to get different expressions of color, disk space and number.

X
A prohibited operation
0
Would love your thoughts, please comment.x
()
x