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

Polynomials, Polynomials like  5x 4    +  2x 3    +  7x 2     +  10x  -  8...

Polynomials like  5x 4    +  2x 3    +  7x 2     +  10x  -  8  can  be  represented by using arrays. Arithmetic operations such as addition & multiplication of polynomials are com

Data structures, #quCreate a flowchart to show the process that will allow ...

#quCreate a flowchart to show the process that will allow the implementation of Queue, Enqueue, and Dequeue operations.estion..

Compound interest, Write the algorithm for compound interest

Write the algorithm for compound interest

Representation of records, Records are mapped onto a computer store by simp...

Records are mapped onto a computer store by simply juxtaposing their elements. The address of a component (field) r relative to the origin address of the record r is named the fiel

Linear node is given by means of pointer, A linear collection of data eleme...

A linear collection of data elements where the linear node is given by means of pointer is known as Linked list

Explain multidimensional array, Multidimensional array: Multidimensional a...

Multidimensional array: Multidimensional arrays can be defined as "arrays of arrays". For example, a bidimensional array can be imagined as a bidimensional table made of elements,

Define spanning tree, Define Spanning Tree A Spanning Tree of a connect...

Define Spanning Tree A Spanning Tree of a connected graph is its linked acyclic sub graph (i.e., a tree) that having all the vertices of the graph.

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

State phong shading, Phong Shading Phong shading too is based on interp...

Phong Shading Phong shading too is based on interpolation, but instead of interpolating the colour value, it is the normal vector, which is interpolated for each point and a co

How do collisions happen during hashing, How do collisions happen during ha...

How do collisions happen during hashing? Usually the key space is much larger than the address space, thus, many keys are mapped to the same address. Assume that two keys K1 an

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