Re: Sorting
- From: Eric Sosman <esosman@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 27 Apr 2007 21:24:30 -0400
Malcolm McLean wrote:
"Umesh" <fraternitydisposal@xxxxxxxxx> wrote in message news:1177664304.581212.237870@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxI don't understand it. Help me by writing a program while i try myselfThere are lots of ways of sorting.
to sort an array of numbers. Thanks.
The easiest, probably, is to go through the array. Compare the number you are on with the number above it. If they are in the wrong order, swap them. Then go back to the start of the array and do it again, until you make a clean sweep without swapping. Set a flag when you swap, and clear it each time you restart.
This algorithm is called bubblesort.
... a.k.a. "The Second-Worst Sorting Algorithm in the
Literature." Vastly inferior to the selection sort already
posted (once its errors are fixed).
--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxx
.
- Follow-Ups:
- Re: Sorting
- From: Malcolm McLean
- Re: Sorting
- From: Richard Harter
- Re: Sorting
- References:
- Sorting
- From: Umesh
- Re: Sorting
- From: Malcolm McLean
- Sorting
- Prev by Date: Re: Reliably determine sign value of double in C90/C89
- Next by Date: Re: Reliably determine sign value of double in C90/C89
- Previous by thread: Re: Sorting
- Next by thread: Re: Sorting
- Index(es):
Relevant Pages
|