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
What is difference between arraylist and linkedlist?
List the applications of set adt?
Does arraylist contain duplicates?
Mention the advantages of representing stacks using linked lists than arrays?
Is it possible to increase size of array?
What is the use of data structure?
Does arraylist have a tostring?
What are the basic data structures?
What is the difference between array list and vector list?
Which interface treemap implements?
Can we change load factor of hashmap?
How do treesets work internally?
What is different between array and list?
Traverse the given tree using Inorder, Preorder and Postorder traversals. Inorder : D H B E A F C I G J Preorder: A B D H E C F G I J Postorder: H D E B F I J G C A
Which sort algorithm is best?