Skip to content
This repository was archived by the owner on Mar 14, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Contributors/Rohit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
1. Name: Rohit
2. Year: Second year
3. Department:Computer Science
4. Interests:coding
5. GitHub Username:agarwalr98
6. Email id : agarwal.r1998@gmail.com
49 changes: 49 additions & 0 deletions Sorting_Algorithms/quicksort/quicksort.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include<bits/stdc++.h>
using namespace std;
int partition1(int a[],int l,int r)
{
int temp,i;
int pivot=a[r];
int p=l;
for(i=l;i<r;i++)
{
if(a[i]<=pivot)
{
//swap(a[i],a[p])
temp=a[i];
a[i]=a[p];
a[p]=temp;
p++;
}

}
//swap(a[p],pivot);
temp=a[p];
a[p]=a[r];
a[r]=temp;
return p;
}
void quicksort(int a[],int l,int r)
{
if(l>=r)
return;
int p=partition1(a,l,r);
quicksort(a,l,p-1);
quicksort(a,p+1,r);

}

int main()
{
int i,j,k,l,m,n;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
quicksort(a,0,n-1);
for(i=0;i<n;i++)
printf("%d ",a[i]);

return 0;
}