Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20407

Re: name of a sorting algorithm

References <CAOuJsMnV0GPK=Jm=s5K7QRS1VO=wy62-H7FfaB-Y5QBitRDu=Q@mail.gmail.com> <o9ukj7p7f6h3sn6p6d0hpoh09vd9rpssu8@4ax.com>
Date 2012-02-14 16:22 +0000
Subject Re: name of a sorting algorithm
From Arnaud Delobelle <arnodel@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.5805.1329236568.27778.python-list@python.org> (permalink)

Show all headers | View raw


On 14 February 2012 15:31, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:
> On Tue, 14 Feb 2012 16:01:05 +0100, Jabba Laci <jabba.laci@gmail.com>
> wrote:
>
>>Could someone please tell me what the following sorting algorithm is called?
>>
>>Let an array contain the elements a_1, a_2, ..., a_N. Then:
>>
>>for i = 1 to N-1:
>>    for j = i+1 to N:
>>        if a_j < a_i then swap(a_j, a_i)
>>
>        Off hand... The ancient Bubble-Sort...
>
> http://en.wikipedia.org/wiki/Bubble_sort

Ahem...

No, it's not Bubble Sort.  Bubble sort only swaps adjacent terms.

I don't know what this sort is called, if it even has a name.  It's a
kind of Selection Sort, as each pass it looks for the minimum of the
remaining unsorted items.  But it ruffles the unsorted list each pass,
seemingly to save using an extra register to store the current minumum
(there was a time when registers were at a premium).

-- 
Arnaud

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: name of a sorting algorithm Arnaud Delobelle <arnodel@gmail.com> - 2012-02-14 16:22 +0000
  Re: name of a sorting algorithm Den <patentsvnc@gmail.com> - 2012-02-14 08:55 -0800
    Re: name of a sorting algorithm Mel Wilson <mwilson@the-wire.com> - 2012-02-14 12:04 -0500
    Re: name of a sorting algorithm Ian Kelly <ian.g.kelly@gmail.com> - 2012-02-14 10:37 -0700
    Re: name of a sorting algorithm Jabba Laci <jabba.laci@gmail.com> - 2012-02-14 19:10 +0100
    Re: name of a sorting algorithm Ian Kelly <ian.g.kelly@gmail.com> - 2012-02-14 13:59 -0700

csiph-web