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 faster array or arraylist?
Why is null not allowed in concurrenthashmap?
What are b tree keys?
What is difference between linear and non linear data structure?
How would you implement two stacks using a single array?
Is hashmap faster than arraylist?
Differentiate between queue and stack.
Why is treeset sorted?
Why quicksort is faster?
What is difference between stack and queue?
Is hashmap part of collection?
How expression trees are gets represented in data structure?
What is a binary search tree? Explain with example?
How does a treemap sort?
How many pointers are necessary to implement a simple linked list?