Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!ecngs!feeder.ecngs.de!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '(there': 0.09; 'bubble': 0.09; 'algorithm': 0.13; 'received:209.85.214.174': 0.13; '...,': 0.16; 'adjacent': 0.16; 'bieber': 0.16; 'called,': 0.16; 'swaps': 0.16; 'then:': 0.16; '\xc2\xa0if': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.21; 'header:In- Reply-To:1': 0.22; 'feb': 0.22; '+0100,': 0.23; 'ancient': 0.23; 'items.': 0.23; 'seemingly': 0.23; 'elements': 0.24; 'cc:2**0': 0.26; 'looks': 0.27; 'pass': 0.29; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.29; 'url:wiki': 0.29; 'array': 0.30; 'remaining': 0.32; 'tue,': 0.32; 'list': 0.32; 'sort': 0.33; 'lee': 0.34; 'someone': 0.34; 'received:209.85.214': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'using': 0.37; 'received:209.85': 0.38; 'url:org': 0.39; 'url:en': 0.39; 'received:209': 0.39; 'selection': 0.40; 'kind': 0.62; 'subject:name': 0.67; 'dennis': 0.73; 'sort.': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=4jUUVy61wcudN7kPqoBwMLamKmTgUUtnePoQ+/Pdv/M=; b=amCu1smuM6oBw/HRWdKc5X83VNY1w3wivnJw6wRfMTAlC+kOy2p1/vfN2dFEdrX/V+ iBh42QJyP8TvWqwDeZ7f1nGDi4fKTbMhVgE06XHIcpORlTQXGbdTMp0nV/b9AohU2icI SZNeXRHybp1HjW9zi9G/pXGPOaBveMNMUurgE= MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 14 Feb 2012 16:22:45 +0000 Subject: Re: name of a sorting algorithm From: Arnaud Delobelle To: Dennis Lee Bieber Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1329236568 news.xs4all.nl 6932 [2001:888:2000:d::a6]:47284 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20407 On 14 February 2012 15:31, Dennis Lee Bieber wrote: > On Tue, 14 Feb 2012 16:01:05 +0100, Jabba Laci > wrote: > >>Could someone please tell me what the following sorting algorithm is call= ed? >> >>Let an array contain the elements a_1, a_2, ..., a_N. Then: >> >>for i =3D 1 to N-1: >> =C2=A0 =C2=A0for j =3D i+1 to N: >> =C2=A0 =C2=A0 =C2=A0 =C2=A0if a_j < a_i then swap(a_j, a_i) >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0Off 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). --=20 Arnaud