MERGE(A,p,q,r)
n1=q-p+1;
n2=r-q;
for(i=1;i<=n1;i++)
L[i]=A[p+i-1];
for(i=1;i<=n2;i++)
R[i]=A[q+i];
L[n1+1]=MAX;
R[n2+1]=MAX;
i=j=1;
for(k=p;k<=r;k++)
{
if(L[i]<R[j])
{
A[k]=L[i];
i++;
}
else
{
A[k]=R[j];
j++;
}
}
MERGE-SORT(A,p,r)
if (p<r)
{
q=(p+q)/2;
MERGE-SORT(A,p,q);
MERGE-SORT(A,q,r);
MERGE(A,p,q,r);
}
06-19
12万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-08