diff --git a/Quick sort b/Quick sort new file mode 100644 index 0000000..ee10dfb --- /dev/null +++ b/Quick sort @@ -0,0 +1,57 @@ +// { Driver Code Starts +#include +#include +using namespace std; +int partition (int arr[], int low, int high); +/* The main function that implements QuickSort + arr[] --> Array to be sorted, low --> Starting index, high --> Ending index */ +void quickSort(int arr[], int low, int high) +{ + if (low < high) + { + /* pi is partitioning index, arr[p] is now at right place */ + int pi = partition(arr, low, high); + // Separately sort elements before partition and after partition + quickSort(arr, low, pi - 1); + quickSort(arr, pi + 1, high); + } +} +/* Function to print an array */ +void printArray(int arr[], int size) +{ + int i; + for (i=0; i < size; i++) + printf("%d ", arr[i]); + printf("\n"); +} +// Driver program to test above functions +int main() +{ + int arr[1000],n,T,i; + scanf("%d",&T); + while(T--){ + scanf("%d",&n); + for(i=0;i