Java 6中有哪些不同的排序算法?

栏目: 编程工具 · 发布时间: 7年前

内容简介:有几种排序算法,如计算机科学教科书中经常讨论的插入排序,选择排序,冒泡排序等.给定一个整数或对象数组,是否有内置的Java 6语言API,让我选择应用特定的排序算法来排序数组而不是我再次重新发明这些轮子?如果没有内置到Java 6中,是否有开源库可以产生这种功能,它们是什么?翻译自:https://stackoverflow.com/questions/6818683/what-different-sorting-algorithms-are-available-in-java-6

有几种 排序 算法,如计算机科学教科书中经常讨论的插入排序,选择排序,冒泡排序等.给定一个整数或对象数组,是否有内置的 Java 6语言API,让我选择应用特定的 排序算法 来排序数组而不是我再次重新发明这些轮子?如果没有内置到Java 6中,是否有开源库可以产生这种功能,它们是什么?

Arrays.sort() 方法在所有基本类型数组中使用快速排序.
The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy’s “Engineering a Sort Function”, Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.

Collections.sort() 方法使用合并排序.这种类型也用于 Arrays.sort(Object[]) 和Arrays.sort(T [],Comparator<?super T>).

The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n log(n) performance. This implementation dumps the specified list into an array, sorts the array, and iterates over the list resetting each element from the corresponding position in the array. This avoids the n2 log(n) performance that would result from attempting to sort a linked list in place.

翻译自:https://stackoverflow.com/questions/6818683/what-different-sorting-algorithms-are-available-in-java-6


以上所述就是小编给大家介绍的《Java 6中有哪些不同的排序算法?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

超级用户

超级用户

[美] 艾迪•尹 / 王喆,余宁 / 中信出版集团 / 2017-9 / 49.00

《超级用户》是一本可以让你和你的公司实现超常规增长的神奇的书。 多数人只有一个订书机,但有一天,全球著名市场调研公司尼尔森的高管艾迪•尹在和办公用品供应商的合作中发现,订书机的“死忠粉”们,平均每人有8个订书机。令人意想不到的是,相比那些需要更换订书机或遗失订书机的“普通”用户,他们的需求更强,购买第九个订书机的可能性更大。 有些人无肉不欢,有些人爱做手工,有些人痴迷于美国女孩玩偶。这......一起来看看 《超级用户》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具