From 58a16192bfead5cfb9466079edb95cf4e0a53903 Mon Sep 17 00:00:00 2001 From: woo-jk <201702042@o.cnu.ac.kr> Date: Thu, 25 Nov 2021 00:29:11 +0900 Subject: [PATCH 1/6] Korean translation of Bubble Sort --- ...60\355\222\210\354\240\225\353\240\254.md" | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 "ko/\354\240\225\353\240\254/\352\261\260\355\222\210\354\240\225\353\240\254.md" diff --git "a/ko/\354\240\225\353\240\254/\352\261\260\355\222\210\354\240\225\353\240\254.md" "b/ko/\354\240\225\353\240\254/\352\261\260\355\222\210\354\240\225\353\240\254.md" new file mode 100644 index 00000000..aacce492 --- /dev/null +++ "b/ko/\354\240\225\353\240\254/\352\261\260\355\222\210\354\240\225\353\240\254.md" @@ -0,0 +1,104 @@ +# 버블 정렬 + +#### 문제 + +원소 n개로 이루어진 정렬되지 않은 배열이 주어졌을 때, 배열을 정렬하는 함수를 작성하라 + +#### 접근방식 + +- 배열의 첫 번째 원소를 선택한다. +- 다음 원소와 비교한다. +- 다음 원소보다 크다면 교환한다. +- 아니라면 아무것도 하지 않는다. +- 배열의 모든 인덱스에 이 작업을 진행한다. +- 위의 과정을 n번 반복한다. + +#### 시간 복잡도 + +`O(n^2)` 최악의 경우 + +`O(n)` 최선의 경우 + +`O(n^2)` 평균 복잡도 + +#### 공간 복잡도 + +`O(1)` 최악의 경우 + +#### 만든 사람 + +- “Bubble Sort”라는 용어는 1962년 Iverson, K에 의해 처음 사용되었다. + +#### 예시 + +``` +배열 = {10, 80, 40, 30} +인덱스들: 0 1 2 3 + +1. 인덱스 = 0, 숫자 = 10 +2. 10 < 80, 아무것도 하지 않고 다음 단계로 넘어간다. + +3. 인덱스 = 1, 숫자 = 80 +4. 80 > 40, 80과 40을 교환한다. +5. 현재 배열은 {10, 40, 80, 30} + +6. 인덱스 = 2, 숫자 = 80 +7. 80 > 30, 80과 30을 교환한다. +8. 현재 배열은 {10, 40, 30, 80} + +위 단계를 다시 반복한다. + +배열 = {10, 40, 30, 80} +인덱스들: 0 1 2 3 + +1. 인덱스 = 0, 숫자 = 10 +2. 10 < 40, 아무것도 하지 않고 다음 단계로 넘어간다. + +3. 인덱스 = 1, 숫자 = 40 +4. 40 > 30, 40과 30을 교환한다. +5. 현재 배열은 {10, 30, 40, 80} + +6. 인덱스 = 2, 숫자 = 40 +7. 40 < 80, 아무것도 하지 않는다. +8. 현재 배열은 {10, 30, 40, 80} + +위 단계를 다시 반복한다. + +배열 = {10, 30, 40, 80} +인덱스들: 0 1 2 3 + +1. 인덱스 = 0, 숫자 = 10 +2. 10 < 30, 아무것도 하지 않고 다음 단계로 넘어간다. + +3. 인덱스 = 1, 숫자 = 30 +4. 30 < 40, 아무것도 하지 않고 다음 단계로 넘어간다. + +5. 인덱스 = 2, 숫자 = 40 +6. 40 < 80, 아무것도 하지 않는다. + +위 단계에서 교환이 없기 때문에 배열이 정렬되었음을 의미하고, 여기서 멈출 수 있다. +``` + +#### 코드 구현 + +- [자바](https://github.com/TheAlgorithms/Java/blob/master/Sorts/BubbleSort.java) +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/sorting/bubble_sort.cpp) +- [파이썬](https://github.com/TheAlgorithms/Python/blob/master/sorts/bubble_sort.py) +- [C#](https://github.com/TheAlgorithms/C-Sharp/blob/master/Algorithms/Sorters/Comparison/BubbleSorter.cs) +- [고](https://github.com/TheAlgorithms/Go/blob/master/sorts/bubblesort.go) +- [루비](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/bubble_sort.rb) +- [C](https://github.com/TheAlgorithms/C/blob/master/sorting/bubble_sort.c) +- [스칼라](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/BubbleSort.scala) +- [자바스크립트](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/BubbleSort.js) + +#### 영상 설명 + +[버블정렬 알고리즘에 대한 영상 설명](https://www.youtube.com/watch?v=Jdtq5uKz-w4) + +#### 그 외 + +버블 정렬은 싱킹 정렬이라고도 한다. + +#### 애니메이션 설명 + +- [Tute Board](https://boardhub.github.io/tute/?wd=bubbleSortAlgo2) From 0561110cca204c28cd40fdb18327f8a0ddf8f8e9 Mon Sep 17 00:00:00 2001 From: woo-jk <201702042@o.cnu.ac.kr> Date: Thu, 25 Nov 2021 00:35:05 +0900 Subject: [PATCH 2/6] Korean translation of Bubble Sort --- .../\353\262\204\353\270\224\354\240\225\353\240\254.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "ko/\354\240\225\353\240\254/\352\261\260\355\222\210\354\240\225\353\240\254.md" => "ko/\354\240\225\353\240\254/\353\262\204\353\270\224\354\240\225\353\240\254.md" (100%) diff --git "a/ko/\354\240\225\353\240\254/\352\261\260\355\222\210\354\240\225\353\240\254.md" "b/ko/\354\240\225\353\240\254/\353\262\204\353\270\224\354\240\225\353\240\254.md" similarity index 100% rename from "ko/\354\240\225\353\240\254/\352\261\260\355\222\210\354\240\225\353\240\254.md" rename to "ko/\354\240\225\353\240\254/\353\262\204\353\270\224\354\240\225\353\240\254.md" From e9dc237b282ca34dcd1598ef6ca8f150daf78d23 Mon Sep 17 00:00:00 2001 From: woo-jk <201702042@o.cnu.ac.kr> Date: Thu, 9 Dec 2021 05:58:30 +0900 Subject: [PATCH 3/6] Added Korean explanation of Heap Sort + Fix typo --- en/Sorting Algorithms/Heap Sort.md | 38 +++++----- .../\355\236\231\354\240\225\353\240\254.md" | 69 +++++++++++++++++++ 2 files changed, 88 insertions(+), 19 deletions(-) create mode 100644 "ko/\354\240\225\353\240\254/\355\236\231\354\240\225\353\240\254.md" diff --git a/en/Sorting Algorithms/Heap Sort.md b/en/Sorting Algorithms/Heap Sort.md index 20250386..8666c2ff 100644 --- a/en/Sorting Algorithms/Heap Sort.md +++ b/en/Sorting Algorithms/Heap Sort.md @@ -23,35 +23,35 @@ or O(n) (equal keys) Best-case performance `O(1)` Worst case auxiliary - #### Example - ``` + +``` Input data: 4, 10, 3, 5, 1 - 4(0) - / \ - 10(1) 3(2) - / \ - 5(3) 1(4) + 4(0) + / \ + 10(1) 3(2) + / \ +5(3) 1(4) The numbers in bracket represent the indices in the array representation of data. Applying heapify procedure to index 1: - 4(0) - / \ - 10(1) 3(2) - / \ + 4(0) + / \ + 10(1) 3(2) + / \ 5(3) 1(4) Applying heapify procedure to index 0: - 10(0) - / \ - 5(1) 3(2) - / \ - 4(3) 1(4) + 10(0) + / \ + 5(1) 3(2) + / \ +4(3) 1(4) The heapify procedure calls itself recursively to build heap - in top down manner. - ``` +in top down manner. +``` ![heap-image](https://upload.wikimedia.org/wikipedia/commons/1/1b/Sorting_heapsort_anim.gif "Heap Sort") @@ -68,4 +68,4 @@ The heapify procedure calls itself recursively to build heap #### Video Explanation -[A video explaining the Selection Sort Algorithm](https://www.youtube.com/watch?v=MtQL_ll5KhQ) +[A video explaining the Heap Sort Algorithm](https://www.youtube.com/watch?v=MtQL_ll5KhQ) diff --git "a/ko/\354\240\225\353\240\254/\355\236\231\354\240\225\353\240\254.md" "b/ko/\354\240\225\353\240\254/\355\236\231\354\240\225\353\240\254.md" new file mode 100644 index 00000000..3d2e7d30 --- /dev/null +++ "b/ko/\354\240\225\353\240\254/\355\236\231\354\240\225\353\240\254.md" @@ -0,0 +1,69 @@ +# 힙 정렬 + +#### 문제 + +정렬되지 않은 n개의 원소로 이루어진 배열이 주어졌을 때, 배열을 정렬하는 함수를 작성하라 + +#### 접근방식 + +- 입력 데이터에서 최대 힙을 빌드한다. +- 이때, 가장 큰 원소가 힙의 루트에 저장된다. 해당 원소를 힙의 마지막 원소로 교체한 뒤, 힙의 사이즈를 1 줄인다. +- 힙의 사이즈가 1보다 크다면 위 과정을 반복한다. + +#### 시간 복잡도 + +`O(n log n)` 최악의 경우 + +`O(n log n)` (고유 키) +or O(n) (동일 키) 최선의 경우 + +`O(n log n)` 평균 복잡도 + +#### 공간 복잡도 + +`O(1)` 최악의 경우 + +#### 예시 + +``` +입력 원소 : 4, 10, 3, 5, 1 + 4(0) + / \ + 10(1) 3(2) + / \ +5(3) 1(4) + +괄호 안의 숫자는 데이터의 배열 인덱스를 나타낸다. + +1번 인덱스에 힙 절차 적용 : + 4(0) + / \ + 10(1) 3(2) + / \ +5(3) 1(4) + +0번 인덱스의 힙 절차 적용: + 10(0) + / \ + 5(1) 3(2) + / \ +4(3) 1(4) +힙 절차는 재귀적으로 호출하여 하향식 방식으로 힙을 빌드한다. +``` + +![힙 이미지](https://upload.wikimedia.org/wikipedia/commons/1/1b/Sorting_heapsort_anim.gif "Heap Sort") + +#### 코드구현 + +- [자바](https://github.com/TheAlgorithms/Java/blob/master/Sorts/HeapSort.java) +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/sorting/heap_sort.cpp) +- [파이썬](https://github.com/TheAlgorithms/Python/blob/master/sorts/heap_sort.py) +- [고](https://github.com/TheAlgorithms/Go/blob/master/sorts/heapsort.go) +- [루비](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/heap_sort.rb) +- [C-sharp](https://github.com/TheAlgorithms/C-Sharp/blob/master/Algorithms/Sorters/Comparison/HeapSorter.cs) +- [C](https://github.com/TheAlgorithms/C/blob/master/sorting/heap_sort.c) +- [자바스크립트](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/HeapSort.js) + +#### 영상 설명 + +[힙 정렬 알고리즘에 대한 영상 설명](https://www.youtube.com/watch?v=MtQL_ll5KhQ) From c0515db6e9d4d5f7f1c663819089419be1748eea Mon Sep 17 00:00:00 2001 From: Jungkyun Woo <73513965+woo-jk@users.noreply.github.com> Date: Mon, 13 Dec 2021 03:03:18 +0900 Subject: [PATCH 4/6] =?UTF-8?q?Update=20=EB=B2=84=EB=B8=94=EC=A0=95?= =?UTF-8?q?=EB=A0=AC.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\353\262\204\353\270\224\354\240\225\353\240\254.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/ko/\354\240\225\353\240\254/\353\262\204\353\270\224\354\240\225\353\240\254.md" "b/ko/\354\240\225\353\240\254/\353\262\204\353\270\224\354\240\225\353\240\254.md" index aacce492..9a9af3a0 100644 --- "a/ko/\354\240\225\353\240\254/\353\262\204\353\270\224\354\240\225\353\240\254.md" +++ "b/ko/\354\240\225\353\240\254/\353\262\204\353\270\224\354\240\225\353\240\254.md" @@ -101,4 +101,4 @@ #### 애니메이션 설명 -- [Tute Board](https://boardhub.github.io/tute/?wd=bubbleSortAlgo2) +- [튜트 보드](https://boardhub.github.io/tute/?wd=bubbleSortAlgo2) From 7bd0ff3cc813a8752d0361915f38ea626ff148f6 Mon Sep 17 00:00:00 2001 From: Jungkyun Woo <73513965+woo-jk@users.noreply.github.com> Date: Mon, 13 Dec 2021 03:04:45 +0900 Subject: [PATCH 5/6] =?UTF-8?q?Update=20ko/=EC=A0=95=EB=A0=AC/=ED=9E=99?= =?UTF-8?q?=EC=A0=95=EB=A0=AC.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: David Leal --- .../\355\236\231\354\240\225\353\240\254.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/ko/\354\240\225\353\240\254/\355\236\231\354\240\225\353\240\254.md" "b/ko/\354\240\225\353\240\254/\355\236\231\354\240\225\353\240\254.md" index 3d2e7d30..375d3ba5 100644 --- "a/ko/\354\240\225\353\240\254/\355\236\231\354\240\225\353\240\254.md" +++ "b/ko/\354\240\225\353\240\254/\355\236\231\354\240\225\353\240\254.md" @@ -51,7 +51,7 @@ or O(n) (동일 키) 최선의 경우 힙 절차는 재귀적으로 호출하여 하향식 방식으로 힙을 빌드한다. ``` -![힙 이미지](https://upload.wikimedia.org/wikipedia/commons/1/1b/Sorting_heapsort_anim.gif "Heap Sort") +![힙 이미지](https://upload.wikimedia.org/wikipedia/commons/1/1b/Sorting_heapsort_anim.gif) #### 코드구현 From a1573553835c3c58a2210158285b57d5356d9b9e Mon Sep 17 00:00:00 2001 From: Jungkyun Woo <73513965+woo-jk@users.noreply.github.com> Date: Mon, 13 Dec 2021 03:21:57 +0900 Subject: [PATCH 6/6] =?UTF-8?q?Update=20ko/=EC=A0=95=EB=A0=AC/=EB=B2=84?= =?UTF-8?q?=EB=B8=94=EC=A0=95=EB=A0=AC.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: David Leal --- .../\353\262\204\353\270\224\354\240\225\353\240\254.md" | 1 - 1 file changed, 1 deletion(-) diff --git "a/ko/\354\240\225\353\240\254/\353\262\204\353\270\224\354\240\225\353\240\254.md" "b/ko/\354\240\225\353\240\254/\353\262\204\353\270\224\354\240\225\353\240\254.md" index aa3ad75e..9a9af3a0 100644 --- "a/ko/\354\240\225\353\240\254/\353\262\204\353\270\224\354\240\225\353\240\254.md" +++ "b/ko/\354\240\225\353\240\254/\353\262\204\353\270\224\354\240\225\353\240\254.md" @@ -102,4 +102,3 @@ #### 애니메이션 설명 - [튜트 보드](https://boardhub.github.io/tute/?wd=bubbleSortAlgo2) -