퀵정렬 소스인데 주석좀 달아주세요
선아
#includestdio.h
#includetime.h
int size, i=0;
int partition(int a[], int begin, int end)
{
int pivot, temp, L, R, t;
L=begin;
R=end;
pivot=(begin+end)/2;
printf( [ %d 단계 : pivot=%d] \n, ++i, a[pivot]);
while(LR) {
while( (a[L]a[pivot]) && (LR) ) L++;
while( (a[R]=a[pivot]) && (LR) ) R--;
if(LR) {
temp = a[L];
a[L] = a[R];
a[R] = temp;
}
}
temp = a[pivot];
a[pivot] = a[R];
a[R] = temp;
for(t=0; tsize; t++) printf( %d, a[t]);
printf(\n\n);
return L;
}
void quicksort(int a[], int begin, int end)
{
if(beginend) {
int p;
p=partition(a, begin, end);
quicksort(a, begin, p-1);
quicksort(a, p+1, end);
}
}
void main()
{
int list[8]={69, 10, 30, 2, 16, 8, 31, 22};
size = 8;
quicksort(list, 0, size-1);
getchar();
}책에 나와있는 내용인데 이해가 잘 안되서요 ㅠㅠ
주석좀 부탁드립니다.
-
사랑
-_-; 이렇게 광범위하게 설명해달라고 하실 바엔...
차라리 책을 다시 한 번 정독해 보시기 바랍니다..;;
책을 읽다가 정 모르는 부분이 있으면
그 부분만 자세하게 물어보는 게 좋을 듯하네요...^^
퀵정렬이나 합병정렬 같은
\디바이드 앤 퀀커 (분할 정복법)\ 정렬들은 좀 내용이 어려울 수 있습니다.
이런 고차원(?)적인 정렬 방법을 분석하시기 전에
좀 더 한단계 낮은, 삽입정렬, 선택정렬, 버블정렬들을 좀 더 분석하신뒤에
90% 정도 이해를