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
Define terminal nodes in a tree?
How does a selection sort work?
Explain extended binary tree.
What is scalar example?
List the types of rotations available in splay tree?
What is integer max_value?
How do stacks work?
Why do we Use a Multidimensional Array?
Can you tell me the differences between Array and ArrayList?
What is a Breadth First Search? Give a few of its applications.
What are control structures?
What is sequential search? What is the average number of comparisons in a sequential search?
Which sorting is used in collections sort?
How do you sort an array by value?
What is collections singletonlist?