Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 01 Sep 2011 21:29:37 -0500 Message-ID: <4E603F93.19F@mindspring.com> Date: Thu, 01 Sep 2011 22:29:39 -0400 From: pete Reply-To: pfiland@mindspring.com Organization: PF X-Mailer: Mozilla 3.04Gold (WinNT; I) MIME-Version: 1.0 Newsgroups: comp.lang.c Subject: Re: My latest magnum opus! References: <4E60142A.575D@mindspring.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 28 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.218.232 X-Trace: sv3-kdttoLTwn+4lN88+ZTxUGhzQWW0EI8yzFmA4eg3WOXzC4azAeWb2z8r3GwD3V8VG/6p1jvmngRWhYNp!FGxOkZ41GGjaJ0RRWP/N1iSgLNbQCIB5FAg9It2UYsrIw7LXfdr3xiAbqehEGrvqNMcVexV4XZo0!z/MsJvSmCw== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2090 Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:9862 Eric Sosman wrote: > > On 9/1/2011 7:24 PM, pete wrote: > > /* BEGIN block_swap_test.c */ > > [...] > > Jon Bentley tackled this problem in one of his "Programming > Pearls" columns in CACM, years and years ago. IIRC, he reported > that he had seen manymanymany attempts to solve it "efficiently" > with clever analysis of which block was the larger, and by how much, > and so on and so forth. He also reported that every such solution > he'd seen was either bug-ridden or actually slower than > > Given an array A...FR...Z, to arrive at R...ZA...F: > Reverse the A...F sequence byte for byte > Reverse the R...Z sequence byte for byte > Reverse the entire array byte for byte > > I have not examined your code closely -- in truth, I have not > even examined it cursorily. The very fact that it's longer than > Bentley's solution tells me it's almost certainly inferior; Bentley's > is certainly easier to analyze for correctness. I'll look into it. Thank you. -- pete