Write programs for Bubble Sort, Quick sort
Answer Posted / cynthia
//Program for implementing Bubble Sort
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],n,i,p,t;
clrscr();
printf("Enter the array limit");
scanf("%d",&n);
printf("\nEnter %d elemts",n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
p=0;
while(p<n-i)
{
if(a[p]>a[p+1])
{
t=a[p];
a[p]=a[p+1];
a[p+1]=t;
}
p++;
}
}
for(i=0;i<n;i++)
printf("%5d",a[i]);
getch();
}
Is This Answer Correct ? | 42 Yes | 16 No |
Post New Answer View All Answers
Does treemap preserve order?
Can arraylist contain null?
What are the properties of an algorithm?
Explain the applications of stack?
How is a queue works?
What is difference between hashset and treeset?
What do you mean by data and data structure?
How does a hashmap work?
What do you mean by rehashing?
What is difference between hashmap and map?
Does concurrenthashmap allow null?
How to find the duplicate in an array?
Do all declaration statements result in a fixed reservation in memory?
What is data structure and data type?
What is the heap in data structures?