这是merge-sort的方法:
private void doMergeSort(int lowerIndex, int higherIndex) {
if (lowerIndex < higherIndex) {
int middle = lowerIndex + (higherIndex - lowerIndex) / 2;
System.out.println("Lower index="+lowerIndex+" Middle="+middle+ " Higher index="+higherIndex);
doMergeSort(lowerIndex, middle);
doMergeSort(middle + 1, higherIndex);
mergeParts(lowerIndex, middle, higherIndex);//never mind this method
}
}
doMergeSort(0,9)的输出如下:
Lower index=0 Middle=4 Higher index=9
Lower index=0 Middle=2 Higher index=4
Lower index=0 Middle=1 Higher index=2
Lower index=0 Middle=0 Higher index=1
Lower index=3 Middle=3 Higher index=4//This line
Lower index=5 Middle=7 Higher index=9
Lower index=5 Middle=6 Higher index=7
Lower index=5 Middle=5 Higher index=6
Lower index=8 Middle=8 Higher index=9
4 11 23 28 43 45 65 77 89 98 //never mind this part too
输出的第4行(用注释标记)是如何形成的?请解释一下。