Talk:Algorithm Implementation/Sorting/Counting sort

Transwiki from English Wikipedia
This page was created with content from Counting Sort.

Article history
* (cur) (last) 15:13, 14 September 2006 Booyabazooka (Talk | contribs) (transwiki code to wikibooks) * (cur) (last) 02:39, 14 September 2006 Torsten Will (Talk | contribs) (removed Basic implementation, does not contribute to Algorithm understanding, makes page too long, see http://en.wikipedia.org/w/index.php?title=Counting_sort&oldid=37075790) * (cur) (last) 02:22, 14 September 2006 Torsten Will (Talk | contribs) m (→Python) * (cur) (last) 02:18, 14 September 2006 Torsten Will (Talk | contribs) (added Python implementation) * (cur) (last) 11:37, 27 August 2006 SmackBot (Talk | contribs) m (ISBN formatting &/or general fixes using AWB) * (cur) (last) 20:31, 31 July 2006 198.37.32.215 (Talk) * (cur) (last) 20:31, 31 July 2006 198.37.32.215 (Talk) * (cur) (last) 06:21, 22 July 2006 202.53.76.18 (Talk) (→External links) * (cur) (last) 03:31, 18 July 2006 195.7.17.85 (Talk) * (cur) (last) 06:28, 14 July 2006 Deco (Talk | contribs) m (Reverted edits by 202.53.72.51 (talk) to last version by Agabrielson) * (cur) (last) 23:06, 13 July 2006 202.53.72.51 (Talk) (→External links) * (cur) (last) 19:32, 5 July 2006 Agabrielson (Talk | contribs) (C code did not present a stable sorting algorithm.) * (cur) (last) 12:13, 30 June 2006 AntiVandalBot (Talk | contribs) m (BOT - rv 203.128.15.4 (talk) to last version by Scullder) * (cur) (last) 12:13, 30 June 2006 203.128.15.4 (Talk) (→Sample implementations) * (cur) (last) 16:49, 13 June 2006 Scullder (Talk | contribs) m (fr:Tri comptage) * (cur) (last) 05:46, 12 June 2006 A5b (Talk | contribs) m (link to ru:~) * (cur) (last) 12:48, 8 June 2006 Pce3@ij.net (Talk | contribs) m (→Visual Basic - update code) * (cur) (last) 09:35, 8 June 2006 Pce3@ij.net (Talk | contribs) m (→Visual Basic version - gramr) * (cur) (last) 09:33, 8 June 2006 Pce3@ij.net (Talk | contribs) (→RESULTS: (Counting sort - Visual Basic) - add Class determination) * (cur) (last) 09:20, 8 June 2006 Pce3@ij.net (Talk | contribs) (→RESULTS: (Counting sort - Visual Basic)) * (cur) (last) 07:02, 8 June 2006 Pce3@ij.net (Talk | contribs) m (→RESULTS: (Counting sort - Visual Basic) - corr) * (cur) (last) 06:59, 8 June 2006 Pce3@ij.net (Talk | contribs) (→RESULTS: (Counting sort - Visual Basic)) * (cur) (last) 06:57, 8 June 2006 Pce3@ij.net (Talk | contribs) (→Visual Basic version - add c++ slope values) * (cur) (last) 06:44, 8 June 2006 Pce3@ij.net (Talk | contribs) m (→Visual Basic version - add link) * (cur) (last) 06:43, 8 June 2006 Pce3@ij.net (Talk | contribs) (→Sample implementations - add Visual Basic version) * (cur) (last) 09:41, 3 June 2006 210.212.5.146 (Talk) (→C) * (cur) (last) 05:40, 24 May 2006 Pako (Talk | contribs) m   * (cur) (last) 20:19, 11 May 2006 Booyabazooka (Talk | contribs) (Category:Stable sorts) * (cur) (last) 18:52, 30 April 2006 Giftlite (Talk | contribs) (wikify) * (cur) (last) 18:50, 30 April 2006 70.48.94.22 (Talk) (Fixed a typo (pigeonhole sort was spelt wrong) and linked it.) * (cur) (last) 08:20, 30 April 2006 Saurabhc (Talk | contribs) * (cur) (last) 15:44, 15 February 2006 81.76.123.165 (Talk) (Added external link) * (cur) (last) 06:45, 13 February 2006 Zippedmartin (Talk | contribs) (→Sample implementations - Remove java imp. - makes page much bigger and is much the same as the c)   * (cur) (last) 09:17, 28 January 2006 84.92.183.124 (Talk) (Fix range error, remove unused variable and irrelevant comment) * (cur) (last) 05:46, 28 January 2006 84.92.183.124 (Talk) (Fix range error and remove unused variable, j)   * (cur) (last) 10:17, 21 January 2006 85.157.105.210 (Talk) (fi) * (cur) (last) 18:56, 6 December 2005 Deco (Talk | contribs) (→Characteristics of counting sort - Link selection algorithm for min/maxfinding) * (cur) (last) 22:18, 28 November 2005 Deco (Talk | contribs) (Link comparison sort) * (cur) (last) 23:44, 18 November 2005 Deco (Talk | contribs) m (Fix year) * (cur) (last) 17:11, 18 November 2005 Deco (Talk | contribs) (Better CLRS ref) * (cur) (last) 17:10, 18 November 2005 Deco (Talk | contribs) (Better CLRS ref) * (cur) (last) 04:56, 18 November 2005 Deco (Talk | contribs) (Add Knuth reference) * (cur) (last) 14:35, 24 September 2005 YurikBot (Talk | contribs) m (robot Adding: he) * (cur) (last) 14:43, 19 September 2005 206.191.221.191 (Talk) (→Java) * (cur) (last) 01:52, 12 September 2005 70.157.50.127 (Talk) (→Java) * (cur) (last) 13:30, 16 July 2005 RobotE (Talk | contribs) m (robot Adding: de, nl) * (cur) (last) 17:43, 5 July 2005 132.170.48.230 (Talk) (→Java) * (cur) (last) 12:20, 25 June 2005 82.48.80.158 (Talk) (+it:) * (cur) (last) 09:56, 13 June 2005 151.188.16.20 (Talk) * (cur) (last) 12:47, 5 May 2005 83.17.149.194 (Talk) * (cur) (last) 11:20, 27 April 2005 Aenar (Talk | contribs) (consistency) * (cur) (last) 10:58, 27 April 2005 Aenar (Talk | contribs) m (→Characteristics of counting sort - tweaking sentence) * (cur) (last) 10:52, 27 April 2005 Aenar (Talk | contribs) (→Characteristics of counting sort - rewrite unclear text) * (cur) (last) 23:12, 20 April 2005 Aenar (Talk | contribs) (Correction and clarification. There are some implicit assumptions (i.e. that indexex of C run from 0) that should be made explicit.) * (cur) (last) 18:49, 20 April 2005 Aenar (Talk | contribs) (Commented C code) * (cur) (last) 18:15, 20 April 2005 Aenar (Talk | contribs) (Done cleanup (hope I didn't delete too much information).) * (cur) (last) 17:27, 20 April 2005 Aenar (Talk | contribs) (Rewriting article (not finished)) * (cur) (last) 04:51, 18 March 2005 67.39.9.8 (Talk) (Fixed typo.) * (cur) (last) 02:49, 8 March 2005 Bayard (Talk | contribs) * (cur) (last) 06:04, 8 June 2004 Smyth (Talk | contribs) * (cur) (last) 18:27, 31 May 2004 Fredrik (Talk | contribs) m (wikify) * (cur) (last) 10:11, 30 May 2004 Timwi (Talk | contribs) (Category:Sort algorithms) * (cur) (last) 06:48, 27 April 2004 Frencheigh (Talk | contribs) m   * (cur) (last) 06:47, 27 April 2004 Frencheigh (Talk | contribs) m    * (cur) (last) 23:15, 31 March 2004 Cyde (Talk | contribs) (Beefed up the explanation of the counting sort, added how to handle strings and negative numbers.) * (cur) (last) 15:28, 22 February 2004 Gamma (Talk | contribs) * (cur) (last) 15:26, 22 February 2004 Gamma (Talk | contribs) (wikif.) * (cur) (last) 23:59, 28 August 2003 202.141.64.82 (Talk) * (cur) (last) 09:23, 16 February 2003 Zundark (Talk | contribs) (remove more pseudo-C code from 24.60.20.159) * (cur) (last) 07:38, 8 February 2003 Maveric149 (Talk | contribs) m (Reverted to last edit by Ducker) * (cur) (last) 07:38, 8 February 2003 Bolero (Talk | contribs) * (cur) (last) 07:37, 8 February 2003 Ducker (Talk | contribs) * (cur) (last) 07:37, 8 February 2003 Bolero (Talk | contribs) * (cur) (last) 18:55, 8 November 2002 128.197.12.3 (Talk) * (cur) (last) 18:53, 8 November 2002 128.197.12.3 (Talk) * (cur) (last) 18:52, 8 November 2002 128.197.12.3 (Talk) * (cur) (last) 18:44, 8 November 2002 128.197.12.3 (Talk) * (cur) (last) 18:41, 8 November 2002 128.197.12.3 (Talk) * (cur) (last) 18:40, 8 November 2002 128.197.12.3 (Talk) * (cur) (last) 21:23, 29 October 2002 207.172.11.233 (Talk) * (cur) (last) 09:47, 29 October 2002 24.60.20.159 (Talk) * (cur) (last) 09:39, 29 October 2002 24.60.20.159 (Talk) m   * (cur) (last) 17:14, 6 October 2002 24.60.20.159 (Talk) m    * (cur) (last) 17:13, 6 October 2002 24.60.20.159 (Talk) * (cur) (last) 19:30, 5 October 2002 24.60.20.159 (Talk) m   * (cur) (last) 19:26, 5 October 2002 24.60.20.159 (Talk) m    * (cur) (last) 19:25, 5 October 2002 24.60.20.159 (Talk)

Is python part in place ? m = maxval + 1 count = [0] * m              # init with zeros

C++ implementation
The C++ implementation has several shortcomings. First of all, the following line is not standard conforming, as the function  does not return a value (it is  ).

A correct program, I suppose, may be obtained by replacing that statement with the following two statements:

Second, that function can be used only to sort arrays of integers. In most cases, a programmer wants to sort an array of records (structs or classes), in which the integer key is only one of the fields.

Third, that function necessarily allocates memory, even when the programmer could have already allocated the needed buffers.

Therefore I am going to replace that function with three function templates that I wrote that, I think, may satisfy real programming needs. --Carlo.milanesi (talk) 17:29, 8 June 2008 (UTC)