Talk:Sorting algorithms/Comb sort

From Rosetta Code
Revision as of 13:44, 16 May 2010 by Wolf (talk | contribs) (Created page with '===Faulty Code=== After discussion on [http://www.autohotkey.com/forum/ AHK forum], and thoroughly checking the findings, I believe the published pseudocode is faulty, and so are…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Faulty Code

After discussion on AHK forum, and thoroughly checking the findings, I believe the published pseudocode is faulty, and so are the implementations that follow the pseudocode. I don't have the ability to check all languages, but these look suspicious to me: ActionScript, C#, Io, PL/I, PureBasic (2nd example), Python, Ruby, Tcl, TI-83 BASIC. I appologize for suspecting any code incorrectly, but I do have a point with python.

This example for Python:

...

x = [88, 18, 31, 44, 4, 0, 8, 81, 14, 78, 20, 76, 84, 33, 73, 75, 82, 5, 62, 70]
combsort(x)
print x

gives this incorrect output: (check the position of 62 und 70)

[0, 4, 5, 8, 14, 18, 20, 31, 33, 44, 70, 62, 73, 75, 76, 78, 81, 82, 84, 88]

I claim no credit for the discovery for myself, as my original code (for AutoHotkey) fell into the same trap, and got corrected by a fellow forum member. --Wolf 13:44, 16 May 2010 (UTC)