diff --git a/3_way_quick_sort.cpp b/3_way_quick_sort.cpp new file mode 100644 index 0000000..4a706d1 --- /dev/null +++ b/3_way_quick_sort.cpp @@ -0,0 +1,93 @@ +#include +using namespace std; + +void print(long long arr[],long long n) +{ + for(int i=0;i partition3(long long arr[],long long l,long long r ) +{ + pair par; + long long i=l,j,k=l,p=r; + while(i=k;i--,j--) + arr[j]=arr[i]; + end=j; + for(j;j>=k;j--) + arr[j]=temp; + // print(arr,r+1); + // cout< par=partition3(arr,l,r); + sort(arr,l,par.first-1); + sort(arr,par.second+1,r); + } +} +bool checkSorted(long long arr[],long long n) +{ + int i; + for(i=0;iarr[i+1]) + return false; + return true; +} + +int main() +{ + long long n,arr[100010]; + cin>>n; + for(int i=0;i>arr[i]; + sort(arr,0,n-1); + print(arr,n); + // partition3(arr,0,n-1); + return 0; +} + +// int main() +// { +// long long n,ini[1000],temp,arr[1000],i; +// n=100; +// while(1) +// { +// srand(time(0)); +// for(i=0;i