Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!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 20:52:56 -0500 Message-ID: <4FD943F9.567C@mindspring.com> Date: Wed, 13 Jun 2012 21:52:57 -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=us-ascii Content-Transfer-Encoding: 7bit Lines: 72 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.219.149 X-Trace: sv3-GWe0vTn1bTRqtZhREdPpabABJsjb1VXvr95vEGrWO/BoMZLS6ldUTcZyps1coQ+33+CSpnXAYdkNmX/!ER2JcqZptsphZ2Dg2TXLvPn5kW8pS+nt4wEgVa0z2reL1tfU8tHg4XyEQutdwglNNnksJTfWAoeP!LHfm1iwa7bA= 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: 2994 Xref: csiph.com comp.lang.c:22240 pete wrote: > > 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; > } After looking at it more closley, I think that I may have been wrong, but please check it anyway. Thank you. -- pete