Talk:Sorting algorithms/Gnome sort

From Rosetta Code
Revision as of 20:47, 27 April 2009 by rosettacode>ShinTakezou (→‎C problem?: it was Huffman, not LZW!)

C problem?

The second j := j + 1 from the example seems to be missing? --Paddy3118 17:04, 27 April 2009 (UTC)

The code works for sure (I've used it in Huffman codes... anyway I've written also a test code and did some testing and it seems to work...); I can't remember, maybe I've "reinterpreted" it or optimized it... I will study if it is still Gnome, or if I've changed it so that it can be called Gnome sort no more. --ShinTakezou 18:28, 27 April 2009 (UTC)
How I can understand it now: the previous C version was simply the original Gnome sort as explained in the Dick Grune citation on Wikipedia (the garden gnome moves always one step forward or backward); the pseudocode is an optimized version, since we don't need to pass through every pot to reach the same position we left when started to go backward; so we can restart from j instead of 1. --ShinTakezou 20:37, 27 April 2009 (UTC)