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
How to sequentially represent max-heap?
Why is quicksort not stable?
Which collection allows null values?
How do you create a tree diagram?
Is array a collection?
Can you distinguish between ArrayList and Array?
What is Storage Structures and File Structures? Can you show their relation? What are the examples of each? Thanks
How would you implement two stacks using a single array?
Explain extended binary tree.
Why is sorting important?
List the applications of stacks?
Explain how is linked list implemented?
Is map a data structure?
What is difference between arraylist and list?
State the rules to be followed during infix to prefix conversions?