# bubble sort?

• 11-12-2002
brianptodd
bubble sort?
Has anyone heard of sorting an array using a bubble sort. I have never heard of it, and I can't find any information on it.

Brian
• 11-12-2002
.............
Bubble sort is a sorting algorithm in which you sort by comparing adjacent elements in an array. If the elements are out of order, you swap them. It works ok on small arrays, I guess, but in general...it's crap. Hope that was what you were looking for.
• 11-12-2002
ammar
I think it's the simplest sorting algorithm I now, and i think the slowest...
it's like this.
if you have an array[size]
you can so this:
Code:

```const int size; int array[size]; int temp; for( int pass=0; pass< size-1; pass++ )     for ( int ij=0; i<size-1; ij++ )           if ( array[i] > array[i+1] ) //check           {               temp = array[i];          //swap variables               array[i] = array[i+1]               array[i+1] = temp;           }```
• 11-13-2002
Prelude
>Has anyone heard of sorting an array using a bubble sort.
I may have seen something concerning a thing called "bubble sort" quite some time ago. It was referred to in terms of something else called "bogo sort". ;)

>I have never heard of it, and I can't find any information on it.
I suggest you get a book (just about any book) on programming and look in the index. If the algorithm isn't there then try another book. I figure that it will take you at most two tries to find it.

-Prelude
• 11-13-2002
...
hey, '.............' i hope you arent planning on keeping that name. ;)
• 11-14-2002
28:06:42:12
Quote:

Originally posted by ...
hey, '.............' i hope you arent planning on keeping that name. ;)
Why, no, in fact, I'm not. This any better? :)
• 11-14-2002
sundeeptuteja
Try this.
Code:

```int array[limit],ctr,temp; bool flag=0; while(flag==0) {   flag=1;   for(ctr=0; ctr<limit-1; ++ctr)   {       if(array[ctr]>array[ctr+1])       {         temp=array[ctr]; array[ctr]=array[ctr+1]; array[ctr+1]=temp;         flag=0;       }   } }```
• 11-14-2002
...
Quote:

Originally posted by 28:06:42:12
Why, no, in fact, I'm not. This any better? :)
much... :P