IMPLEMENTATION OF QUICK SORT
PROGRAM:
#include
#include
#define size 10
void quick(int a[size],int,int);
int partition(int a[size],int,int);
void swap(int a[size],int *,int*);
int n;
void main()
{
int i;
int a[size];
clrscr();
printf("\n Quick Sort");
printf("\n Enter the no of sort");
scanf("%d",&n);
for(i=0;i
printf("\nEnter the %d st number",i+1);
scanf("\n%d",&a[i]);
}
quick(a,0,n-1);
printf("\nSorted Array");
for(i=0;i
getch();
}
void quick(int a[size],int low,int high)
{
int m,i;
if(low
m=partition(a,low,high);
quick(a,low,m-1);
quick(a,m+1,high);
}
}
int partition(int a[size],int low,int high)
{
int pivot=a[low],i=low,j=high;
while(i<=j)
{
while(a[i]<=pivot)
i++;
while(a[j]>pivot)
j--;
if(i
}
swap(a,&low,&j);
return j;
}
void swap(int a[size],int *i,int*j)
{
int temp;
temp=a[*i];
a[*i]=a[*j];
a[*j]=temp;
}
OUTPUT:
Quick Sort
Enter the no of sort 5
Enter the 1 st number 9
Enter the 2 st number 7
Enter the 3 st number 5
Enter the 4 st number 3
Enter the 5 st number 1
Sorted Array 1 3 5 7 9
CIET college Programs,LAB Programs for Engineering Students,DAA LAB Programs,DSA LAB Programs,Remoboys,karthik,Remokn,Student3k,programs source code,Design Analysis And Algorithms LAB Programs,Data Structures and Algorithms LAB Programs,LAB Codings,Coimbatore Institute of Engineering and Technology ( CIET )
Wednesday, September 22, 2010
IMPLEMENTATION OF QUICK SORT PROGRAM
9:28 AM
Karthikh Venkat
Popular Posts( Last 7 Days )
-
wwe wallpapers,wwe stills, wwe posters,wwe latest picture photo posters collections, batista latest pictures wallpapers posters news recent
-
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Computer science and engineering department aims at producing technically competent professi...
-
A Aalim Muhammed Salegh College of Engineering, Chennai Aarupadai Veedu Institute of Technology, Kanchipuram Aksheyaa College of Engineer...
-
Tapsee Photo Shoot, aadukalam actress tapasee pannu new stills, south indian actress tapsee pannu new stills, tapasee pannu Latest Ph...
-
Ravi Teja's Veera Movie Stills stars : Ravi Teja, Kajal, Taapsee, Kick Shaam, Sridevi, Prakash Raj, Brahmanandam directed by Ramesh Varm...
-
Pak match-fixing scandal: Handed over 'proof' of Asif's corruption, says Veena Malik Lahore: Pakistani cri...