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

Program for linear search, Program for Linear Search. Program: Linear S...

Program for Linear Search. Program: Linear Search /*Program for Linear Search*/ /*Header Files*/ #include #include /*Global Variables*/ int search; int

Define tree ?, A tree is a non-empty set one component of which is designat...

A tree is a non-empty set one component of which is designated the root of the tree while the remaining components are partitioned into non-empty groups each of which is a subtree

Program, What is a first-in-first-out data structure ? Write algorithms to...

What is a first-in-first-out data structure ? Write algorithms to perform the following operations on it – create, insertion, deletion, for testing overflow and empty conditions.

Define about the inheritance hierarchy, Define about the inheritance hierar...

Define about the inheritance hierarchy Languages Eiffel and D provide constructs in language for invariants and pre- and post conditions which are compiled into the code and ar

Explain the term - branching, Explain the term - Branching There are t...

Explain the term - Branching There are two common ways of branching: case of ..... otherwise ...... endcase  if ..... then ..... else ..... endif   case of

Write an algorithm of value in tax using pseudocode, A town contains a tota...

A town contains a total of 5000 houses. Every house owner has to pay tax based on value of the house. Houses over $200 000 pay 2% of their value in tax, houses over $100 000 pay 1.

State in detail about the integer, State in detail about the Integer ...

State in detail about the Integer Carrier set of the Integer ADT is the set {..., -2, -1, 0, 1, 2, ...}, and  operations on these values are addition, multiplication, subtrac

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

Define graph, A graph is a mathematical structure giving of a set of vertex...

A graph is a mathematical structure giving of a set of vertexes (v1, v2, v3) and a group of edges (e1, e2, e3). An edge is a set of vertexes. The two vertexes are named the edge en

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