转载自:http://java2novice.com/java-sorting-algorithms/merge-sort/
Merge sort is a divide and conquer algorithm.
Steps to implement Merge Sort:
1) Divide the unsorted array into n partitions, each partition contains 1 element. Here the one element is considered as sorted.
2) Repeatedly merge partitioned units to produce new sublists until there is only 1 sublist remaining. This will be the sorted list at the end.

Merge sort is a fast, stable sorting routine with guaranteed O(n*log(n)) efficiency. When sorting arrays, merge sort requires additional scratch space proportional to the size of the input array. Merge sort is relatively simple to code and offers performance typically only slightly below that of quicksort.
|
| Output: |
4 11 23 28 43 45 65 77 89 98 |
本文介绍了一种快速稳定的排序算法——归并排序。归并排序采用分治策略,将待排序数组分为若干个子序列,每个子序列都是有序的,再依次合并这些子序列,直至得到最终有序序列。文章详细解释了归并排序的实现步骤,并提供了Java代码示例。
556

被折叠的 条评论
为什么被折叠?



