# 정렬 알고리즘 정리

선택 정렬

* 제일 작은 거 찾아서 맨 앞으로 보내는거 n번
* 찾는 연산은 원소만큼 N, 반복을 N, 최종 복잡도 O(n^2)

버블 정렬

* 2개씩 비교해서 자리 옮기는거 n번, n-1번 ...
* 연산 횟수 1부터 n까지 더하면 최고항 N^2, 최종 복잡도 O(n^2)

삽입 정렬

* 정렬 범위 1씩 확대하면서 새로 추가된 거 정렬될때까지 앞으로 보내기
* 원소 개수 N, 앞으로 보내기 N, 최종 복잡도 O(n^2)

병합 정렬

* 죄다 나눈 다음에 짝지어서 합치고 정렬 반복
* 합칠 때 정렬은 둘 중 작은 값 뽑아내기
* 원소의 개수만큼 비교하므로 N, 합치는 단계가 logN, 최종 복잡도 O(NlogN)

퀵 정렬

* 피벗 골라서 작은 값은 왼쪽, 큰 값은 오른쪽 반복
* 피벗 중간값 가까우면 : O(NlogN), 피벗 최대나 최소면 : O(N^2)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lazyartisan.gitbook.io/note/main-page/algorithm/undefined/undefined-7.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
