DAA lab practical program (B.tech 6th sem)
DAA lab practical program PDF download DAA lab practical program b.tech 6th sem 1. Sort a given set of elements using the Quicksort 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. Solution:- #include<stdio.h> #include<sys/time.h> void swap(int *x,int *y) { int temp; temp=*x; *x=*y; *y=temp; } void generate_random(int a[],int n) { int i; srand(time(0)); for(i=0;i<n;i++) a[i]=rand()%1000; } int Partition(int a[10],int l,int h) { int i,j,p; i=l;j=h+1; p=l; do{ do{ i=i+1; }while(a[i]<a[p]); do{ j=j-1; }while(a[j]>a[p]); swap(&a[i],&a[j]); }while(i<=j); swap(&a[i],&a[j]); swap(&a[l],&a[j]); return j; } int Quicksort(int a[10],int m,int n) { int s; if(m...