diff --git a/Add Code Here/quickSort.cpp b/Add Code Here/quickSort.cpp new file mode 100644 index 0000000..1b5ff8b --- /dev/null +++ b/Add Code Here/quickSort.cpp @@ -0,0 +1,36 @@ +#include +using namespace std; + +int partition(int *arr,int l,int r){ + // pivot + int pivot = arr[r]; + int i = l; + for(int j = l;j=r){ + return; + } + // pivot index + int p = partition(arr,l,r); + quickSort(arr,l,p-1); + quickSort(arr,p+1,r); +} + +int main(){ + int arr[] = {0,6,0,3,2}; + int n= 5; + quickSort(arr,0,n-1); + for(int i = 0;i