且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

寻找一种算法,尽可能少的比较操作

更新时间:2023-01-27 09:19:16

我不认为你很可能会得到比的有关排序的***页面。

I don't think you're likely to get a better answer than the Wikipedia page on sorting.

摘要:

  • 对于任意的比较(在这里你不能使用像基数排序),***你能做到的,是为O(n log n)的
  • 各种算法实现这一点 - 见的算法比较
  • 在常用的快速排序是O(n log n)的一个典型案例,但为O(n ^ 2)在最坏的情况;经常有办法避免这种情况,但如果你真的担心比较的成本,我喜欢的东西归并或堆排序去。这部分取决于现有的数据结构。

如果人类正在做比较,是他们也做了排序?你有你需要使用一个固定的数据结构,或者你能有效地创建使用平衡二叉树插入排序的副本吗?什么是存储需求?

If humans are doing the comparisons, are they also doing the sorting? Do you have a fixed data structure you need to use, or could you effectively create a copy using a balanced binary tree insertion sort? What are the storage requirements?