From afeb87dc941077c41824713f8d8ed494409ed8c2 Mon Sep 17 00:00:00 2001 From: 5hibin5hibu <116331005+5hibin5hibu@users.noreply.github.com> Date: Sat, 22 Oct 2022 09:55:22 +0530 Subject: [PATCH] Create quickSort.c Program to implement QuickSort. --- C/quickSort.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 C/quickSort.c diff --git a/C/quickSort.c b/C/quickSort.c new file mode 100644 index 0000000..22ef497 --- /dev/null +++ b/C/quickSort.c @@ -0,0 +1,64 @@ +#include +#include +#include +int a[100]; +int n, left = 0, right; +void setup() +{ + int i; + printf("How many elements do you want to enter?\n"); + scanf("%d", &n); + right = n-1; + printf("Enter the elements\n"); + for (i = 0; i < n; i++) + scanf("%d", &a[i]); + a[n]=INT_MAX; + printf("The entered array is:\n"); +} +void display() +{ + for (int i = 0; i < n; i++) + printf("%d ", a[i]); +} +void swap(int *x, int *y) +{ + int t = *x; + *x = *y; + *y = t; +} +int partition( int a[], int l, int r) +{ + int pivot = a[l]; + int i = l; + int j = r + 1; + while(i < j) + { + while(a[i] <= pivot) + i++; + while(a[j] > pivot) + j--; + if(i