Write programs for Bubble Sort, Quick sort

Answer Posted / prashant gupta

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j,t;
int a[7]={5,7,8,1,4,2,9}; // You can use any length

for(i=0;i<6;i++)
{
for(j=i+1;j<6;j++)
{
if(a[i]>a[j])
{
t = a[i];
a[i] = a[j];
a[j] = t;
}
}
printf("The Sorted Array is = %d",a[i]);

getch();
}

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is Insertion sort, selection sort, bubble sort( basic differences among the functionality of the three sorts and not the exact algorithms)?

516


When will we get ArrayStoreException?

744


Which is best array or linked list?

467


What is difference between array and arraylist? When will you use array over arraylist?

522


How does quick sort work?

517






Differentiate between set and map.

614


How do you sort an array by value?

472


What is an externalizable interface?

520


What is sorting explain?

477


Does treeset allow duplicates?

457


Which is better bubble sort or selection sort?

469


You are given a singly linked list. How would you find out if it contains a loop or not without using temporary space?

686


What is application of data structure?

470


What do u mean by array?

474


What differences exist between hashmap and hashtable?

504