Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Does linked list allow null values?

769


What is time complexity of binary search?

842


Can we put null key in hashmap?

842


How will you reverse Linked List.

848


Is list a data structure?

910


Name two algorithms two find minimum spanning tree?

877


Which one is the simplest sorting in data structure?

1002


What is difference between data type and variable?

760


How will you sort the elements of array in descending order?

900


What is the difference between a hashmap and hashtable?

774


Does arraylist allow null values?

884


How can you add an item to the beginning of the list?

948


What is the procedure to insert into a sorted array?

933


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

1054


What is data structures in computer science?

871