Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.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: Wed, 13 Jun 2012 23:04:46 -0500 Message-ID: <4FD962DD.7243@mindspring.com> Date: Thu, 14 Jun 2012 00:04:45 -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: Open letter to Ian Collins References: <4FD93D9B.7012@mindspring.com> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Lines: 97 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.220.162 X-Trace: sv3-A4Kkhsg7Koaa6mBjn2bpqgCxJwHVLM9ImR7EQGrctY6lyjQS7wAIqOHzIv3zdCrw+YWHfVZpCEW/u6k!C709OA/YWvpGbzs10O5jTd+pv4IiC34I6A2R0SQp41T+52/QkTcZ5GH6new+kbx0lYsgf9j5O8ND!LMu/A7whqJ4= 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: 3613 Xref: csiph.com comp.lang.c:22245 jacob navia wrote: > > Le 14/06/12 03:25, pete a écrit : > > Ian Collins wrote: > >> > > /* > > ** Would you please run this program > > ** and let me know what the output is? > > ** I'm of the opinion that the QSORT function > > ** which is currently in listgen.c, at > > ** http://code.google.com/p/ccl/downloads/detail?name=ccl.zip&can=2&q= > > ** has approximately zero chance of correctly sorting > > ** a data set of as many as 10000000 psuedorandom keys. > > */ > > #include > > > > #include "containers.h" > > #include "intlist.h" > > > > #define N 10000000 > > > > int > > main(void) > > { > > intList *L1; > > size_t i; > > int d; > > long unsigned sum=0,newSum=0; > > Iterator *it; > > int *pint, last_pint; > > > > L1 = iintList.Create(sizeof(int)); > > iintList.UseHeap(L1,NULL); // Use specialized Heap > > // Add N random numbers to the integer list > > for (i=0; i > d = rand(); > > sum += d; > > iintList.Add(L1,d); > > } > > // Sort it > > iintList.Sort(L1); > > // Go through the sorted list using an iterator > > it = iintList.NewIterator(L1); > > i=0; > > pint = it->GetFirst(it); > > while (pint != NULL) { > > last_pint = *pint; > > newSum += last_pint; > > pint = it->GetNext(it); > > if (pint != NULL&& last_pint> *pint) { > > puts("\n\nThe data is not sorted.\n\n"); > > iintList.Finalize(L1); > > exit(EXIT_SUCCESS); > > } > > } > > // Verify that both sums are identical > > if (sum != newSum) { > > printf("Failed\n"); > > } else { > > printf("Sum = %lu\n",sum); > > } > > // Destroy the list > > iintList.Finalize(L1); > > return 0; > > } > > > > Hi Pete > > The output is: > Sum = 10737818730605039 > > Maybe because I incorporated the > changes you proposed to the quick sort > template after the last discussion. > > You get another output? No. I misread the code. Where I saw swap(lo, higuy); I mistakenly thought instead that it was swap(loguy, higuy); > Have you tried with the latest sources? No. > Thanks for your help. You're welcome and I'm sorry about the misunderstanding. -- pete