解决方法
在数组几乎排序的假设下,您可以使用以下之一:
Wiki甚至有一个java实现就可以了.因为你不能比O(n)快得多(因为为了甚至找出数组是否排序需要很多时间)smoothsort是一个不错的选择.更多细节here.
The advantage of smoothsort is that it
comes closer to O(n) time if the input
is already sorted to some degree
The complexity of cocktail sort in big
O notation is O(n2) for both the worst
case and the average case,but it
becomes closer to O(n) if the list is
mostly ordered before applying the
sorting algorithm,
原文地址:https://www.jb51.cc/c/112522.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。