Now Online : 11

New User? Register

Welcome

 My Profile My Articles My Projects My Snippets My Polls Invite Friends

 New User? Register
 Find us on
 Technologies

POLL OF THE DAY
 How do you back up your personal data? USB thumb driveExternal hard driveOptical discMemory cardOnline backup serviceMultiple methodsNetwork-attached storage device Want to create a new poll now? (Login Required)

How do you back up your personal data?

USB thumb drive 15 11.40
External hard drive 43 32.60
Optical disc 9 6.80
Memory card 14 10.60
Online backup service 23 17.40
Multiple methods 14 10.60
Network-attached storage device 14 10.60

Total Responses: 132

Not scientifically valid. Results are updated every 15 minutes.

## Bubble sort in C-Language

 Author: Renuka Email: ******** Last Updated: 8/6/2010 8:30:00 PM Views: 28881 Level: Intermediate Downloads: 0

Introduction

Sorting is arranging the given list in ascending/descending order, with respect to a given key field. This list can be number of records, with each record having many fields.

Types of sorting

• Exchange/Bubble Sort
• Selection Sort
• Insertion Sort
• Quick/Partition Exchange Sort
• Merge/2-Way Merge Sort

Exchange/Bubble Sort : It uses simple algorithm. It sors by comparing each pair of adjusent items and swaping them in the order .This will be repeated until no swaps are needed. The algorithm got its name from the way smaller elements "bubble" to the top of the list.

It is not that much efficient, when a list is having more than a few elements. Among simple sorting algorithms, algorithms like insertion sort are usually considered as more efficient.
Bubble sort is little slower compared to other sorting techniques but it is easy because it deals with only two elements at a time.

An example to bubble sort is given below.

```    #include <stdio.h>
void main()
{
int a[10]={34,2,56,78,34,5,76,10,47,29};  //initializing array of elements
int n=10;
int i,j,temp;
for(i=0;i<10;i++)            //for loop to select each element in the array
{
for(j=0;j<n-i;j++)      //for loop to swap elements after comparing
{
if(a[j]>a[j+1])
{
temp=a[j];       //swaping
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
for(i=0;i<n;i++)           //for loop to print sorted elements
{
printf("%d \n",a[i]);
}
}
```
 Comments rep:Bubble sort in C-Language Posted on 4/17/2013 @ 12:25 PM By dutta Pls explain me bubble sort with an example not by programming language. rep:Bubble sort in C-Language Posted on 4/16/2013 @ 6:38 AM By birendra why it is not running in my "c-free5" application ??? rep:Bubble sort in C-Language Posted on 12/21/2012 @ 12:41 PM By dddddd Exactly what i needed. I'll try it. I hope it will work for a beginner like me. Thanks. rep:Bubble sort in C-Language Posted on 10/29/2012 @ 2:31 AM By nagesh hosale thanks for cleraring my doubts rep:Bubble sort in C-Language Posted on 9/27/2012 @ 8:04 AM By Aabi thank you for help in c language.... rep:Bubble sort in C-Language Posted on 8/25/2012 @ 7:53 AM By aratrik thanks a lot rep:Bubble sort in C-Language Posted on 7/13/2012 @ 6:22 AM By sanjeev sharma enquary
 Post your comments: Name : Email : Subject : -Select- FeedBack Help/Support Question Message : Type the word :