Write programs for Bubble Sort, Quick sort
Answer Posted / siya
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],n,i,j,temp;
printf("\n\nEnter the total number of eleents:");
scanf("%d",&n);
printf("\n\nEnter the array elements:");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
/* sorting */
for(i=0;i<n;i++)
{
for(j=i;j<n-i-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j+1];
a[j+1]=a[j];
a[j]=temp;
}
}
}
printf("\n\nThe sorted array:");
for(i=0;i<n;i++)
printf("%d ",a[i]);
}
| Is This Answer Correct ? | 36 Yes | 28 No |
Post New Answer View All Answers
How does threaded binary tree represented in data structure?
How many sorting algorithms are there?
What does simulation of queues mean?
What is the difference between for and foreach loop?
What is data structure and its operations?
What is a matrix?
What is a weighted graph?
Why is waste sorting important?
Difference between arrays and linked list?
What is subtree?
Who created quicksort?
Which is the simplest file structure? (a) Sequential (b) Indexed (c) Random (a) Sequential
Is pointer a variable?
Which method will arrange the element of an array in alphabetical order?
Is pointer a variable in data structure?