Revision as of 09:52, 4 January 2015 editDsernst (talk | contribs)7 edits →An Implementation in Javascript: new section← Previous edit | Revision as of 11:48, 29 June 2015 edit undoSverdrup (talk | contribs)Extended confirmed users8,936 edits About error in previous version of articleNext edit → | ||
Line 6: | Line 6: | ||
I implemented this algorithm in Javascript based on the pseudocode from this article, as closely as possible. I had found the algorithm a little difficult to understand without a working implementation, & hope this can help others. I didn't add this link to the Article itself, to avoid violating ]. http://dsernst.com/2014/12/14/heaps-permutation-algorithm-in-javascript/ Thanks! --] (]) 09:52, 4 January 2015 (UTC) | I implemented this algorithm in Javascript based on the pseudocode from this article, as closely as possible. I had found the algorithm a little difficult to understand without a working implementation, & hope this can help others. I didn't add this link to the Article itself, to avoid violating ]. http://dsernst.com/2014/12/14/heaps-permutation-algorithm-in-javascript/ Thanks! --] (]) 09:52, 4 January 2015 (UTC) | ||
== Incorrect algorithm == | |||
The extra swaps stem from swapping in the last iteration of the for loop, are not a part of Heap's algorithm. I compared with Sedgewick (1977). I will correct the article, but this means that the nice illustration is out of date, and will be removed. ] (]) 11:48, 29 June 2015 (UTC) |
Revision as of 11:48, 29 June 2015
This article needs to be enhanced. It looks like this algorithm is a good solution to the problem. It is quite nice that it is short and works, and in 1963 it was most important to reduce complexity and memory consumption. But if you look what it does (the picture is very helpful with that) it is quite weird and does lots of unnecessary swaps. So, the pro and contra, and other algorithms like Steinhaus–Johnson–Trotter algorithm should be mentioned. 5.146.194.61 (talk) 14:53, 8 October 2014 (UTC)
- Please fix it! Feel free to add at least a "see also" section that links to the other algorithm, and if you have source that compares algorithms, be sure to cite it. QVVERTYVS (hm?) 09:34, 9 October 2014 (UTC)
An Implementation in Javascript
I implemented this algorithm in Javascript based on the pseudocode from this article, as closely as possible. I had found the algorithm a little difficult to understand without a working implementation, & hope this can help others. I didn't add this link to the Article itself, to avoid violating WP:NOR. http://dsernst.com/2014/12/14/heaps-permutation-algorithm-in-javascript/ Thanks! --dsernst (talk) 09:52, 4 January 2015 (UTC)
Incorrect algorithm
The extra swaps stem from swapping in the last iteration of the for loop, are not a part of Heap's algorithm. I compared with Sedgewick (1977). I will correct the article, but this means that the nice illustration is out of date, and will be removed. sverdrup (talk) 11:48, 29 June 2015 (UTC)