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 perfect binary tree?
What is tree in computer science?
List the data structures which are used in rdbms, network data modal, and hierarchical data model.
Differentiate between hashset and treeset.
How does a heap sort work?
How does insertion sort works?
What is the capacity of arraylist?
How do you sort an array by value?
What are the Difference between tcp and udp?
Explain what is the type of the algorithm used in solving the 8 queens problem?
how to delete first node from singly linked list?
How to excel in data structures and algorithms?
What is application of data structure?
On clicking a node in a tree, all the adjacent edges are turned on. Calculate min of clicks such that all the edges are turned on.
What is the structure of an array?