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 is the difference between dictionary and hashtable?
What do you mean by complexity of search algorithm?
What data structure underlies a python list?
How many types of sorting algorithms are there?
Why is null not allowed in concurrenthashmap?
which is the simplest file structure? (Sequential, indexed, random)
What is the difference between a stack and an array?
What is the difference between the hash table and hash map?
Define right-in threaded tree?
Are dictionaries mutable?
What is the difference between collections class vs collections interface?
How do you access the values within an array?
Define hashing?
How does a treemap sort?
What is the need of sorting?