Question: Hi there, I'm having trouble completing the following code in C, any help would be appreciated and so would a sample output. The following uses

Hi there, I'm having trouble completing the following code in C, any help would be appreciated and so would a sample output. The following uses quicksort Thank you!

#include

void quicksort(int [10],int,int);

int main(){

int x[20],size,i;

printf("Enter size of the array: ");

scanf("%d",&size);

printf("Enter %d elements: ",size);

for(i=0;i

scanf("%d",&x[i]);

printf(" ");

for(i=0; i

printf(" %4d", x[i]);

printf(" ");

quicksort(x,0,size-1);

printf(" Sorted elements: ");

for(i=0;i

printf(" %4d",x[i]);

printf(" ");

return 0;

}

void quicksort(int x[10],int first,int last){

int pivot,j,temp,i;

if(first

pivot=first;

i=first;

j=last;

while(i

while(x[i]<=x[pivot]&&i

i++;

while(x[j]>x[pivot])

j--;

if(i

temp=x[i];

x[i]=x[j];

x[j]=temp;

}

}

temp=x[pivot];

x[pivot]=x[j];

x[j]=temp;

quicksort(x,first,j-1);

quicksort(x,j+1,last);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!