Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"We will bury you." -- Nikita Kruschev


devel / comp.lang.c / on legal definitions of a certain algorithm (Was: Re: **********@b*****.uk)

SubjectAuthor
* ben.usenet@bsb.me.ukArslan RK
+- Re: ben.usenet@bsb.me.ukScott Lurndal
+- Re: ben.usenet@bsb.me.ukLew Pitcher
+- Re: ben.usenet@bsb.me.ukMalcolm McLean
+* Re: ben.usenet@bsb.me.ukBen Bacarisse
|`- Re: ben.usenet@bsb.me.ukChris M. Thomasson
`* Re: **********@b*****.ukKaz Kylheku
 +* Re: **********@b*****.ukRichard Damon
 |`* Re: **********@b*****.ukTim Rentsch
 | `* on legal definitions of a certain algorithm (Was: Re: **********@b*****.uk)Meredith Montgomery
 |  +* Re: on legal definitions of a certain algorithmBen Bacarisse
 |  |`* Re: on legal definitions of a certain algorithmMeredith Montgomery
 |  | +* Re: on legal definitions of a certain algorithmStefan Ram
 |  | |`* Re: on legal definitions of a certain algorithmMeredith Montgomery
 |  | | +- Re: on legal definitions of a certain algorithmStefan Ram
 |  | | `- Re: on legal definitions of a certain algorithmStefan Ram
 |  | `- Re: on legal definitions of a certain algorithmTim Rentsch
 |  `- Re: on legal definitions of a certain algorithmTim Rentsch
 `* Re: **********@b*****.ukMalcolm McLean
  `- This newsgroup (Was: for some totally inexplicable reason, **********@b*****.uk)Kenny McCormack

1
ben.usenet@bsb.me.uk

<c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20015&group=comp.lang.c#20015

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:ca:: with SMTP id p10mr9303631qtw.386.1642442890863;
Mon, 17 Jan 2022 10:08:10 -0800 (PST)
X-Received: by 2002:a05:620a:1587:: with SMTP id d7mr15356853qkk.333.1642442890668;
Mon, 17 Jan 2022 10:08:10 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 17 Jan 2022 10:08:10 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=39.34.186.249; posting-account=tiXKTAoAAADfLFt0WYZT4PMZOBC28zgF
NNTP-Posting-Host: 39.34.186.249
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com>
Subject: ben.usenet@bsb.me.uk
From: itsarsla...@gmail.com (Arslan RK)
Injection-Date: Mon, 17 Jan 2022 18:08:10 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 13
 by: Arslan RK - Mon, 17 Jan 2022 18:08 UTC

I want some help.
if anyone is reading please contact
The bubble sort presented in for large arrays. Make the following simple modifications to
improve
the performance of the bubble sort:
b) The data in the array may already be in the proper order or near-proper order, so why make
nine passes if fewer will
suffice? Modify the sort to check at the end of each pass if any swaps have been made. If none
have been made, then
the data must already be in the proper order, so the program should terminate. If swaps have
been made, then at least
one more pass is needed.
1. Devise an Algorithm
2. Create a program in C++

Re: ben.usenet@bsb.me.uk

<TmiFJ.265383$1d1.86673@fx99.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20016&group=comp.lang.c#20016

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!news.freedyn.de!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx99.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: ben.usenet@bsb.me.uk
Newsgroups: comp.lang.c
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com>
Lines: 17
Message-ID: <TmiFJ.265383$1d1.86673@fx99.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Mon, 17 Jan 2022 18:15:15 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Mon, 17 Jan 2022 18:15:15 GMT
X-Received-Bytes: 1389
 by: Scott Lurndal - Mon, 17 Jan 2022 18:15 UTC

Arslan RK <itsarslanfiverr@gmail.com> writes:
>I want some help.
>if anyone is reading please contact
>The bubble sort presented in for large arrays. Make the following simple modifications to
>improve
>the performance of the bubble sort:
>b) The data in the array may already be in the proper order or near-proper order, so why make
>nine passes if fewer will
>suffice? Modify the sort to check at the end of each pass if any swaps have been made. If none
>have been made, then
>the data must already be in the proper order, so the program should terminate. If swaps have
>been made, then at least
>one more pass is needed.
>1. Devise an Algorithm
>2. Create a program in C++

Sleeping in class, it seems.

Re: ben.usenet@bsb.me.uk

<ss4c8q$qjr$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20017&group=comp.lang.c#20017

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.lang.c
Subject: Re: ben.usenet@bsb.me.uk
Date: Mon, 17 Jan 2022 18:24:26 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <ss4c8q$qjr$1@dont-email.me>
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 17 Jan 2022 18:24:26 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="5d0ae439b535bbc2e0ccfa4c2d936518";
logging-data="27259"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18WIqjebo/pjCEnY1k2AMmoYrGyLCvKXdA="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:ZN5XEn/pjvk4CylRnB3owegKeNA=
 by: Lew Pitcher - Mon, 17 Jan 2022 18:24 UTC

On Mon, 17 Jan 2022 10:08:10 -0800, Arslan RK wrote:

> I want some help.
> if anyone is reading please contact
> The bubble sort presented in for large arrays. Make the following simple modifications to
> improve
> the performance of the bubble sort:
> b) The data in the array may already be in the proper order or near-proper order, so why make
> nine passes if fewer will
> suffice? Modify the sort to check at the end of each pass if any swaps have been made. If none
> have been made, then
> the data must already be in the proper order, so the program should terminate. If swaps have
> been made, then at least
> one more pass is needed.
> 1. Devise an Algorithm
> 2. Create a program in C++

First off, you posted your request to the wrong usenet newsgroup.
This is comp.lang.c, where we discuss programming in the C programming
language. You want a C++ solution, and thus should post your questions
to comp.lang.c++.

If you use google groups to post, you will have difficulty posting to
comp.lang.c++, as the Google interface has glitches that prevent posting
to that newsgroup. If that is the case, then I suggest that you use a
different news source; eternal-september.org, and aioe.org both offer
free usenet access.

Secondly, if you are having problems, we can only help you if you show
us your work. Are you having problems understanding the requirements,
or with your code?

--
Lew Pitcher
"In Skills, We Trust"

Re: ben.usenet@bsb.me.uk

<21938d10-160c-4fea-bb5d-1dfa7d8defb5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20018&group=comp.lang.c#20018

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ad4:4ee6:: with SMTP id dv6mr19075788qvb.77.1642445157648;
Mon, 17 Jan 2022 10:45:57 -0800 (PST)
X-Received: by 2002:a05:620a:a:: with SMTP id j10mr15109433qki.362.1642445157504;
Mon, 17 Jan 2022 10:45:57 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 17 Jan 2022 10:45:57 -0800 (PST)
In-Reply-To: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:4141:499c:1d86:5a90;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:4141:499c:1d86:5a90
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <21938d10-160c-4fea-bb5d-1dfa7d8defb5n@googlegroups.com>
Subject: Re: ben.usenet@bsb.me.uk
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Mon, 17 Jan 2022 18:45:57 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 20
 by: Malcolm McLean - Mon, 17 Jan 2022 18:45 UTC

On Monday, 17 January 2022 at 18:08:20 UTC, itsarsl...@gmail.com wrote:
> I want some help.
> if anyone is reading please contact
> The bubble sort presented in for large arrays. Make the following simple modifications to
> improve
> the performance of the bubble sort:
> b) The data in the array may already be in the proper order or near-proper order, so why make
> nine passes if fewer will
> suffice? Modify the sort to check at the end of each pass if any swaps have been made. If none
> have been made, then
> the data must already be in the proper order, so the program should terminate. If swaps have
> been made, then at least
> one more pass is needed.
> 1. Devise an Algorithm
> 2. Create a program in C++
>
Usenet isn't a free homework doing service, and I hope that no-one will post
a solution you can dishonestly submit as your own work.

If you post an attempt and have some specific question about it, that's
different.

Re: ben.usenet@bsb.me.uk

<874k625bzl.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20019&group=comp.lang.c#20019

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: ben.usenet@bsb.me.uk
Date: Mon, 17 Jan 2022 20:43:58 +0000
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <874k625bzl.fsf@bsb.me.uk>
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="ab704c70d1bdbef5793a106f0a9c6472";
logging-data="32088"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19cgDYOoVRjIt+R03pRqzc+tiiQdL1tyt0="
Cancel-Lock: sha1:DCVoWi8M6PPmGjHtrMSMOugLYnc=
sha1:7AxPAHuFCM3n2O2svxGflfNYyl4=
X-BSB-Auth: 1.572673a66d63a73346f6.20220117204358GMT.874k625bzl.fsf@bsb.me.uk
 by: Ben Bacarisse - Mon, 17 Jan 2022 20:43 UTC

Arslan RK <itsarslanfiverr@gmail.com> writes:

> I want some help.

Why did you start a thread with my email address as the subject line?

--
Ben.

Re: ben.usenet@bsb.me.uk

<ss4p4a$i1r$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20024&group=comp.lang.c#20024

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: ben.usenet@bsb.me.uk
Date: Mon, 17 Jan 2022 14:03:54 -0800
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <ss4p4a$i1r$1@dont-email.me>
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com>
<874k625bzl.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 17 Jan 2022 22:03:55 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="5509059438e41e9808fb87b7d56277f6";
logging-data="18491"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Koe2lMPULrZ9sb0SD2ofpfBwJNol/29A="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:kMWBBe85ACMQ7vllt3iV9SNBt34=
In-Reply-To: <874k625bzl.fsf@bsb.me.uk>
Content-Language: en-US
 by: Chris M. Thomasson - Mon, 17 Jan 2022 22:03 UTC

On 1/17/2022 12:43 PM, Ben Bacarisse wrote:
> Arslan RK <itsarslanfiverr@gmail.com> writes:
>
>> I want some help.
>
> Why did you start a thread with my email address as the subject line?
>

No shit!

Re: **********@b*****.uk

<20220123074300.987@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20117&group=comp.lang.c#20117

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 480-992-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: **********@b*****.uk
Date: Sun, 23 Jan 2022 15:48:34 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <20220123074300.987@kylheku.com>
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com>
Injection-Date: Sun, 23 Jan 2022 15:48:34 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9c2f15a7bc4425d0b88d715f28fed36f";
logging-data="5770"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+r1guVPb+p+JKXTUxuqyJ7ZgAR6ccCzkg="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:SAn4Kt3APTXvX4apVMu9p5tKy+8=
 by: Kaz Kylheku - Sun, 23 Jan 2022 15:48 UTC

On 2022-01-17, Arslan RK <itsarslanfiverr@gmail.com> wrote:
> The data in the array may already be in the proper order or near-proper order, so why make
> nine passes if fewer will
> suffice? Modify the sort to check at the end of each pass if any swaps have been made. If none
> have been made, then
> the data must already be in the proper order, so the program should terminate. If swaps have
> been made, then at least
> one more pass is needed.

Your teacher is an ignoramus, or else you are trolling.

The above termination test is part of the definition of Bubble Sort.

https://en.wikipedia.org/wiki/Bubble_sort

Re: **********@b*****.uk

<YUgHJ.39367$gX.15436@fx40.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20120&group=comp.lang.c#20120

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx40.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.5.0
Subject: Re: **********@b*****.uk
Content-Language: en-US
Newsgroups: comp.lang.c
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com>
<20220123074300.987@kylheku.com>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <20220123074300.987@kylheku.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 31
Message-ID: <YUgHJ.39367$gX.15436@fx40.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 23 Jan 2022 13:13:10 -0500
X-Received-Bytes: 2468
 by: Richard Damon - Sun, 23 Jan 2022 18:13 UTC

On 1/23/22 10:48 AM, Kaz Kylheku wrote:
> On 2022-01-17, Arslan RK <itsarslanfiverr@gmail.com> wrote:
>> The data in the array may already be in the proper order or near-proper order, so why make
>> nine passes if fewer will
>> suffice? Modify the sort to check at the end of each pass if any swaps have been made. If none
>> have been made, then
>> the data must already be in the proper order, so the program should terminate. If swaps have
>> been made, then at least
>> one more pass is needed.
>
> Your teacher is an ignoramus, or else you are trolling.
>
> The above termination test is part of the definition of Bubble Sort.
>
> https://en.wikipedia.org/wiki/Bubble_sort

To my knowledge, there is no official legal definition of Bubble Sort.
The Naive Sort that doesn't test if it is done still falls within what I
would consider the family of 'Bubble Sort'. Checking for no swaps,
decreasing the bounds each loop by one, or to the last swap, are all
fairly standard improvements over the naive bubble sort.

For a class, starting with the simplest version (with not test) and then
showing ways to optimize, becomes a very good learning experience and
gets the students to actually THINK about what is happening rather than
just copy the algorithm.

Then moving on to other improvements, like cocktails sort reversing its
pass each time can lead to a natural discussion of algorithms and
actually designing an algorithm rather than being stuck with ones
someone gives you.

Re: **********@b*****.uk

<cc61e709-6a41-40d6-8d40-cd128304d70dn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20121&group=comp.lang.c#20121

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:6214:1c8a:: with SMTP id ib10mr11881774qvb.126.1642965318828; Sun, 23 Jan 2022 11:15:18 -0800 (PST)
X-Received: by 2002:a37:6985:: with SMTP id e127mr2835617qkc.100.1642965318662; Sun, 23 Jan 2022 11:15:18 -0800 (PST)
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 23 Jan 2022 11:15:18 -0800 (PST)
In-Reply-To: <20220123074300.987@kylheku.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:8896:32d8:b837:4f52; posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:8896:32d8:b837:4f52
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com> <20220123074300.987@kylheku.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cc61e709-6a41-40d6-8d40-cd128304d70dn@googlegroups.com>
Subject: Re: **********@b*****.uk
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Sun, 23 Jan 2022 19:15:18 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 7
 by: Malcolm McLean - Sun, 23 Jan 2022 19:15 UTC

On Sunday, 23 January 2022 at 15:48:47 UTC, Kaz Kylheku wrote:
>
> Your teacher is an ignoramus, or else you are trolling.
>
That claim is commonly made, usually be people who don't
teach. It's necessary to simplify in the early stages of teaching
material. It's seldom the case that the teacher doesn't know that
what he is saying is technically wrong.

This newsgroup (Was: for some totally inexplicable reason, **********@b*****.uk)

<sskcl3$3hrvr$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20122&group=comp.lang.c#20122

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.c
Subject: This newsgroup (Was: for some totally inexplicable reason, **********@b*****.uk)
Date: Sun, 23 Jan 2022 20:09:07 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <sskcl3$3hrvr$1@news.xmission.com>
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com> <20220123074300.987@kylheku.com> <cc61e709-6a41-40d6-8d40-cd128304d70dn@googlegroups.com>
Injection-Date: Sun, 23 Jan 2022 20:09:07 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3731451"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sun, 23 Jan 2022 20:09 UTC

In article <cc61e709-6a41-40d6-8d40-cd128304d70dn@googlegroups.com>,
Malcolm McLean <malcolm.arthur.mclean@gmail.com> wrote:
>On Sunday, 23 January 2022 at 15:48:47 UTC, Kaz Kylheku wrote:
>>
>> Your teacher is an ignoramus, or else you are trolling.
>>
>That claim is commonly made, usually be people who don't
>teach. It's necessary to simplify in the early stages of teaching
>material. It's seldom the case that the teacher doesn't know that
>what he is saying is technically wrong.

That sort of problem - the inability to grasp and practice "lies for
children" - is endemic on this newsgroup.

--
Pensacola - the thinking man's drink.

Re: **********@b*****.uk

<86h79tomko.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20130&group=comp.lang.c#20130

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: **********@b*****.uk
Date: Sun, 23 Jan 2022 19:10:47 -0800
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <86h79tomko.fsf@linuxsc.com>
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com> <20220123074300.987@kylheku.com> <YUgHJ.39367$gX.15436@fx40.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="d742d26243a9575adb46fc0e29496190";
logging-data="742"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191IdfVpcoY+ITDWDnExQcJLsz7Ci+dxDg="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:SO6EDWFXUmvxbBYNpK5gTTHGbZs=
sha1:34k+4o8XLzl8GK414LLmKyW1t2o=
 by: Tim Rentsch - Mon, 24 Jan 2022 03:10 UTC

Richard Damon <Richard@Damon-Family.org> writes:

> On 1/23/22 10:48 AM, Kaz Kylheku wrote:
>
>> On 2022-01-17, Arslan RK <itsarslanfiverr@gmail.com> wrote:
>>
>>> The data in the array may already be in the proper order or
>>> near-proper order, so why make nine passes if fewer will suffice?
>>> Modify the sort to check at the end of each pass if any swaps have
>>> been made. If none have been made, then the data must already be
>>> in the proper order, so the program should terminate. If swaps
>>> have been made, then at least one more pass is needed.
>>
>> Your teacher is an ignoramus, or else you are trolling.
>>
>> The above termination test is part of the definition of Bubble Sort.
>>
>> https://en.wikipedia.org/wiki/Bubble_sort
>
> To my knowledge, there is no official legal definition of Bubble
> Sort. The Naive Sort that doesn't test if it is done still falls
> within what I would consider the family of 'Bubble Sort'. Checking
> for no swaps, decreasing the bounds each loop by one, or to the last
> swap, are all fairly standard improvements over the naive bubble
> sort.
>
> For a class, starting with the simplest version (with not test)
> and then showing ways to optimize, becomes a very good learning
> experience and gets the students to actually THINK about what is
> happening rather than just copy the algorithm.
>
> Then moving on to other improvements, like cocktails sort reversing
> its pass each time can lead to a natural discussion of algorithms
> and actually designing an algorithm rather than being stuck with
> ones someone gives you.

I agree on all points. Any algorithm that does repeated swapping
scans may reasonably be called a bubble sort, even the horribly
naive algorithm that starts again from the bottom whenver an out
of order pair is found (and so typically has O( n*n*n ) runtime).
One nice property of bubble sort from an educational perspective
is that, because it is so simple, there are lots of obvious
refinements to try. Furthermore all the obvious refinements are
still pretty bad performance-wise, which serves as a springboard
into more elaborate but better performing algorithms.

on legal definitions of a certain algorithm (Was: Re: **********@b*****.uk)

<86sft55qgd.fsf_-_@levado.to>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20297&group=comp.lang.c#20297

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!swDOntj3lPshdK/dkw97wQ.user.46.165.242.75.POSTED!not-for-mail
From: mmontgom...@levado.to (Meredith Montgomery)
Newsgroups: comp.lang.c
Subject: on legal definitions of a certain algorithm (Was: Re: **********@b*****.uk)
Date: Sun, 30 Jan 2022 10:00:02 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86sft55qgd.fsf_-_@levado.to>
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com>
<20220123074300.987@kylheku.com> <YUgHJ.39367$gX.15436@fx40.iad>
<86h79tomko.fsf@linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="30005"; posting-host="swDOntj3lPshdK/dkw97wQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
Cancel-Lock: sha1:HWYgUdfObwzc3Q8nY1RA5JmVeUc=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Meredith Montgomery - Sun, 30 Jan 2022 13:00 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:

> Richard Damon <Richard@Damon-Family.org> writes:
>> On 1/23/22 10:48 AM, Kaz Kylheku wrote:

[...]

>>> Your teacher is an ignoramus, or else you are trolling.
>>>
>>> The above termination test is part of the definition of Bubble Sort.
>>>
>>> https://en.wikipedia.org/wiki/Bubble_sort
>>
>> To my knowledge, there is no official legal definition of Bubble
>> Sort.

[...]

> I agree on all points. Any algorithm that does repeated swapping
> scans may reasonably be called a bubble sort, even the horribly
> naive algorithm that starts again from the bottom whenver an out
> of order pair is found (and so typically has O( n*n*n ) runtime).

[...]

This thread is reminding me of an event I went through once. I took a
data structures course once and there was a written test that asked me
to sort a list of numbers using quicksort. The question was totally
vague like that. Sort [a, b, c, d, e] using quicksort.

How did I do it? First I determined that I was going to use a random
number generator that was myself --- I chose the pivot-elements so as to
keep the number of iterations in the algorithm smallest. (I thought I
was being elegant that way.) Then using a functional implementation of
quicksort in my head --- my favorite ones --- I explained the steps I
took and how the list was sorted.

I was marked completely off because what I was using ``was not
quicksort''. Then the question became what is quicksort. Effectively
the teacher claimed quicksort is some imperative implementation of the
method that runs in O(n log n) on the average case. (No publication was
offered to back up this claim.)

Upon the teacher's own request, I uselessly showed him various important
publications that called various versions of quicksort as ``quicksort''
--- all of which were totally compatiable with my step by step
illustration of how I sorted the list showed on the test --- without any
sort of footnote-remark to the effect that they were abusing language or
something like that. (Also by his own request, I implemented in the C
language the version I described on the test. For the curious, no, I
did not get any points for the question, despite showing how I could
implemented the strategy in more than one way in the language
requested.)

I came out of that experience with the conclusion that one cannot
identify an algorithm with a runtime class. A functional language is
able to imitate an imperative one with a maximum loss of O(ln n) steps.
For example, given an algorithm that runs in O(n) time, the same
algorithm can be implemented in a functional machine in time O(n ln n).
That's theorem 3.1 of the following paper.

--8<---------------cut here---------------start------------->8---
Nicholas Pippenger. “Pure versus impure Lisp”. Em: ACM Transactions on
Programming Languages and Systems (TOPLAS) 19.2 (1997), pp. 223–238.
--8<---------------cut here---------------end--------------->8---

In the context of where we were --- English-language descriptions of
algorithms ---, there was no possibility for the distinction of
algorithms by way of their expressions. Not even the typical
programming language is able to do that, much less English. The paper
below makes that point.

--8<---------------cut here---------------start------------->8---
Andreas Blass, Nachum Dershowitz e Yuri Gurevich. “When are two
algorithms the same?” Em: Bulletin of Symbolic Logic 15.2 (2009),
pp. 145–168.
--8<---------------cut here---------------end--------------->8---

I'll appreciate hearing what you guys have to say about any of this.

Re: on legal definitions of a certain algorithm

<87sft4di1w.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20306&group=comp.lang.c#20306

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: on legal definitions of a certain algorithm
Date: Sun, 30 Jan 2022 21:34:19 +0000
Organization: A noiseless patient Spider
Lines: 87
Message-ID: <87sft4di1w.fsf@bsb.me.uk>
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com>
<20220123074300.987@kylheku.com> <YUgHJ.39367$gX.15436@fx40.iad>
<86h79tomko.fsf@linuxsc.com> <86sft55qgd.fsf_-_@levado.to>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="1dbc8256201ba2e23e0efb476fdd0bff";
logging-data="2046"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/c0Cjh1pr5RQePbgh6Zq3ALxeKEh/4mdA="
Cancel-Lock: sha1:ZJZJRadEBXOtkZBYvWZtVFCCDls=
sha1:sNB3CFZ9sXs31Zyz9HYzJs5LoRA=
X-BSB-Auth: 1.b83f36409e3ec8b40e0d.20220130213419GMT.87sft4di1w.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 30 Jan 2022 21:34 UTC

Meredith Montgomery <mmontgomery@levado.to> writes:

> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>
>> Richard Damon <Richard@Damon-Family.org> writes:
>>> On 1/23/22 10:48 AM, Kaz Kylheku wrote:
>
> [...]
>
>>>> Your teacher is an ignoramus, or else you are trolling.
>>>>
>>>> The above termination test is part of the definition of Bubble Sort.
>>>>
>>>> https://en.wikipedia.org/wiki/Bubble_sort
>>>
>>> To my knowledge, there is no official legal definition of Bubble
>>> Sort.
>
> [...]
>
>> I agree on all points. Any algorithm that does repeated swapping
>> scans may reasonably be called a bubble sort, even the horribly
>> naive algorithm that starts again from the bottom whenver an out
>> of order pair is found (and so typically has O( n*n*n ) runtime).
>
> [...]
>
> This thread is reminding me of an event I went through once. I took a
> data structures course once and there was a written test that asked me
> to sort a list of numbers using quicksort. The question was totally
> vague like that. Sort [a, b, c, d, e] using quicksort.
>
> How did I do it? First I determined that I was going to use a random
> number generator that was myself --- I chose the pivot-elements so as to
> keep the number of iterations in the algorithm smallest. (I thought I
> was being elegant that way.) Then using a functional implementation of
> quicksort in my head --- my favorite ones --- I explained the steps I
> took and how the list was sorted.

Can you sketch the algorithm you used? I know it's some time ago but I
don't follow what you are saying. Are you saying that you choose pivot
elements very much not at random, but so as to minimise the work? That
brings another algorithm into play that is not usually part of a
quicksort.

> I was marked completely off because what I was using ``was not
> quicksort''. Then the question became what is quicksort. Effectively
> the teacher claimed quicksort is some imperative implementation of the
> method that runs in O(n log n) on the average case. (No publication was
> offered to back up this claim.)

Well the O(n log n) bit is not in dispute is it? Are you saying that
the teacher insisted that quicksort must /not/ be written recursively?
Are you sure you understood?

As a former teacher, I feel somewhat obliged to defend this poor man!
It's certainly possible that he was so ignorant that he thought
quicksort -- one of the most iconic recursive algorithms -- must be
written without recursion, but it seems a stretch, especially as
quicksort is hard to write that way. You can loop over one "half" of
the recursion, but doing that for both is much more work.

> Upon the teacher's own request, I uselessly showed him various important
> publications that called various versions of quicksort as ``quicksort''
> --- all of which were totally compatiable with my step by step
> illustration of how I sorted the list showed on the test --- without any
> sort of footnote-remark to the effect that they were abusing language or
> something like that. (Also by his own request, I implemented in the C
> language the version I described on the test. For the curious, no, I
> did not get any points for the question, despite showing how I could
> implemented the strategy in more than one way in the language
> requested.)

Was a model answer even presented? Did you get to find out how he
thought quicksort /should/ look? I'd love to see it!

> I came out of that experience with the conclusion that one cannot
> identify an algorithm with a runtime class.

Hmm.. what's the runtime class got to do with it? That quicksort "is"
O(n log n) on average (albeit a slightly tricky thing to pin down) was
not in dispute here, was it? If your algorithm wasn't O(n log n), on
average, then I can see your teacher might have some legitimate
concerns.

--
Ben.

Re: on legal definitions of a certain algorithm

<868ruw1vmh.fsf@levado.to>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20307&group=comp.lang.c#20307

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!swDOntj3lPshdK/dkw97wQ.user.46.165.242.75.POSTED!not-for-mail
From: mmontgom...@levado.to (Meredith Montgomery)
Newsgroups: comp.lang.c
Subject: Re: on legal definitions of a certain algorithm
Date: Sun, 30 Jan 2022 23:34:14 -0300
Organization: Aioe.org NNTP Server
Message-ID: <868ruw1vmh.fsf@levado.to>
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com>
<20220123074300.987@kylheku.com> <YUgHJ.39367$gX.15436@fx40.iad>
<86h79tomko.fsf@linuxsc.com> <86sft55qgd.fsf_-_@levado.to>
<87sft4di1w.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="7723"; posting-host="swDOntj3lPshdK/dkw97wQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:ZoJrPYX98EKaA3/wEK2emiLxuXw=
 by: Meredith Montgomery - Mon, 31 Jan 2022 02:34 UTC

Ben Bacarisse <ben.usenet@bsb.me.uk> writes:

> Meredith Montgomery <mmontgomery@levado.to> writes:
>
>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>
>>> Richard Damon <Richard@Damon-Family.org> writes:
>>>> On 1/23/22 10:48 AM, Kaz Kylheku wrote:
>>
>> [...]
>>
>>>>> Your teacher is an ignoramus, or else you are trolling.
>>>>>
>>>>> The above termination test is part of the definition of Bubble Sort.
>>>>>
>>>>> https://en.wikipedia.org/wiki/Bubble_sort
>>>>
>>>> To my knowledge, there is no official legal definition of Bubble
>>>> Sort.
>>
>> [...]
>>
>>> I agree on all points. Any algorithm that does repeated swapping
>>> scans may reasonably be called a bubble sort, even the horribly
>>> naive algorithm that starts again from the bottom whenver an out
>>> of order pair is found (and so typically has O( n*n*n ) runtime).
>>
>> [...]
>>
>> This thread is reminding me of an event I went through once. I took a
>> data structures course once and there was a written test that asked me
>> to sort a list of numbers using quicksort. The question was totally
>> vague like that. Sort [a, b, c, d, e] using quicksort.
>>
>> How did I do it? First I determined that I was going to use a random
>> number generator that was myself --- I chose the pivot-elements so as to
>> keep the number of iterations in the algorithm smallest. (I thought I
>> was being elegant that way.) Then using a functional implementation of
>> quicksort in my head --- my favorite ones --- I explained the steps I
>> took and how the list was sorted.
>
> Can you sketch the algorithm you used?

I used exactly this one. This is Racket syntax. (I'm sure you can see
the meaning the procedure /random-element-of/. And, of course, to sort
a list using such algorithm I will have to be the random generator
myself. I wasn't going to flip coins during the test.)

(define (qsort ls)
(cond [(empty? ls) empty]
[else
(let ([pivot (random-element-of ls)])
(append (qsort (smaller pivot ls))
(list pivot)
(qsort (greater pivot ls))))]))

(define (make-filter cmp)
(lambda (pivot ls)
(cond [(empty? ls) empty]
[else
(filter (lambda (x) (cmp x pivot)) ls)])))

(define smaller (make-filter <))
(define greater (make-filter >))

> I know it's some time ago but I don't follow what you are saying. Are
> you saying that you choose pivot elements very much not at random, but
> so as to minimise the work? That brings another algorithm into play
> that is not usually part of a quicksort.

Yes. I chose the numbers myself. This was not his issue at all. I had
to ``run an algorithm on paper'', so I had to somehow choose pivot
elements. I could have chosen always the first element or always the
last. I decided to choose it ``at random''. It was a paper test, so
shortening the answer was definitely an elegant thing to do. (It was an
illustration that I knew what I was doing --- because I knew the choices
that minimized the number of steps.)

His problem was the algorithm I followed was a functional one and the he
apparently was unable to accept that could be called quicksort. His
final argument was that the complexity was not the same --- that was his
evidence that what I executed was not quicksort.

>> I was marked completely off because what I was using ``was not
>> quicksort''. Then the question became what is quicksort. Effectively
>> the teacher claimed quicksort is some imperative implementation of the
>> method that runs in O(n log n) on the average case. (No publication was
>> offered to back up this claim.)
>
> Well the O(n log n) bit is not in dispute is it? Are you saying that
> the teacher insisted that quicksort must /not/ be written recursively?

Recursion was not the problem. The problem is that that version above
is not O(n log n) because the sorting is not in-place.

> Are you sure you understood?

I would never claim I'm sure about understanding someone like that. He
demanded I showed how to write the algorithm and show references of
other people saying it was quicksort and so on. I showed a few serious
publications calling it quicksort. (I still have those references.) I
did not demand anything of him. I take no pleasure in seeing people not
able to explain themselves. It was clear he was not well informed on
the subject.

What he was looking for was the algorithm below --- or something very
close to this. He did not want anyone to write the method down; he
wanted students to just sort a list of numbers.

This is Python, so let A be a list so that the sorting happens
/in-place/.

def qsort(A, lo, hi):
if lo < hi:
p = partition(A, lo, hi)
qsort(A, lo, p)
qsort(A, p + 1, hi)
return A

def partition(A, lo, hi):
pivot = A[lo]
i = lo - 1
j = hi + 1
while True:
while True:
i = i + 1
if A[i] >= pivot:
break
while True:
j = j - 1
if A[j] <= pivot:
break
if i >= j:
return j
A[i], A[j] = A[j], A[i]

> As a former teacher, I feel somewhat obliged to defend this poor man!

He needs an exceptional defense!

> It's certainly possible that he was so ignorant that he thought
> quicksort -- one of the most iconic recursive algorithms -- must be
> written without recursion, but it seems a stretch, especially as
> quicksort is hard to write that way. You can loop over one "half" of
> the recursion, but doing that for both is much more work.

I had a feeling his problem was with functional programming. He seemed
to think it was impossible to call anything quicksort that did not sort
in place.

>> Upon the teacher's own request, I uselessly showed him various important
>> publications that called various versions of quicksort as ``quicksort''
>> --- all of which were totally compatiable with my step by step
>> illustration of how I sorted the list showed on the test --- without any
>> sort of footnote-remark to the effect that they were abusing language or
>> something like that. (Also by his own request, I implemented in the C
>> language the version I described on the test. For the curious, no, I
>> did not get any points for the question, despite showing how I could
>> implemented the strategy in more than one way in the language
>> requested.)
>
> Was a model answer even presented?

Yes. On the board I remember seeing various lines with numbers written
horizontally, clearly showing that he was thinking of an in-place
sorting. Each line was an iteration.

> Did you get to find out how he thought quicksort /should/ look? I'd
> love to see it!

Yes, that version above would be what he would have in mind. I
understood he had one version of quicksort in mind and it had to be that
one he had in mind.

>> I came out of that experience with the conclusion that one cannot
>> identify an algorithm with a runtime class.
>
> Hmm.. what's the runtime class got to do with it?

Nothing. He was the one that said --- this is not O(n log n) and so I
can't accept it.

> That quicksort "is" O(n log n) on average (albeit a slightly tricky
> thing to pin down) was not in dispute here, was it? If your algorithm
> wasn't O(n log n), on average, then I can see your teacher might have
> some legitimate concerns.

I don't know the O-expression of the complexity of that Racket qsort
procedure above. I think I'd have to look up the master theorem to try
to tell it. I bet you can apply the theorem from the top of your mind.
If it is not O(n log n), then that was the teacher's argument.

Re: on legal definitions of a certain algorithm

<quicksort-20220131041344@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20308&group=comp.lang.c#20308

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.c
Subject: Re: on legal definitions of a certain algorithm
Date: 31 Jan 2022 03:14:08 GMT
Organization: Stefan Ram
Lines: 46
Expires: 1 Apr 2022 11:59:58 GMT
Message-ID: <quicksort-20220131041344@ram.dialup.fu-berlin.de>
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com> <20220123074300.987@kylheku.com> <YUgHJ.39367$gX.15436@fx40.iad> <86h79tomko.fsf@linuxsc.com> <86sft55qgd.fsf_-_@levado.to> <87sft4di1w.fsf@bsb.me.uk> <868ruw1vmh.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de cjJ3UIg9PaKtiDZyt8V66gYESqqJFG/gX0jG5GfSYESc7h
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Mon, 31 Jan 2022 03:14 UTC

Meredith Montgomery <mmontgomery@levado.to> writes:
> while True:
> while True:
> i = i + 1
> if A[i] >= pivot:
> break

I'm not sure whether, in Python, this loop will ever exit!

>I had a feeling his problem was with functional programming. He seemed
>to think it was impossible to call anything quicksort that did not sort
>in place.

I wrote this quicksort that's not only functional, but also visual:

.--------------------------------------------.
| .---------------. |
| | .----. | |
| | ->| | | |
.-------. | | | <= | -> | |
[] --->| qsort |---> [] | | x ->| | | |
'-------' | | '----' | |
| '---------------' |
| | |
| v .---. |
| .------. .-------. | | |
..---------------. | xs -->| grep | ->| qsort | --->| | |
| .---. | | '------' '-------' | j | |
| x -->| | | .-------. | .------. | o | |
| | : | -> |-->| qsort | ->| x --->| list | --------------->| i | --> |
| xs ->| | | '-------' | '------' | n | |
| '___' | | .------. .-------. | | |
'---------------' | xs -->| grep | ->| qsort | --->| | |
| '------' '-------' | | |
| ^ '---' |
| | |
| .---------------. |
| | .----. | |
| | x ->| | | |
| | | < | -> | |
| | ->| | | |
| | '----' | |
| '---------------' |
'--------------------------------------------'

Re: on legal definitions of a certain algorithm

<865yq0mrga.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20309&group=comp.lang.c#20309

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: on legal definitions of a certain algorithm
Date: Sun, 30 Jan 2022 20:58:45 -0800
Organization: A noiseless patient Spider
Lines: 80
Message-ID: <865yq0mrga.fsf@linuxsc.com>
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com> <20220123074300.987@kylheku.com> <YUgHJ.39367$gX.15436@fx40.iad> <86h79tomko.fsf@linuxsc.com> <86sft55qgd.fsf_-_@levado.to> <87sft4di1w.fsf@bsb.me.uk> <868ruw1vmh.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="5204caba212f86213f2db7ab16b145f8";
logging-data="23662"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+3Jo6hsMMBKAFy8m5ysRdzGwUM/ye24Lg="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:zaR27c2NVeuqnmn7BTu1zu8NUBs=
sha1:RgJU372wzMxUH2qct8GZmhn1Zho=
 by: Tim Rentsch - Mon, 31 Jan 2022 04:58 UTC

Meredith Montgomery <mmontgomery@levado.to> writes:

> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>
>> Meredith Montgomery <mmontgomery@levado.to> writes:
>>
>>>> ["what algorithms may be called bubblesort?"]
>>>
>>> This thread is reminding me of an event I went through once. I
>>> took a data structures course once and there was a written test
>>> that asked me to sort a list of numbers using quicksort. The
>>> question was totally vague like that. Sort [a, b, c, d, e] using
>>> quicksort.
>>>
>>> How did I do it? First I determined that I was going to use a
>>> random number generator that was myself --- I chose the
>>> pivot-elements so as to keep the number of iterations in the
>>> algorithm smallest. (I thought I was being elegant that way.)
>>> Then using a functional implementation of quicksort in my head ---
>>> my favorite ones --- I explained the steps I took and how the list
>>> was sorted.
>>
>> Can you sketch the algorithm you used?
>
> I used exactly this one. This is Racket syntax. (I'm sure you
> can see the meaning the procedure /random-element-of/. And, of
> course, to sort a list using such algorithm I will have to be the
> random generator myself. I wasn't going to flip coins during the
> test.)
>
> (define (qsort ls)
> (cond [(empty? ls) empty]
> [else
> (let ([pivot (random-element-of ls)])
> (append (qsort (smaller pivot ls))
> (list pivot)
> (qsort (greater pivot ls))))]))
>
> (define (make-filter cmp)
> (lambda (pivot ls)
> (cond [(empty? ls) empty]
> [else
> (filter (lambda (x) (cmp x pivot)) ls)])))
>
> (define smaller (make-filter <))
> (define greater (make-filter >))

Problem: what does your algorithm produce if asked to evaluate
an example such as

(qsort (list 5 5 5 5 5 5 5 5 5))

Disclaimer: I am guessing at syntax, I don't know Racket.

> [...]
>
> His problem was the algorithm I followed was a functional one
> and the he apparently was unable to accept that could be called
> quicksort. His final argument was that the complexity was not
> the same --- that was his evidence that what I executed was not
> quicksort.
>
> [...]
>
> Recursion was not the problem. The problem is that that version
> above is not O(n log n) because the sorting is not in-place.

A bad argument and a bad conclusion. First a sorting algorithm
doesn't have to be an in-place algorithm to have O( n log n )
average case behavior (or even worst case behavior for that
matter). Second, after correcting for the problem shown above,
and making reasonable assumptions for 'filter' and 'append', the
algorithm shown has the same big-O behavior as an in-place
quicksort. (There may be a constant factor between them but
that doesn't affect big-O.) Can you see why?

Disclaimer: again, I don't know Racket. It's possible Racket
has some sort of non-linear behavior in places where that isn't
necessary, but that doesn't happen if Racket is "Lisp-ish",
which I am assuming it is.

Re: on legal definitions of a certain algorithm

<861r0omr62.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20310&group=comp.lang.c#20310

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: on legal definitions of a certain algorithm
Date: Sun, 30 Jan 2022 21:04:53 -0800
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <861r0omr62.fsf@linuxsc.com>
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com> <20220123074300.987@kylheku.com> <YUgHJ.39367$gX.15436@fx40.iad> <86h79tomko.fsf@linuxsc.com> <86sft55qgd.fsf_-_@levado.to>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="5204caba212f86213f2db7ab16b145f8";
logging-data="23662"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ClWQLEzf1uXBNu0+t54WedP9Zhppdepw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:COWgequvEr4Uw7yfcTL1sA4dm7w=
sha1:MHA+dsdt5rn634krHT/Lm6Lj+xU=
 by: Tim Rentsch - Mon, 31 Jan 2022 05:04 UTC

Meredith Montgomery <mmontgomery@levado.to> writes:

> [...]
>
> I'll appreciate hearing what you guys have to say about any of
> this.

If you don't mind a suggestion, I think it would be helpful if
you would put less effort into acquiring knowledge, and more into
gaining understanding.

Re: on legal definitions of a certain algorithm

<86czk59x5s.fsf@levado.to>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20315&group=comp.lang.c#20315

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!PdxfHDVExCx5BRYlwbJcbA.user.46.165.242.91.POSTED!not-for-mail
From: mmontgom...@levado.to (Meredith Montgomery)
Newsgroups: comp.lang.c
Subject: Re: on legal definitions of a certain algorithm
Date: Wed, 02 Feb 2022 11:10:39 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86czk59x5s.fsf@levado.to>
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com>
<20220123074300.987@kylheku.com> <YUgHJ.39367$gX.15436@fx40.iad>
<86h79tomko.fsf@linuxsc.com> <86sft55qgd.fsf_-_@levado.to>
<87sft4di1w.fsf@bsb.me.uk> <868ruw1vmh.fsf@levado.to>
<quicksort-20220131041344@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="8636"; posting-host="PdxfHDVExCx5BRYlwbJcbA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:I0VRYSinSxGXMRuWPTAl7cMRj9Y=
 by: Meredith Montgomery - Wed, 2 Feb 2022 14:10 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:

> Meredith Montgomery <mmontgomery@levado.to> writes:
>> while True:
>> while True:
>> i = i + 1
>> if A[i] >= pivot:
>> break
>
> I'm not sure whether, in Python, this loop will ever exit!

It won't. I messed up the indentation. Here it is again.

--8<---------------cut here---------------start------------->8---
def qsort(A, lo, hi):
if lo < hi:
p = partition(A, lo, hi)
qsort(A, lo, p)
qsort(A, p + 1, hi)
return A

def partition(A, lo, hi):
pivot = A[lo]
i = lo - 1
j = hi + 1
while True:
while True:
i = i + 1
if A[i] >= pivot:
break
while True:
j = j - 1
if A[j] <= pivot:
break
if i >= j:
return j
A[i], A[j] = A[j], A[i]
--8<---------------cut here---------------end--------------->8---

>>I had a feeling his problem was with functional programming. He seemed
>>to think it was impossible to call anything quicksort that did not sort
>>in place.
>
> I wrote this quicksort that's not only functional, but also visual:

Beautiful! But is it ``quicksort''?

>
> .--------------------------------------------.
> | .---------------. |
> | | .----. | |
> | | ->| | | |
> .-------. | | | <= | -> | |
> [] --->| qsort |---> [] | | x ->| | | |
> '-------' | | '----' | |
> | '---------------' |
> | | |
> | v .---. |
> | .------. .-------. | | |
> .---------------. | xs -->| grep | ->| qsort | --->| | |
> | .---. | | '------' '-------' | j | |
> | x -->| | | .-------. | .------. | o | |
> | | : | -> |-->| qsort | ->| x --->| list | --------------->| i | --> |
> | xs ->| | | '-------' | '------' | n | |
> | '___' | | .------. .-------. | | |
> '---------------' | xs -->| grep | ->| qsort | --->| | |
> | '------' '-------' | | |
> | ^ '---' |
> | | |
> | .---------------. |
> | | .----. | |
> | | x ->| | | |
> | | | < | -> | |
> | | ->| | | |
> | | '----' | |
> | '---------------' |
> '--------------------------------------------'

Re: on legal definitions of a certain algorithm

<quicksort-20220202192332@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20316&group=comp.lang.c#20316

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.c
Subject: Re: on legal definitions of a certain algorithm
Date: 2 Feb 2022 18:27:13 GMT
Organization: Stefan Ram
Lines: 16
Expires: 1 Apr 2022 11:59:58 GMT
Message-ID: <quicksort-20220202192332@ram.dialup.fu-berlin.de>
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com> <20220123074300.987@kylheku.com> <YUgHJ.39367$gX.15436@fx40.iad> <86h79tomko.fsf@linuxsc.com> <86sft55qgd.fsf_-_@levado.to> <87sft4di1w.fsf@bsb.me.uk> <868ruw1vmh.fsf@levado.to> <quicksort-20220131041344@ram.dialup.fu-berlin.de> <86czk59x5s.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de ZSR6dOaTBZpyElpCVaSMsw6V6ehlcQP5dGpHiEiOsDVvyI
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Wed, 2 Feb 2022 18:27 UTC

Meredith Montgomery <mmontgomery@levado.to> writes:
>Beautiful! But is it ``quicksort''?

This is a question of the definition of a term.
In mathematics and theoretical computer science,
each author is free to define his terms as he wishes.

The ISO and the INCITS both define several terms of
computer science, but AFAIK not "quicksort".

As far as the use of the term in the general language
is concerned, the definition of Wikipedia might give an
orientation. In it, the very first sentence reads:
"Quicksort is an in-place sorting algorithm.".

Re: on legal definitions of a certain algorithm

<quicksort-20220202193049@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20317&group=comp.lang.c#20317

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.c
Subject: Re: on legal definitions of a certain algorithm
Supersedes: <quicksort-20220202192332@ram.dialup.fu-berlin.de>
Date: 2 Feb 2022 18:33:44 GMT
Organization: Stefan Ram
Lines: 19
Expires: 1 Apr 2022 11:59:58 GMT
Message-ID: <quicksort-20220202193049@ram.dialup.fu-berlin.de>
References: <c4a6e92b-c7e3-46bf-9356-55b402eabc4bn@googlegroups.com> <20220123074300.987@kylheku.com> <YUgHJ.39367$gX.15436@fx40.iad> <86h79tomko.fsf@linuxsc.com> <86sft55qgd.fsf_-_@levado.to> <87sft4di1w.fsf@bsb.me.uk> <868ruw1vmh.fsf@levado.to> <quicksort-20220131041344@ram.dialup.fu-berlin.de> <86czk59x5s.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 0nnQcEXRjBYiQjQHZAfm7QjTLKsgeFWZaa7O7UNGzcM9aA
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Wed, 2 Feb 2022 18:33 UTC

Supersedes: <quicksort-20220202192332@ram.dialup.fu-berlin.de>
[removed article "the" from "ISO" and "INCITS"]

Meredith Montgomery <mmontgomery@levado.to> writes:
>Beautiful! But is it ``quicksort''?

This is a question of the definition of a term.
In mathematics and theoretical computer science,
each author is free to define his terms as he wishes.

ISO and INCITS both define several terms of
computer science, but AFAIK not "quicksort".

As far as the use of the term in the general language
is concerned, the definition of Wikipedia might give an
orientation. In it, the very first sentence reads:
"Quicksort is an in-place sorting algorithm.".

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor