File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #include<bits/stdc++.h>
2+ using namespace std;
3+
4+
5+ int getPivort(int arr[],int low, int high){
6+ int i = low;
7+ int j = high;
8+ int pivort = arr[low];
9+
10+ while(i<j){
11+ while(arr[i]<=pivort && i<high) i++;
12+ while(arr[j]>pivort && j>=low) j--;
13+ if(i<j) swap(arr[i],arr[j]);
14+ }
15+ swap(arr[j],arr[low]);
16+ return j;
17+ }
18+
19+ void quickSort(int arr[], int low,int high){
20+ if(high>low){
21+ int pivort = getPivort(arr,low,high);
22+ quickSort(arr,low,pivort-1);
23+ quickSort(arr,pivort+1,high);
24+ cout<<"Hi"<<endl;
25+ }
26+ }
27+
28+ void printArr(int arr[],int n){
29+ for(int i=0; i<n; i++){
30+ cout<<arr[i]<<" ";
31+ }
32+ }
33+
34+ int main(){
35+ // freopen("input.txt","r",stdin);
36+ int n;
37+ cin>>n;
38+ int arr[n];
39+ for(int i=0; i<n; i++){
40+ cin>>arr[i];
41+ }
42+
43+ quickSort(arr,0,n-1);
44+ printArr(arr,n);
45+ }
You can’t perform that action at this time.
0 commit comments