![]() |
|
#1
|
|||
|
|||
Bubble Sort ProgramI have written the following program for bubble sort, is it correct? Can somebody run it and check the output to confirm its correctness?
Actually, the number of runs for the following sequence : 44,33,55,22,11 is 8 i.e. swap=8. I also put this code on wikipedia reference, but there people said, its wrong as it takes too many turns to sort. But my point is that number of swaps is only 8, the 20 steps obtained after entering above numbers shows the number of steps required, or the number of times the outer loop for variable "i" runs. So i think it is right. but still any advice would be welcome. CPP / C++ / C Code:
Last edited by cable_guy_67 : 02-Jul-2006 at 14:58.
Reason: Please surround your C code with [c] your code [/c] code tags.
|
|
#2
|
||||
|
||||
Re: Bubble Sort Programhave a look at an alternative algorithm here:
http://linux.wku.edu/~lamonml/algor/sort/bubble.html __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
Recent GIDBlog
Developing GUIs with wxPython (Part 4) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to read particular memory location ? | realnapster | C Programming Language | 10 | 10-May-2006 09:11 |
| help with Bubble sort program that uses vectors instead of arrays | sasuke101 | C++ Forum | 9 | 25-Oct-2005 11:26 |
| need help with bubble sort for c++ | sasuke101 | C++ Forum | 2 | 21-Sep-2005 20:12 |
| Type casts ? | kai85 | C++ Forum | 12 | 23-Jun-2005 12:04 |
| [GIM] gim.h | dsmith | C Programming Language | 0 | 18-Jan-2005 08:48 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The