Question

Write a C function to process arrays (1D and 2D), select sort, quick sort

Write a C function to process arrays (1D and 2D), select sort, quick sort

0 0
Add a comment Improve this question Transcribed image text
Answer #1

For select sort :

Void sel_sort( int arr[],int n )

{ Int i,min,j;

For(i=0;i<n-1;i++)

Min = i;

For(j=i+1;j<n;j++)

{

If(arr[j]<arr[min])

Min=j;

}

Swap(arr,min,i);

}

Swap (int arr[],int i,int j)

{

Int temp=arr[i];

arr[i]=arr[j];

arr[j]=temp;

}

For quick sort :

Quick_sort(int arr[],int l, int h)

{

Int p=partision(arr,l,h);

Quick_sort(arr,l,p-1);

Quick_sort(arr,p+1,h)

}

}

Partision(int arr[],int l,int h)

{ Int x,i,j;

x =arr[h];

i = ( l -1) ;

For(j=l;j<h-1;j++)

{ If (arr[j]<x)

{

i++;

Swap(&arr[i],arr[j]]);

}

}

Swap(&arr[i+1],&arr[h]);

Return i+1;

}

Swap (int *a,int *b)

{

Int temp=*a;

*a=*b;

*b=temp;

}

For string :

Void reverse()

{

If (c !='\n')

{

Reverse ();

Printf("%c",c);

}

}

Add a comment
Know the answer?
Add Answer to:
Write a C function to process arrays (1D and 2D), select sort, quick sort
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT