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

Assignment Help:

Write down the algorithm of quick sort.

An algorithm for quick sort:
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 ; }


Related Discussions:- Write down the algorithm of quick sort

Ruby implementation of the symbol abstract data type, Ruby implementation o...

Ruby implementation of the Symbol ADT Ruby implementation of the Symbol ADT, as mentioned, hinges on making Symbol class instances immutable that corresponds to the relative la

Creation of Heap, Q. Create a heap with the given list of keys: ...

Q. Create a heap with the given list of keys: 8, 20, 9, 4, 15, 10, 7, 22, 3, 12                                                  Ans: Creation

Develop a material requirements plan, The below figure illustrates the BOM ...

The below figure illustrates the BOM (Bill of Materials) for product A. The MPS (Material requirements Planning) start row in the master production schedule for product A calls for

Create a function to show data structure, Given a number that is represente...

Given a number that is represented in your data structure, you will need a function that prints it out in base 215 in such a way that its contents can be checked for correctness. Y

Double linked list, In a doubly linked list, also called as 2 way list, eac...

In a doubly linked list, also called as 2 way list, each node is divided into 3 parts. The first part is called previous pointer field. It contains the address of the preceding

Row major representation, Row Major Representation In memory the primar...

Row Major Representation In memory the primary method of representing two-dimensional array is the row major representation. Under this representation, the primary row of the a

Give the example of bubble sort algorithm, Give the example of bubble sort ...

Give the example of bubble sort algorithm For example List: - 7 4 5 3 1. 7 and 4 are compared 2. Since 4 3. The content of 7 is now stored in the variable which was h

Determine the importance of array, Determine the importance of array Ar...

Determine the importance of array Arrays are significant since they allow many values to be stored in a single data structure whereas providing very fast access to each value.

Random searching, write aprogram for random -search to implement if a[i]=x;...

write aprogram for random -search to implement if a[i]=x;then terminate other wise continue the search by picking new randon inex into a

Create algorithm for similarities between documents, Here is a diagram show...

Here is a diagram showing similarities between documents; this is an actual set of physics lab assignments from a large university. Each node (square) in the graph is a doc

5/10/2013 5:08:29 AM

Thanks for suggesting me this answer, appreciate your knowledge

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd