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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started