New Member FAQ | Forums | Earn Revenue | Posting Guidelines | Help Topics


ResourcesPractice TestsAsk ExpertsQuestion PapersJobsStudy in UKUniversitiesCollegesCoursesSchoolsTraining


My Profile

Awards & Gifts


Active Members
TodayLast 7 Daysmore...





Implementation of Quick Sort


Posted Date:     Total Responses: 0    Posted By: pankaj agarwala   Member Level: Silver   Points/Cash: 2   


To write a C program to Quick Sort




#include
#include

int quick(int *p,int lb,int ub)
{
int pos=lb,t;
while(1)
{
while(p[ub]>=p[pos]&&pos!=ub)
ub--;
if(pos!=ub)
{
t=p[pos];
p[pos]=p[ub];
p[ub]=t;
pos=ub;
}
else
return pos;
while(p[lb]>p[pos]&&pos!=lb)
lb++;
if(pos=lb)
{
t=p[pos];
p[pos]=p[lb];
p[lb]=t;
pos=lb;
}
else
return pos;
}
}







void quicksort(int *p,int n)
{
int lower[10],upper[10],top=-1;
int l,u,pos;
lower[++top]=0;
upper[top]=n-1;
while(top!=-1)
{
l=lower[top];
u=upper[top--];
pos=quick(p,l,u);
if(pos+1{
lower[++top]=pos+1;
upper[top]=u;
}
if(pos-1>l)
{
lower[++top]=l;
upper[top]=pos-1;
}
}
}









void main()
{
clrscr();
int x[10],i;
printf("\n Enter Array");
for(i=0;i<10;i++)
scanf("%d",&x[i]);

quicksort(x,10);
printf("\n AFTER SOrting");
for(i=0;i<10;i++)
printf(" %d",x[i]);
getch();
}


Project Feedbacks

Author: Member Level: GoldRevenue Score: 1 out of 5
In which version did you run this project


Author: Member Level: SilverRevenue Score: 1 out of 5
hi saurabh,
You can run this this project in any C compiler.
I have compiled it in Turbo C++.




Post Feedback
You must Sign In to post a feedback.
Next Project: Evaluation of PostFix Expression
Previous Project: Security Market line with reference to Financial Firms in India

Return to Project Index

Post New Project


Related Projects

Subscribe to Email
  • Get Jobs by Email
  • Forum posts by Email
  • Articles by Email



  • website counter

    Online Membersbenson gomez
    Ashish Kumar
    Iti Tyagi
    Sakshi Sood
    dks
    Arvind
    siva
    sathishkumar
    Shiyas
    Kamlesh. M. Dhurve
    Saraswathi
    More...



    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    AdSense Revenue Sharing sites   Advertise   Talk to Tony John
    ISC Technologies, Kochi - India
    2006 - 2012 All Rights Reserved.