提交 c717bb9f 编写于 作者: yin-zh's avatar yin-zh

test

上级 302a9e3e
...@@ -6,9 +6,8 @@ package com.yzh; ...@@ -6,9 +6,8 @@ package com.yzh;
import java.util.Arrays; import java.util.Arrays;
public class MergeSort { public class MergeSort {
/**
*把输入序列分成left,right两个子序列,再分别对子序列递归调用归并排序 //把输入序列分成left,right两个子序列,再分别对子序列递归调用归并排序
*/
public int[] solution(int[] array) { public int[] solution(int[] array) {
if (array.length < 2) { if (array.length < 2) {
return array; return array;
...@@ -20,9 +19,8 @@ public class MergeSort { ...@@ -20,9 +19,8 @@ public class MergeSort {
return merge(solution(left), solution(right)); return merge(solution(left), solution(right));
} }
/**
*将两段排序好的数组结合成一个排序数组 //将两段排序好的数组结合成一个排序数组
*/
public int[] merge(int[] left, int[] right) { public int[] merge(int[] left, int[] right) {
int[] result = new int[left.length + right.length]; int[] result = new int[left.length + right.length];
for (int index = 0, i = 0, j = 0; index < result.length; index++) { for (int index = 0, i = 0, j = 0; index < result.length; index++) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册