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

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

内容简介:有几种排序算法,如计算机科学教科书中经常讨论的插入排序,选择排序,冒泡排序等.给定一个整数或对象数组,是否有内置的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 McIlroys 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中有哪些不同的排序算法?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

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

Microformats

Microformats

John Allsopp / friends of ED / March 26, 2007 / $34.99

In this book, noted web developer and long time WaSP member John Allsop teaches all you need to know about the technology: what Microformats are currently available and how to use them; the general pr......一起来看看 《Microformats》 这本书的介绍吧!

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

在线压缩/解压 HTML 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

SHA 加密
SHA 加密

SHA 加密工具