Quick Sort
Quick Sort 관련 기록.
글 관리 · 공개 범위이 글의 목차
Quick Sort
void qSort(int s, int e) {
if (s >= e) return;
int l = s, r = e;
auto pivot = data[(l+r)/2];
while(l < r) {
while(pivot < data[r]) --r;
while(data[l] < pivot) ++l;
if (l >= r) break;
auto tmp = data[l];
data[l] = data[r];
data[r] = tmp;
++l, --r;
}
qSort(s, r);
qSort(l, e);
}
Time Complexity
- Average:
- Worst:
이전 사이트에서 옮긴 글입니다. 원본 보관본
AI로 읽기 · Markdown
로그인 없이 읽는 Markdown 원문.
curl -fsSL 'https://www.readiz.com/notes/algorithm/sort/quick/index.md'