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
Does linked list allow null values?
What is time complexity of binary search?
Can we put null key in hashmap?
How will you reverse Linked List.
Is list a data structure?
Name two algorithms two find minimum spanning tree?
Which one is the simplest sorting in data structure?
What is difference between data type and variable?
How will you sort the elements of array in descending order?
What is the difference between a hashmap and hashtable?
Does arraylist allow null values?
How can you add an item to the beginning of the list?
What is the procedure to insert into a sorted array?
You are given a singly linked list. How would you find out if it contains a loop or not without using temporary space?
What is data structures in computer science?