Write programs for Bubble Sort, Quick sort
Answer Posted / siya
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],n,i,j,temp;
printf("\n\nEnter the total number of eleents:");
scanf("%d",&n);
printf("\n\nEnter the array elements:");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
/* sorting */
for(i=0;i<n;i++)
{
for(j=i;j<n-i-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j+1];
a[j+1]=a[j];
a[j]=temp;
}
}
}
printf("\n\nThe sorted array:");
for(i=0;i<n;i++)
printf("%d ",a[i]);
}
Is This Answer Correct ? | 36 Yes | 28 No |
Post New Answer View All Answers
What happens if we try to insert duplicate key in hashmap?
Which sorting algorithm is best for large data?
Which data structure is used to perform recursion?
Can constructor be static?
Why arraylist is not efficient for manipulation?
What is difference between tree and forest?
What is difference between array and arraylist?
What is the use of treemap?
What are the types of collection?
How will you sort the elements of array in descending order?
What is default array size?
What do you mean by structure property in a heap?
Define an equivalence relation?
What are the advantages of selecetion sort?
What is heap and its types?