728x90
반응형
merge(list, left, mid, last):
// 2개의 인접한 배열 list[left..mid]와 list[mid+1..right]를 합병
b1←left;
e1←mid;
b2←mid+1;
e2←right;
sorted 배열을 생성;
index←0;
while b1≤e1 and b2≤e2 do
if(list[b1]<list[b2])
then
sorted[index]←list[b1];
b1++;
index++;
else
sorted[index]←list[b2];
b2++;
index++;
요소가 남아있는 부분배열을 sorted로 복사한다;
sorted를 list로 복사한다;
// 2개의 인접한 배열 list[left..mid]와 list[mid+1..right]를 합병
b1←left;
e1←mid;
b2←mid+1;
e2←right;
sorted 배열을 생성;
index←0;
while b1≤e1 and b2≤e2 do
if(list[b1]<list[b2])
then
sorted[index]←list[b1];
b1++;
index++;
else
sorted[index]←list[b2];
b2++;
index++;
요소가 남아있는 부분배열을 sorted로 복사한다;
sorted를 list로 복사한다;
728x90
반응형
'C언어' 카테고리의 다른 글
퀵 소팅 알고리즘 (0) | 2010.10.15 |
---|---|
쉘정렬 알고리즘 시간 복잡도 (0) | 2010.10.15 |
c언어 최대공약수 / 최소공배수 (0) | 2010.10.15 |
팩토리얼 재귀함수로 구현하기 (0) | 2009.10.19 |
피보나치 수열 함수로 구현하기 (0) | 2009.10.19 |