Snis Pilbor wrote:
> Logan Shaw wrote:
>
>>Snis Pilbor wrote:
>>
>>>Registered User wrote:
>>>
>>>>What is the name of the following sorting method?
>>>>
>>>>for (i=0; i<n-1; i++)
>>>> for (j=i+1; j<n; j++)
>>>> if (a[i]>a[j])
>>>> swap(&a[i], &a[j]);
>>>>
>>
>>(snip)
>>
>>By the way, I am sure I am not the only one to have come up with it,
>>but I was quite proud of myself when I came up with this exact sort
>>in high school. I liked it because (I believe) it's more efficient
>>than bubble sort in practice and it's extremely easy to remember and
>>key in quickly. So if you are on a system with no built-in sort
>>function (admittedly less common a situation these days than when I
>>was in high school 20 years ago...), and if you're only sorting 10
>>elements, it could be useful.
>
>
> Not to belittle you or anything, but what is to be proud of? This is
> about as straightforward as it gets- I have trouble thinking of a MORE
> straightforward, brainless way of doing the sort, short of maybe
> specifically finding the lowest entry and putting it at the bottom of a
> new array, then the 2nd lowest, etc., then copying the new array onto
> the original. I mean, in terms of ingenuity involved, the OP's sort
> algorithm is about one or two steps above "Hello, world!"
_QBasic Programming for Dummies_ (my first programming book) actually
claims this one is not too bad. What could they be comparing it
against? (IIRC, Knuth gives an O(n^3) algorithm as the one with the
shortest MIX program.)
--
Simon Richard Clarkstone: s.r.cl?rkst?n?@durham.ac.uk/s?m?n.cl?rkst?n?@
hotmail.com ### "I have a spelling chequer / it came with my PC /
it plainly marks for my revue / Mistake's I cannot sea" ...
by: John Brophy (at:
http://www.cfwf.ca/farmj/fjjun96/)