Join the social network of Tech Nerds, increase skill rank, get work, manage projects...

• # Implement Quick Sort using C

• 0
• 0
• 0
• 0
• 0
• 0
• 0
• 0
• 151
Comment on it

Quick Sort Algorithm:- Quick sort is the most famous sorting algorithm. It is the external sorting technique that is based on divide and conquer strategy. The Complexity of this algorithm is following:

Best Case:- O(n log n)
Average Case:- O(n log n)
Worst Case:- O(n^2)

```#include<stdio.h>
#include<conio.h>

int split(int *,int,int);
void quick_sort(int *,int,int);

void main()
{
int arr[10],i,j,lw,up,mid;
clrscr();
printf("\nEnter 5 Unsorted Elements:=");
for(i=0;i<6;i++)
scanf("%d",&arr[i]);

lw=0;
up=6-1;
quick&#95;sort(arr,lw,up);
printf("\nSorted Array is:=\n");
for(i=0;i<6;i++)
printf("\n%d",arr[i]);
getch();
}

void quick_sort(int *a,int lw,int up)
{
int i;
if(up>lw)
{
i=split(a,lw,up);
quick_sort(a,lw,i-1);
quick_sort(a,i+1,up);
}
}

int split(int *a,int lw,int up)
{
int i=0,j=0,pivot,temp;
i=lw+1;
j=up;
pivot=a[lw];

while(j>=i)
{
while(a[i]<pivot)
i++;

while(pivot<a[j])
j--;

if(j>i)
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}

}
temp=a[lw];
a[lw]=a[j];
a[j]=temp;

return j;
}
```

## 0 Comment(s)

OR
OR
Register

OR
Fill out the form below and instructions to reset your password will be emailed to you:

• Hire
• Post Projects

### Post Projects

• All at 0 Cost ....
• Post Tech Job
• Select Best Bidder
• Track the Project
• Approve Work and Pay safely
• Browse Nerds
• Work
• Find Projects Find Projects
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
• Manage
• Company Company

### Manage Company

• All at 0 Cost ....
• Manage Company and Employee Profiles
• Company wide Employee Productivity Reports
• Knowledge Sharing and Collaboration Tools
• Get Sales Lead and Bid for Tech Projects
• Send Invoices and Receive Payment Safely
• Learn
• Nerd Digest Nerd Digest
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
• Tech Q & A Tech Q & A
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
• Record & Share

### Desktop Recording Tool

• All at 0 Cost ....
• Online tool for Recording Desktop Activity and Audio
• Store and Share from the Cloud
• Creating Software Product Demos
• Creating video tutorials
• Recording and Reporting Software and Project issues as videos