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 do you mean by garbage collection?
Define graph?
What is stable sort?
What is a sorting algorithm in data structure?
What is a circular singly linked list?
Complete structure of hashmap, very detail description, along with the basic coding of the hashmap internal implementation.
How to get the index of an array element?
Is a list an array?
What are basic algorithms?
What is a spanning tree in data structure?
What do you mean by articulation point?
What do you mean by disjoint set adt?
How many types of linked list are there?
What is advantage and disadvantage of linked list?
Which sorting is stable?