比较程序排序时出现问题
问题描述:
为什么在此代码选择排序中比快速排序更快?<a href="http://www.codeproject.com/KB/recipes/SortVisualization.aspx">Visualization and Comparison of sorting algorithms in C#</a>[<a href="http://www.codeproject.com/KB/recipes/SortVisualization.aspx" target="_blank" title="New Window">^</a>]
why in this code selection sort is faster than quick sort?<a href="http://www.codeproject.com/KB/recipes/SortVisualization.aspx">Visualization and Comparison of sorting algorithms in C#</a>[<a href="http://www.codeproject.com/KB/recipes/SortVisualization.aspx" target="_blank" title="New Window">^</a>]
答
我可能是因为那篇文章中的算法所做的不只是排序.例如更新UI方面.这不是比较排序算法的方式,因为它会使结果失真.
我不会使用该特定应用程序,因为排序速度似乎会根据您的算法在UI中的哪一侧而改变,而右边的那个总是对我而言似乎总是更快.
/Fredrik
I could be because the algorithms in that article does a lot more than sort. Such as updating the UI aspects as well. That''s not how you compare sorting algorithms as it can distort the results.
I wouldn''t use that perticular application as the sorting speed seems to change depending on which side your algorithm is on in the UI, the one on the right always seems faster too me.
/Fredrik