Sort a given set of elements using the Quick sort method and determine the time required to sort the elements. Repeat the experiment for different values of n, the number of elements in the list to be sorted and plot a graph of the time taken versus n. The elements can be read from a file or can be generated using the random number generator.

#include<stdio.h>
#include<conio.h>
int partition(int a[],int low,int high){
	int pivot=a[low],temp;
	int i=low+1;
	int j=high;
	for(;;){
		while(i<high && a[i]<pivot){
			i++;
		}
		while(pivot<a[j]){
			j--;
		}
		if(i<j){
			temp=a[i];
			a[i]=a[j];
			a[j]=temp;
		}
		else{
			temp=a[low];
			a[low]=a[j];
			a[j]=temp;
			return j;
		}
	}
}
void quick_sort(int a[],int low,int high){
	if(low<=high){
		int pivot=partition(a,low,high);
		quick_sort(a,low,pivot-1);
		quick_sort(a,pivot+1,high);
	}
}
void main(){
	int n,a[10],i;
	clrscr();
	printf("Enter size of array\n");
	scanf("%d",&n);
	printf("Enter all array elements to sort\n");
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	quick_sort(a,0,n-1);
	printf("Sorted array are:\n");
	for(i=0;i<n;i++){
		printf("%d\n",a[i]);
	}
	getch();
}