Re: name of a sorting algorithm

2012-02-14 Thread Ian Kelly
On Tue, Feb 14, 2012 at 11:10 AM, Jabba Laci wrote: > Hi, > >> Either you're misremembering, or the algorithm you programmed 43 years >> ago was not actually bubble sort.  Quoting from Wikipedia: >> >> """ >> Bubble sort, also known as sinking sort, is a simple sorting algorithm >> that works by r

RE: name of a sorting algorithm

2012-02-14 Thread Prasad, Ramit
Wilson, Mel wrote: >Well, the classic bubble sort swaps adjacent elements until the extreme one >gets all the way to the end. This sort continually swaps with the end >element during one pass until the end element holds the extreme. Then it >shrinks the range and swaps then next less extreme i

RE: name of a sorting algorithm

2012-02-14 Thread Prasad, Ramit
Prasad, Ramit wrote: > My apologies, you are correct. It is a selection sort, just an inefficient > one. Hmm, I think I should say it is neither since it reminds me of a hybrid of both (bubble/selection). The swapping seems very bubble sort, but the looking for the min / max case seems selectio

Re: name of a sorting algorithm

2012-02-14 Thread Jabba Laci
Hi, > Either you're misremembering, or the algorithm you programmed 43 years > ago was not actually bubble sort.  Quoting from Wikipedia: > > """ > Bubble sort, also known as sinking sort, is a simple sorting algorithm > that works by repeatedly stepping through the list to be sorted, > comparing

Re: name of a sorting algorithm

2012-02-14 Thread Ian Kelly
On Tue, Feb 14, 2012 at 9:55 AM, Den wrote: > On Feb 14, 8:22 am, Arnaud Delobelle wrote: >> 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 >> >>

Re: name of a sorting algorithm

2012-02-14 Thread Mel Wilson
Den wrote: > I disagree. In a bubble sort, one pointer points to the top element, > while another descents through all the other elements, swapping the > elements at the pointers when necessary. 'When I use a word,' Humpty Dumpty said, in rather a scornful tone, 'it means just what I choose it

Re: name of a sorting algorithm

2012-02-14 Thread Den
On Feb 14, 8:22 am, Arnaud Delobelle wrote: > 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 called? > > >>Let an array contain the elements a_1, a_2, .

RE: name of a sorting algorithm

2012-02-14 Thread Mel Wilson
Prasad, Ramit wrote: >> > for i in xrange (N-1): > for j in xrange (i, N): > if a[j] < a[i]: > a[i], a[j] = a[j], a[i] >> It's what Wikipedia says a selection sort is: put the least element in >> [0], the least of the remaining elements in [1], etc. > > If your only requi

Re: name of a sorting algorithm

2012-02-14 Thread Arnaud Delobelle
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 called? >> >>Let an array contain the elements a_1, a_2, ..., a_N. Then: >> >>for i = 1 to N-1: >>    for j = i+1

Re: name of a sorting algorithm

2012-02-14 Thread Ulrich Eckhardt
Am 14.02.2012 16:01, schrieb Jabba Laci: 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) It's so simple that it's not ment

RE: name of a sorting algorithm

2012-02-14 Thread Prasad, Ramit
> for i in xrange (N-1): for j in xrange (i, N): if a[j] < a[i]: a[i], a[j] = a[j], a[i] > It's what Wikipedia says a selection sort is: put the least element in [0], > the least of the remaining elements in [1], etc. If your only requirement to match to selection sort is

Re: name of a sorting algorithm

2012-02-14 Thread Mel Wilson
Jabba Laci 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 in xrange (N-1): for j in xrange (i, N): if a[j] < a[i]: a[i], a[j] = a[j], a[i] > > It's so simple t

name of a sorting algorithm

2012-02-14 Thread Jabba Laci
Hi, 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) It's so simple that it's not mentioned anywhere. I guess it's called "sel