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
How are elements stored in hashset?
Is array static or dynamic?
How to sequentially represent max-heap?
How is a hashset implemented?
There is a program which inserts and deletes node in a sorted singly linked list. There is a bug in one of the modules, how would you debug it?
What do you understand by stable sort?
Does list allow null values?
Is null a binary search tree?
Is array part of collection framework?
Can we give size to arraylist?
What are the average and worst time complexity in a sorted binary tree is
What is difference between hashtable and hashmap?
Explain the Queue
Explain the implementation of an AVL tree and Binary tree.
What are the advantages of linked list over array (static data structure)?