#Include #Include: Const Int Class Private Int Int Public
#Include #Include: Const Int Class Private Int Int Public
INTRODUCTION:
ALGORITHM:
PROGRAM:
#include <iostream.h>
#include<conio.h>
const int MAX = 10 ;
class array
{
private :
int arr[MAX] ;
int count ;
public :
array( ) ;
void add ( int item ) ;
int getcount( ) ;
static int split ( int *, int, int ) ;
void quiksort ( int lower, int upper ) ;
void display( ) ;
};
array :: array( )
{
count = 0 ;
for ( int i = 0 ; i < MAX ; i++ )
arr[i] = 0 ;
}
void array :: add ( int item )
{
if ( count < MAX )
{
arr[count] = item ;
count++ ;
}
else
cout << "\nArray is full" << endl ;
}
int array :: getcount( )
{
return count ;
}
void array :: quiksort ( int lower, int upper )
{
if ( upper > lower )
{
int i = split ( arr, lower, upper ) ;
quiksort ( lower, i - 1 ) ;
quiksort ( i + 1, upper ) ;
}
}
Quick sort:
Array before sorting
11 2 9 13 57 25 17 1 90 3
Array after quick sorting
1 2 3 9 11 13 17 25 57 90