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 are the Differences between map and hashmap?
What is the best case complexity of quicksort?
How is any data structure application is classified among files?
What is mean by selection sort?
What is data structure? Explain.
State the advantages of using postfix notations?
When will we get ArrayStoreException?
Can we change load factor of hashmap?
What are the major data structures used in the following areas : network data model & hierarchical data model?
What is a multiset table?
What is the difference between hashmap and treemap?
What are examples of data structures?
Are sets sorted?
What is difference between map and hashmap?
Define a Deque?