简体   繁体   English

mergesort和java实现

[英]mergesort and java implementation

Suppose I want to use the mergesort algorithm. 假设我想使用mergesort算法。 Does JAVA has a method/function which implements the mergesort algorithm? JAVA有一个实现mergesort算法的方法/函数吗?

Or do I have to "manually" code the algorithm? 或者我必须“手动”编码算法?

I do not know JAVA at all. 我根本不认识JAVA。

是的,有Arrays.sort(Object []) ,OpenJDK有一个源代码示例

You could use Collections.sort() 你可以使用Collections.sort()

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). 排序算法是修改后的mergesort(如果低子列表中的最高元素小于高子列表中的最低元素,则省略合并)。 This algorithm offers guaranteed n log(n) performance. 该算法提供有保证的n log(n)性能。

No there isn't a merge sort out of the box. 没有开箱即用的合并排序。 A simple google after 'java mergesort' should give you plenty of useful results 在'java mergesort'之后的一个简单的谷歌应该会给你很多有用的结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM