我正在研究"Quick as a Flash" over at CodeEval,我试图找出他们用于分区步骤的算法。 The only hint is the animation they include.这用什么分区算法? (用于快速排序)
它看起来是递归的,但我不知道逻辑是什么。它似乎没有按照维基百科的标准“Lomuto”分区方案。
任何指针将不胜感激,没有破坏者如何完成挑战,我想自己完成它;但是,这个帖子中没有足够的信息可以继续。
编辑:
这里它显示在动画列表的状态之间的转变:
- 5,2,6,1,3,4
- 4,2,6 ,1,3,5
- 4,2,5,1,3,6
- 4,2,3,1,5,6
- 1,2,3,4,5,6
(然后重复)
[链接到维基百科文章的Lumoto方法。 ](https://en.wikipedia.org/wiki/Quicksort#Lomuto_partition_scheme) – mathFromtheGroundUp
[链接到同一篇文章中备用分区方案的图形。](https://en.wikipedia.org/wiki/File:Quicksort -diagram.svg) – mathFromtheGroundUp