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 are dynamic data structures?
What is the complexity of sorting algorithm?
Does arraylist have a tostring?
What is binary tree example?
How do you sort an arraylist?
Is priority queue sorted?
How do you separate zeros from non-zeros in an array?
What is the use of isEmpty() member methods?
What are the difference between arraylist and linkedlist from the perspective of sorting?
Which data structure is used to perform recursion?
What is sorting rule in shapes?
How do you find the complexity of a bubble sort?
Describe what is Node in link list? And name the types of Linked Lists?
State the difference between stacks and linked lists?
What are binary trees?