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
What is a matrix? Explain its uses with an example
What is the use of treemap?
How do I push an element into a stack?
What is an iterative algorithm?
What is lifo?
Why merge sort is better than insertion sort?
Differentiate between iterator and listiterator.
Does linked list allow null values?
What do you mean by level of the tree?
What is b tree in data structure?
What things you would care about to improve the performance of application if its identified that its db communication that needs to be improved?
Does map extend iterable?
Is pointer a variable in data structure?
How remove all from arraylist?
Is hashmap fail safe?