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
Define an algorithm.
Define an abstract data type (adt)?
What is difference between arraylist and linkedlist?
Write a program to sum values of given array.
Is a hash table a map?
What is difference between hashset and treeset?
“int a[] = new int[3]{1, 2, 3}” – This a legal way of defining the arrays?
Differentiate between hashmap and treemap.
What are the Difference between tcp and udp?
How can someone display singly linked list from first to last?
What is bubble sort with example?
What are red-black trees?
Provide an algorithm to reverse a linked list without using recursion.
How to create your own data structure in java?
What are the advantages of binary search over linear search?