Write the algorithm of the quick sort, Data Structure & Algorithms


An algorithm for the quick sort is as follows:

void quicksort ( int a[ ], int lower, int upper )


int i ;

if ( upper > lower ) {

i = split ( a, lower, upper ) ; quicksort ( a, lower, i - 1 ) ; quicksort ( a, i + 1, upper ) ;                                }


int split ( int a[ ], int lower, int upper ){

int i, p, q, t ;

p = lower + 1 ;

q = upper ;

i = a[lower] ;

while ( q >= p )


while ( a[p] < i )

p++ ;

while ( a[q] > i )

q-- ;

if ( q > p )


t = a[p] ; a[p] = a[q] ; a[q] = t ;



t = a[lower] ; a[lower] = a[q] ; a[q] = t ;

return q ; }

Posted Date: 7/12/2012 8:33:20 AM | Location : United States

Related Discussions:- Write the algorithm of the quick sort, Assignment Help, Ask Question on Write the algorithm of the quick sort, Get Answer, Expert's Help, Write the algorithm of the quick sort Discussions

Write discussion on Write the algorithm of the quick sort
Your posts are moderated
Related Questions
The two pointers per number of a doubly linked list prepare programming quite easy. Singly linked lists as like the lean sisters of doubly linked lists. We need SItem to consider t

Let a be a well-formed formula. Let c be the number of binary logical operators in a. (Recall that ?, ?, ?, and ? are the binary logical operators). Let s be the number of proposit

Postorder traversal of a binary tree struct NODE { struct NODE *left; int value;     /* can take any data type */ struct NODE *right; }; postorder(struct NODE

ALGORITHM (Insertion of element into a linked list) Step 1 Begin the program Step 2 if the list is empty or any new element comes before the start (head) element, then add t

Q. Write  down a   programme  in  C  to  create  a  single  linked  list also  write the functions to do the following operations (i)  To insert a new node at the end (ii

Q.1 Write procedures/ Algorithm to insert and delete an element in to array. Q.2. Write an algorithm for binary search. What are the conditions under which sequential search of

A list item stores pointers and an element to predecessor and successor. We call a pointer to a list item a handle . This looks simple enough, but pointers are so powerful tha

Q. What do you understand by the term by hash clash? Explain in detail any one method to resolve the hash collisions.