Skip to content

Commit 79ca83c

Browse files
Add Korean translation of Quick Select algorithm (TheAlgorithms#193)
Co-authored-by: David Leal <[email protected]>
1 parent 25d6f3a commit 79ca83c

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

en/Selection Algorithms/Quick Select.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ Let's say k = 4. ie. We have to find 4th smallest element.
4141
4. As position of '7' is 4th (ie. k). Thus we will simply return 7
4242
```
4343

44+
### Code Implementation Links
45+
46+
- [Java](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/searches/QuickSelect.java)
47+
- [Python](https://github.com/TheAlgorithms/Python/blob/master/searches/quick_select.py)
48+
- [Go](https://github.com/TheAlgorithms/Go/blob/master/search/selectk.go)
49+
- [JavaScript](https://github.com/TheAlgorithms/JavaScript/blob/master/Data-Structures/Array/QuickSelect.js)
50+
4451
### Helpful Video Links
4552

4653
[Video explaining how to find the Kth smallest/largest element in varying complexities](https://youtu.be/hGK_5n81drs)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# 퀵 셀렉트
2+
3+
### 문제
4+
5+
주어진 배열에 대해, k번째로 큰/작은 원소를 선형 시간복잡도 안에 찾아라.
6+
7+
### 접근
8+
9+
- 배열에서 무작위로 '피벗'으로 쓰일 원소를 정한다.
10+
- 퀵 소트에서와 같이, 파티션을 적용한다.
11+
- 파티션을 나누면, 피벗보다 작은 원소들은 피벗의 왼쪽 부분에 위치하고, 피벗보다 큰 원소들은 피벗의 오른쪽 부분에 위치하게 된다. 즉, 피벗은 배열 내에서 정렬된 위치에 존재한다.
12+
- 피벗의 인덱스가 k라면, 원하는 원소를 찾았으므로 피벗을 반환한다.
13+
- 아니라면, 현재 피벗의 위치가 k보다 큰지 작은지 확인하고, 이에 따라 k번째 원소가 위치할 수 있는 범위 안에서 새로운 피벗을 고른다.
14+
- 이를 반복한다.
15+
16+
### 시간 복잡도
17+
18+
- 최악의 경우 `O(n^2)`
19+
20+
- 최선의 경우 `O(n)`
21+
22+
- 평균 `O(n)`
23+
24+
25+
### 알고리즘을 고안한 사람
26+
27+
- 이 알고리즘은 토니 호어(Tony Hoare)에 의해 발명되어, `호어의 선택 알고리즘`이라고도 불린다.
28+
29+
### 예시
30+
31+
```
32+
배열 = {8,2,11,7,9,1,3}
33+
인덱스: 0 1 2 3 4 5 6
34+
35+
k = 4, 즉 4번째로 작은 원소를 찾고 싶다고 하자.
36+
37+
1. 무작위로 피벗을 고른다. 여기서는 7을 골랐다고 하자.
38+
2. 7과 마지막 원소(3)의 위치를 바꾸고, 파티션을 적용한다.
39+
3. 그러면 7보다 작은 모든 원소들은 7의 왼쪽에 있고, 7보다 큰 모든 원소들은 7의 오른쪽에 있게 된다. 즉, 7은 정렬된 위치에 있다. (배열 = {2,3,1,7,8,9,11})
40+
4. 7의 위치가 4번째이므로, 우리가 찾는 원소이다. 7을 반환한다.
41+
```
42+
43+
### 구현
44+
45+
- [Java](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/searches/QuickSelect.java)
46+
- [Python](https://github.com/TheAlgorithms/Python/blob/master/searches/quick_select.py)
47+
- [Go](https://github.com/TheAlgorithms/Go/blob/master/search/selectk.go)
48+
- [JavaScript](https://github.com/TheAlgorithms/JavaScript/blob/master/Data-Structures/Array/QuickSelect.js)
49+
50+
### 관련 영상
51+
52+
[여러가지 시간 복잡도에 따라 K번째로 작은/큰 원소를 찾는 방법을 설명하는 영상](https://youtu.be/hGK_5n81drs)

0 commit comments

Comments
 (0)