From 10541847844b15a88bca613062d5915e63cb2a8f Mon Sep 17 00:00:00 2001 From: Doononi Date: Wed, 25 Aug 2021 10:46:09 +0900 Subject: [PATCH 01/17] added korean directory --- README.md | 1 + ko/README.md | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 ko/README.md diff --git a/README.md b/README.md index 647159ec..1c8b2e1e 100644 --- a/README.md +++ b/README.md @@ -14,5 +14,6 @@ All Algorithms explained in simple language with examples and links to their imp - [Nepali](./ne) - [Hebrew](./he) - [Indonesian](./id) +- [Korean](./ko) To add a new language, create a new folder using 2 character `ISO 639-1` Code of that language. For example use `hi` for `Hindi` explanations. diff --git a/ko/README.md b/ko/README.md new file mode 100644 index 00000000..6090eccb --- /dev/null +++ b/ko/README.md @@ -0,0 +1,30 @@ +# 알고리즘 이름 + +알고리즘에 대한 간략한 설명을 다음과 같이 적어주세요: + +1. 시간 복잡도 +2. 공간 복잡도 +3. 활용 +4. 만든 사람 +5. 등... + +## 단계 + +알고리즘을 명확하고 단순하며 이해하기 쉬운 단계로 구분하여 설명해주세요. + +## 예시 + +간단한 예시를 들어 알고리즘을 추적해주세요. + +## 구현 + +프로그래밍 언어로 구현된 알고리즘을 링크로 연결해주세요. +NOTE: 이 조직의 다른 저장소 안에 있는 링크만 연결해주세요. + +## 영상 URL + +알고리즘을 설명하는 영상의 URL을 첨부해주세요. + +## 기타 + +다른 모든 정보는 언제든지 환영하며, 이 섹션에 포함해주세요. From 0e1d20a35f059557ea7c5d2efc3cf5e37ef8552d Mon Sep 17 00:00:00 2001 From: Doononi Date: Wed, 25 Aug 2021 11:23:17 +0900 Subject: [PATCH 02/17] added fibonacci numbers in ko basic math --- ...4\353\202\230\354\271\230 \354\210\230.md" | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 "ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230.md" diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230.md" new file mode 100644 index 00000000..8ff96757 --- /dev/null +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230.md" @@ -0,0 +1,81 @@ +# 피보나치 수 + +수학에서, 일반적으로 F(n)으로 표기되는 피보나치 수는 첫째 및 둘째 항이 1이며 그 뒤의 모든 항은 바로 앞 두 항의 합인 피보나치 수열을 구성한다. + +`[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...]` + +## 활용 + +`N번째` 피보나치 수를 구하는 것은 다양하게 활용될 수 있다: + +- 최근 피보나치 수열과 황금비는 고에너지 물리학, 양자역학, 암호학, 코딩 등 다양한 과학 분야의 연구자들에게 큰 관심을 받고 있다. + +## 단계 + +1. 기본 행렬 준비하기 +2. 기본 행렬의 거듭제곱 계산하기 +3. 행렬 원소 중 해당 값 찾기 + +## 예시 + +`8번째` 피보나치 수를 구하라 + +### 0단계 + +``` +| F(n+1) F(n) | +| F(n) F(n-1)| +``` + +### 1단계 + +``` +기본 행렬 +| 1 1 | +| 1 0 | +``` + +### 2단계 + +``` +기본 행렬의 제곱 +| 2 1 | +| 1 1 | +``` + +### 3단계 + +``` +기본 행렬의 네제곱 +| 5 3 | +| 3 2 | +``` + +### 4단계 + +``` +기본 행렬의 여덟제곱 +| 34 21 | +| 21 13 | +``` + +### 5단계 + +``` +F(8)=21 +``` + +## 구현 + +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/math/fibonacci.cpp) +- [Java](https://github.com/TheAlgorithms/Java/blob/master/Maths/FibonacciNumber.java) +- [Javascript](https://github.com/TheAlgorithms/Javascript/blob/80c2dc85d714f73783f133964d6acd9b5625ddd9/Maths/Fibonacci.js) +- [Python](https://github.com/TheAlgorithms/Python/blob/master/maths/fibonacci.py) + +## 영상 URL + +- [Youtube](https://www.youtube.com/watch?v=EEb6JP3NXBI) + +## 기타 + +- [증명](https://brilliant.org/wiki/fast-fibonacci-transform/) From 6660da67861f0eb38c235bfc8fa7aad1c4c94e77 Mon Sep 17 00:00:00 2001 From: Doononi Date: Wed, 25 Aug 2021 11:38:09 +0900 Subject: [PATCH 03/17] added geometric sequence in ko basic math --- ...61\353\271\204\354\210\230\354\227\264.md" | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 "ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" new file mode 100644 index 00000000..f7cab6a9 --- /dev/null +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" @@ -0,0 +1,56 @@ +# 등비수열 + +연속된 두 항의 비율이 같을 때 그 수열을 `등비수열`이라고 한다. 간단히 말해, 이전 항에 상수를 곱하여 다음 항을 계산하여 등비수열을 만들 수 있다. + +예를 들어, `2, 4, 8, 16`은 연속된 두 항의 비율(공비)가 모두 같으므로 등비수열이다 (4 / 2 = 8 / 4 = 16 / 8 = 2). + +

+ +

+ +**등비수열에 관한 사실들:** + +1. **초항:** 등비수열에서, 첫 항은 초항이라고 불린다. +2. **공비:** 다음 항을 이전 항으로 나누어 나타낸 연속된 두 항의 비율 +3. 등비수열은 공비에 따라 여러 경향을 보인다. 만약 공비가: + +- 양수이면, 모든 항은 첫 항과 같은 부호를 가진다. +- 음수이면, 부호가 번갈아 가며 나타난다. +- 1보다 크면, (초항의 부호에 따라) 양의 무한대 또는 음의 무한대를 향해 지수적으로 증가한다. +- 1이면, 모든 항의 값이 같은 상수수열이다. +- −1과 1사이에 있지만 0이 아니면, 0을 향해 지수적으로 감소한다. +- −1이면, 모든 항의 절댓값은 같지만, 부호가 번갈아 가며 나타난다. +- -1보다 작으면, 부호가 번갈아 가며 나타나고, 절대값은 양의 무한대를 향해 지수적으로 증가한다. + +**등비수열의 n번째 항 공식:** + +`a`가 초항이고, `r`이 공비일 때, n번째 항은: + +

+ +

+ +**등비급수(등비수열의 첫 n항의 합) 공식:** + +

+ +

+ +**등비수열에 관련된 문제를 풀기 위한 일반적인 공식:** + +`a`가 초항, `r`이 공비일 때: +등비수열의 n번째 항 = `a * r^(n-1)`. + +- 기하평균 = `n개 항의 곱의 n제곱근`. +- 등비급수 (r < 1) = `[a (1 – r^n)] / [1 – r]`. +- 등비급수 (r > 1) = `[a (r^n – 1)] / [r – 1]`. +- 무한등비급수 (r < 1) = `(a) / (1 – r)`. + +## 출처 + +- [등비수열](https://www.geeksforgeeks.org/geometric-progression/) + +## 영상 URL + +- [등비수열의 개념](https://youtu.be/gua96ju_FBk) +- [동적 계획법을 이용한 등비수열 구현 (C++)](https://youtu.be/92ZldzuGUHs) From a4e03af270d47f7853141d35efb5d749665fd9da Mon Sep 17 00:00:00 2001 From: Doononi Date: Wed, 25 Aug 2021 11:52:15 +0900 Subject: [PATCH 04/17] revised geometric sequence --- .../\353\223\261\353\271\204\354\210\230\354\227\264.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" index f7cab6a9..389f091d 100644 --- "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" @@ -1,6 +1,6 @@ # 등비수열 -연속된 두 항의 비율이 같을 때 그 수열을 `등비수열`이라고 한다. 간단히 말해, 이전 항에 상수를 곱하여 다음 항을 계산하여 등비수열을 만들 수 있다. +연속된 두 항의 비율이 항상 같을 때 그 수열을 `등비수열`이라고 한다. 간단히 말해, 이전 항에 상수를 곱하여 다음 항을 계산하여 등비수열을 만들 수 있다. 예를 들어, `2, 4, 8, 16`은 연속된 두 항의 비율(공비)가 모두 같으므로 등비수열이다 (4 / 2 = 8 / 4 = 16 / 8 = 2). @@ -39,8 +39,8 @@ **등비수열에 관련된 문제를 풀기 위한 일반적인 공식:** `a`가 초항, `r`이 공비일 때: -등비수열의 n번째 항 = `a * r^(n-1)`. +- 등비수열의 n번째 항 = `a * r^(n-1)`. - 기하평균 = `n개 항의 곱의 n제곱근`. - 등비급수 (r < 1) = `[a (1 – r^n)] / [1 – r]`. - 등비급수 (r > 1) = `[a (r^n – 1)] / [r – 1]`. From f07b360207d65eb24fceff6ee680f3e772ec9496 Mon Sep 17 00:00:00 2001 From: Doononi Date: Wed, 25 Aug 2021 11:55:40 +0900 Subject: [PATCH 05/17] added arithmetic sequence in ko basic math --- ...61\354\260\250\354\210\230\354\227\264.md" | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 "ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\354\260\250\354\210\230\354\227\264.md" diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\354\260\250\354\210\230\354\227\264.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\354\260\250\354\210\230\354\227\264.md" new file mode 100644 index 00000000..b095a486 --- /dev/null +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\354\260\250\354\210\230\354\227\264.md" @@ -0,0 +1,46 @@ +# 등차수열 + +연속된 두 항의 차이가 항상 같을 때 그 수열을 `등차수열`이라고 한다. 간단히 말해, 이전 항에 상수를 더하여 다음 항을 계산하여 등차수열을 만들 수 있다. + +예를 들어, `2, 4, 6, 8, 10`은 연속된 두 항의 차이(공차)가 모두 같으므로 등차수열이다 (4 - 2 = 6 - 4 = 8 - 6 = 10 - 8 = 2). + +

+ +

+ +**등차수열에 관한 사실들:** + +1. 초항: 등차수열에서, 수열의 첫 항은 초항이라고 불린다. +2. 공차: 연속된 두 항의 차이를 공차라고 한다. +3. 등차수열의 경향성은 공차 `d`에 따라 결정된다. 만약 공차가 양수라면, 모든 항은 양의 무한대를 향해 증가한다. 하지만 만약 공차가 음수라면, 모든 항은 음의 무한대를 향해 감소한다. + +**등차수열의 n번째 항 공식:** + +`a`가 초항이고, `d`가 공차일 때, n번째 항은: + +

+ +

+ +**등차급수(등차수열의 첫 n항의 합) 공식:** + +

+ +

+ +**등차수열에 관련된 물제를 풀기 위한 일반적인 공식:** + +`a`가 초항, `d`가 공차일 때: + +- 등차수열의 n번째 항 = `a + d*(n-1)`. +- 산술평균 = `전체 항의 합 / 항의 개수`. +- 등차급수 = `0.5 * n * (초항 + 말항)` = `0.5 * n * [2a + (n-1) d]`. + +## 출처 + +- [등차수열](https://www.geeksforgeeks.org/arithmetic-progression) + +## 영상 URL + +- [등차수열의 개념](https://youtu.be/gua96ju_FBk) +- [동적 계획법을 이용한 등차수열 구현 (C++)](https://youtu.be/U_qtSRQYoPs) From 1dde80f3de5e1f7de562908826f0513307a869b6 Mon Sep 17 00:00:00 2001 From: Doononi Date: Wed, 25 Aug 2021 13:01:14 +0900 Subject: [PATCH 06/17] added average in ko basic math --- .../\355\217\211\352\267\240\352\260\222.md" | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 "ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\217\211\352\267\240\352\260\222.md" diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\217\211\352\267\240\352\260\222.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\217\211\352\267\240\352\260\222.md" new file mode 100644 index 00000000..73cc63f6 --- /dev/null +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\217\211\352\267\240\352\260\222.md" @@ -0,0 +1,70 @@ +# 평균값 + +숫자로 구성된 리스트의 평균값을 계산한다. + +## 활용 + +평균값을 계산하는 것은 다음과 같은 상황에서 유용하다: + +- 비디오 게임에서 같은 레벨의 플레이어의 평균 점수 결정. +- 이번 학기 수강생의 평균 시험 성적 산출. +- 폴더 내 모든 파일의 평균 크기 결정. + +## 단계 + +1. 숫자로 구성된 리스트를 입력한다. +2. 리스트에 속한 수를 모두 합한다. +3. 리스트에 속한 수의 개수를 센다. +4. 합을 리스트에 속한 수의 개수로 나눈다. +5. 평균값을 반환한다. + +## 예시 + +`[2, 4, 6, 8, 20, 50, 70]`라는 리스트가 주어졌을 때, 이 리스트의 평균값을 구하라 + +### 1단계 + +`[2, 4, 6, 8, 20, 50, 70]`를 함수에 입력한다. + +### 2단계 + +리스트에 속한 수를 모두 합한다. + +`2 + 4 + 6 + 8 + 20 + 50 + 70 = 160`, 그러므로 `sum = 160`. + +### 3단계 + +리스트에 속한 수의 개수를 센다. + +위 리스트는 7개의 숫자를 가지고 있으므로, `count = 7`. + +### 4단계 + +모든 수의 합을 수의 개수로 나눈다. + +``` +sum = 160 +count = 7 +``` + +유효숫자를 무시하면: `sum / count = `22.857142 + +유효숫자를 고려하면: `sum / count = 23` + +### 5단계 + +22.857142나 `23`를 반환한다. + +## 구현 + +- [Python](https://github.com/TheAlgorithms/Python/blob/master/maths/average_mean.py) +- [Ruby](https://github.com/TheAlgorithms/Ruby/blob/master/maths/average_mean.rb) + +## 영상 URL + +- [Khan Academy](https://www.khanacademy.org/math/ap-statistics/summarizing-quantitative-data-ap/measuring-center-quantitative/v/mean-median-and-mode) + +## 기타 + +- [위키피디아 "평균" 항목](https://ko.wikipedia.org/wiki/%ED%8F%89%EA%B7%A0) +- [Wikipedia "Mean" 항목](https://en.wikipedia.org/wiki/Mean) From cd26eb966eadf17b4bc66e7bbcd8a0c2675bbf51 Mon Sep 17 00:00:00 2001 From: Doononi Date: Wed, 25 Aug 2021 14:12:26 +0900 Subject: [PATCH 07/17] added maximum number and revised ko basic math --- ko/README.md | 10 +- ...61\353\271\204\354\210\230\354\227\264.md" | 23 ++-- ...61\354\260\250\354\210\230\354\227\264.md" | 8 +- .../\354\236\220\353\246\277\354\210\230.md" | 103 ++++++++++++++++++ .../\354\265\234\353\214\223\352\260\222.md" | 98 +++++++++++++++++ .../\355\217\211\352\267\240\352\260\222.md" | 16 +-- ...4\353\202\230\354\271\230 \354\210\230.md" | 18 +-- 7 files changed, 238 insertions(+), 38 deletions(-) create mode 100644 "ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\354\236\220\353\246\277\354\210\230.md" create mode 100644 "ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\354\265\234\353\214\223\352\260\222.md" diff --git a/ko/README.md b/ko/README.md index 6090eccb..0f503ee5 100644 --- a/ko/README.md +++ b/ko/README.md @@ -8,18 +8,18 @@ 4. 만든 사람 5. 등... -## 단계 +## 절차 알고리즘을 명확하고 단순하며 이해하기 쉬운 단계로 구분하여 설명해주세요. ## 예시 -간단한 예시를 들어 알고리즘을 추적해주세요. +간단한 예시를 들어 알고리즘의 동작 과정을 보여주세요. ## 구현 -프로그래밍 언어로 구현된 알고리즘을 링크로 연결해주세요. -NOTE: 이 조직의 다른 저장소 안에 있는 링크만 연결해주세요. +다양한 프로그래밍 언어로 구현된 알고리즘을 링크로 연결해주세요. +NOTE: `TheAlgorithms`의 다른 저장소 안에 있는 링크만 연결해주세요. ## 영상 URL @@ -27,4 +27,4 @@ NOTE: 이 조직의 다른 저장소 안에 있는 링크만 연결해주세요. ## 기타 -다른 모든 정보는 언제든지 환영하며, 이 섹션에 포함해주세요. +다른 모든 정보는 이 섹션에 포함해주세요. diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" index 389f091d..f41df493 100644 --- "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" @@ -13,14 +13,13 @@ 1. **초항:** 등비수열에서, 첫 항은 초항이라고 불린다. 2. **공비:** 다음 항을 이전 항으로 나누어 나타낸 연속된 두 항의 비율 3. 등비수열은 공비에 따라 여러 경향을 보인다. 만약 공비가: - -- 양수이면, 모든 항은 첫 항과 같은 부호를 가진다. -- 음수이면, 부호가 번갈아 가며 나타난다. -- 1보다 크면, (초항의 부호에 따라) 양의 무한대 또는 음의 무한대를 향해 지수적으로 증가한다. -- 1이면, 모든 항의 값이 같은 상수수열이다. -- −1과 1사이에 있지만 0이 아니면, 0을 향해 지수적으로 감소한다. -- −1이면, 모든 항의 절댓값은 같지만, 부호가 번갈아 가며 나타난다. -- -1보다 작으면, 부호가 번갈아 가며 나타나고, 절대값은 양의 무한대를 향해 지수적으로 증가한다. + - 양수이면, 모든 항은 첫 항과 같은 부호를 가진다. + - 음수이면, 부호가 번갈아 가며 나타난다. + - 1보다 크면, (초항의 부호에 따라) 양의 무한대 또는 음의 무한대를 향해 지수적으로 증가한다. + - 1이면, 모든 항의 값이 같은 상수수열이다. + - −1과 1사이에 있지만 0이 아니면, 0을 향해 지수적으로 감소한다. + - −1이면, 모든 항의 절댓값은 같지만, 부호가 번갈아 가며 나타난다. + - -1보다 작으면, 부호가 번갈아 가며 나타나고, 절대값은 양의 무한대를 향해 지수적으로 증가한다. **등비수열의 n번째 항 공식:** @@ -46,11 +45,11 @@ - 등비급수 (r > 1) = `[a (r^n – 1)] / [r – 1]`. - 무한등비급수 (r < 1) = `(a) / (1 – r)`. -## 출처 - -- [등비수열](https://www.geeksforgeeks.org/geometric-progression/) - ## 영상 URL - [등비수열의 개념](https://youtu.be/gua96ju_FBk) - [동적 계획법을 이용한 등비수열 구현 (C++)](https://youtu.be/92ZldzuGUHs) + +## 출처 + +- [GeeksforGeeks](https://www.geeksforgeeks.org/geometric-progression/) diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\354\260\250\354\210\230\354\227\264.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\354\260\250\354\210\230\354\227\264.md" index b095a486..83ce8763 100644 --- "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\354\260\250\354\210\230\354\227\264.md" +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\354\260\250\354\210\230\354\227\264.md" @@ -36,11 +36,11 @@ - 산술평균 = `전체 항의 합 / 항의 개수`. - 등차급수 = `0.5 * n * (초항 + 말항)` = `0.5 * n * [2a + (n-1) d]`. -## 출처 - -- [등차수열](https://www.geeksforgeeks.org/arithmetic-progression) - ## 영상 URL - [등차수열의 개념](https://youtu.be/gua96ju_FBk) - [동적 계획법을 이용한 등차수열 구현 (C++)](https://youtu.be/U_qtSRQYoPs) + +## 출처 + +- [GeeksForGeeks](https://www.geeksforgeeks.org/arithmetic-progression) diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\354\236\220\353\246\277\354\210\230.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\354\236\220\353\246\277\354\210\230.md" new file mode 100644 index 00000000..175b2bb8 --- /dev/null +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\354\236\220\353\246\277\354\210\230.md" @@ -0,0 +1,103 @@ +# 자릿수 + +`N = 2019`이라고 할 때, `N`의 자릿수는 4이고, 각 자리의 숫자는 `2`, `0`, `1`, `9`이다. + +몇 가지 예시를 보면: + +``` +N = 00 [영(零)] +자릿수 = 0 + +N = -123 [음수] +자릿수 = 3 + +N = 10000 [양수] +자릿수 = 5 +``` + +## 간단한 방법 + +가장 먼저 떠오르는 방법은 간단하다: + + 1. 숫자 N이 0인지 확인한다. + 2. N이 0이 아닌 경우, 자릿수를 1 늘린다. + 3. N을 10으로 나눈다. + 4. N이 0이 될 때까지 위의 과정을 반복한다. + +**알고리즘 분석:** 위 방법에서 수행되는 작업의 수는 숫자 N의 자릿수와 같다는 사실을 쉽게 알 수 있다. 따라서 이 방법의 시간 복잡도는 $O(자릿수)$이다. + +**모의 실행:** `N = 58964`라고 할 때, + +자릿수를 저장할 변수 `digitsCount`를 0으로 초기화하고, `N`이 0이 아닌 동안 반복적으로 `digitsCount`를 늘리고 `N`을 10으로 나눈다. + +``` +Iteration 1: N not equals to 0 +Increment digitsCount, digitsCount = digitsCount + 1. +digitsCount = 0 + 1 = 1. +N = N/10 = 58964/10 = 5896. + +Iteration 2: N not equals to 0 +Increment digitsCount, digitsCount = digitsCount + 1. +digitsCount = 1 + 1 = 2. +N = N/10 = 5896/10 = 589. + +Iteration 3: N not equals to 0 +Increment digitsCount, digitsCount = digitsCount + 1. +digitsCount = 2 + 1 = 3. +N = N/10 = 589/10 = 58. + +Iteration 4: N not equals to 0 +Increment digitsCount, digitsCount = digitsCount + 1. +digitsCount = 3 + 1 = 4. +N = N/10 = 58/10 = 5. + +Iteration 5: N not equals to 0 +Increment digitsCount, digitsCount = digitsCount + 1. +digitsCount = 4 + 1 = 5. +N = N/10 = 5/10 = 0. + +Iteration 6: N becomes equal to 0. +Terminate any further operation. +Return value of digitsCount. +``` + +그러므로 `N`의 자릿수는 5이다. + +## 더 나은 방법 + +수학을 활용하면 더 나은 방법을 찾을 수 있다. N의 자릿수는 다음의 공식으로 쉽게 구할 수 있다: + +``` +N의 자릿수 = log10(N) + 1. +``` + +**유도:** `N`의 자릿수를 `K`라고 하면: + +``` +10^(K-1) <= N < 10^K +``` + +위 부등식의 양변에 상용로그(밑이 10인 로그)를 취하면: + +``` +K - 1 <= log10(N) < K. + +또는, K - 1 + 1 <= log10(N) + 1 < K + 1 +또는, K <= log10(N) + 1 < K + 1 +``` + +그러므로, + +``` +K = floor(log10(N) + 1) +``` + +**알고리즘 분석:** 위 방법은 `로그`와 `버림`이라는 수학적인 함수를 사용한다. 그러므로 이 방법의 시간 복잡도는 두 함수의 복잡도에 따라 달라진다. 버림함수는 소수점 이하의 숫자들을 버리기만 하면 되기 때문에 사실상 항상 일정한 시간이 걸린다 (적어도 그렇게 만들기 쉽다). 일반적으로 고정폭 부동 소수점 값을 사용하기 때문에 실용적으로는 `로그함수도 일정한 시간이 걸린다고 가정`할 수 있다. 하지만 임의 정밀도 "큰 수" 라이브러리를 사용하면, 사용되는 로그 알고리즘에 따라 로그함수의 성능이 달라질 수 있다. + +## 영상 URL + +- [자릿수 찾기 프로그램 구현 (C, C++)](https://www.youtube.com/watch?v=ngWnvWR8NkE) + +## 출처 + +- [GeeksforGeeks](https://www.geeksforgeeks.org/program-count-digits-integer-3-different-methods/) diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\354\265\234\353\214\223\352\260\222.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\354\265\234\353\214\223\352\260\222.md" new file mode 100644 index 00000000..6b3596cc --- /dev/null +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\354\265\234\353\214\223\352\260\222.md" @@ -0,0 +1,98 @@ +# 최댓값 + +숫자로 구성된 리스트의 최댓값을 찾는다. + +## 활용 + +리스트의 최댓값을 찾으면, 다음과 같은 작업들을 수행할 수 있다. + +- 가장 큰 값을 기준으로 레코드 정렬하기 +- 특정 항목을 탐색하는 시간 줄이기 + +## 방법 + +최댓값은 다양한 방식으로 찾을 수 있다. 여기서는 세 가지 방법을 제시한다. + +1. 리스트의 모든 원소를 비교한다. +2. 이미 정의된 함수를 사용한다. +3. 정렬한다. + +## 예시 1 + +리스트의 모든 원소를 비교한다: + +`[6, 4, 50, 8, 70, 2, 20]`라는 리스트가 주어졌을 때, 이 리스트의 최댓값을 구하라. + +### 1단계 + +`[6, 4, 50, 8, 70, 2, 20]`를 함수에 입력한다. + +### 2단계 + +비교 과정을 통해 가장 큰 숫자를 찾을 것이다. 리스트의 첫 원소를 최댓값으로 설정한다. + +`max = array[0]`이므로, `max = 6`이다. + +### 3단계 + +리스트의 모든 원소와 최댓값을 비교한다. 만약 원소가 최댓값보다 크면, 그 수를 최댓값으로 지정한다. + +`max`와 `array[2]`를 비교하면 `6 < 50`이므로, `max = 50`이 된다. + +모든 원소와 비교가 끝나면, `max = 70`이다. + +### 4단계 + +`70`을 반환한다. + +## 예시 2 + +이미 정의된 함수를 사용한다: + +`[6, 4, 50, 8, 70, 2, 20]`라는 리스트가 주어졌을 때, 이 리스트의 최댓값을 구하라. + +### 1단계 + +`[6, 4, 50, 8, 70, 2, 20]`를 함수에 입력한다. + +### 2단계 + +이미 정의된 `max` 함수가 `70`을 반환한다. + +### 3단계 + +`70`을 반환한다. + +## 예시 3 + +정렬한다: + +`[6, 4, 50, 8, 70, 2, 20]`라는 리스트가 주어졌을 때, 이 리스트의 최댓값을 구하라. + +### 1단계 + +`[6, 4, 50, 8, 70, 2, 20]`를 함수에 입력한다. + +### 2단계 + +이미 정의된 `sort` 함수가 전체 리스트를 오름차순으로 정렬하여 `[2, 4, 6, 8, 20, 50, 70]`을 반환한다. + +### 3단계 + +이미 정의된 `last` 함수가 리스트의 마지막 원소로 `70`을 반환한다. + +### 4단계 + +`70`을 반환한다. + +## 구현 + +- [Ruby](https://github.com/TheAlgorithms/Ruby/blob/master/maths/find_max.rb) + +## 영상 URL + +- [GeeksforGeeks](https://youtu.be/En68ipRaFOU) + +## 출처 + +- [GeeksforGeeks](https://www.geeksforgeeks.org/c-program-find-largest-element-array/) diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\217\211\352\267\240\352\260\222.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\217\211\352\267\240\352\260\222.md" index 73cc63f6..bf26c698 100644 --- "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\217\211\352\267\240\352\260\222.md" +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\217\211\352\267\240\352\260\222.md" @@ -6,11 +6,11 @@ 평균값을 계산하는 것은 다음과 같은 상황에서 유용하다: -- 비디오 게임에서 같은 레벨의 플레이어의 평균 점수 결정. -- 이번 학기 수강생의 평균 시험 성적 산출. -- 폴더 내 모든 파일의 평균 크기 결정. +- 비디오 게임에서 같은 레벨의 플레이어의 평균 점수 결정 +- 이번 학기 수강생의 평균 시험 성적 산출 +- 폴더 내 모든 파일의 평균 크기 결정 -## 단계 +## 절차 1. 숫자로 구성된 리스트를 입력한다. 2. 리스트에 속한 수를 모두 합한다. @@ -20,7 +20,7 @@ ## 예시 -`[2, 4, 6, 8, 20, 50, 70]`라는 리스트가 주어졌을 때, 이 리스트의 평균값을 구하라 +`[2, 4, 6, 8, 20, 50, 70]`라는 리스트가 주어졌을 때, 이 리스트의 평균값을 구하라. ### 1단계 @@ -30,7 +30,7 @@ 리스트에 속한 수를 모두 합한다. -`2 + 4 + 6 + 8 + 20 + 50 + 70 = 160`, 그러므로 `sum = 160`. +`2 + 4 + 6 + 8 + 20 + 50 + 70 = 160`이므로, `sum = 160`. ### 3단계 @@ -53,7 +53,7 @@ count = 7 ### 5단계 -22.857142나 `23`를 반환한다. +22.857142나 `23`을 반환한다. ## 구현 @@ -62,7 +62,7 @@ count = 7 ## 영상 URL -- [Khan Academy](https://www.khanacademy.org/math/ap-statistics/summarizing-quantitative-data-ap/measuring-center-quantitative/v/mean-median-and-mode) +- [평균값, 중앙값, 최빈값](https://www.khanacademy.org/math/ap-statistics/summarizing-quantitative-data-ap/measuring-center-quantitative/v/mean-median-and-mode) ## 기타 diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230.md" index 8ff96757..0cca3f49 100644 --- "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230.md" +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230.md" @@ -1,24 +1,24 @@ # 피보나치 수 -수학에서, 일반적으로 F(n)으로 표기되는 피보나치 수는 첫째 및 둘째 항이 1이며 그 뒤의 모든 항은 바로 앞 두 항의 합인 피보나치 수열을 구성한다. +수학에서, 일반적으로 $F(n)$으로 표기하는 피보나치 수는 첫째 및 둘째 항이 1이며 그 뒤의 모든 항은 바로 앞 두 항의 합인 피보나치 수열을 구성한다. `[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...]` ## 활용 -`N번째` 피보나치 수를 구하는 것은 다양하게 활용될 수 있다: +`N번째 피보나치 수`를 구하는 것은 다양하게 활용될 수 있다: - 최근 피보나치 수열과 황금비는 고에너지 물리학, 양자역학, 암호학, 코딩 등 다양한 과학 분야의 연구자들에게 큰 관심을 받고 있다. -## 단계 +## 절차 -1. 기본 행렬 준비하기 -2. 기본 행렬의 거듭제곱 계산하기 -3. 행렬 원소 중 해당 값 찾기 +1. 기본 행렬을 준비한다. +2. 기본 행렬의 거듭제곱을 계산한다. +3. 행렬의 원소 중 필요한 값을 찾는다. ## 예시 -`8번째` 피보나치 수를 구하라 +`8번째` 피보나치 수를 구하라. ### 0단계 @@ -62,7 +62,7 @@ ### 5단계 ``` -F(8)=21 +F(8) = 21 ``` ## 구현 @@ -74,7 +74,7 @@ F(8)=21 ## 영상 URL -- [Youtube](https://www.youtube.com/watch?v=EEb6JP3NXBI) +- [행렬 거듭제곱을 이용한 피보나치 수열 구현](https://www.youtube.com/watch?v=EEb6JP3NXBI) ## 기타 From ba0681c86c6735487cd31c26db281bbcfe117999 Mon Sep 17 00:00:00 2001 From: Lee Joonhun Date: Fri, 27 Aug 2021 14:01:53 +0900 Subject: [PATCH 08/17] added array and revised ko basic math --- ...\261\353\271\204\354\210\230\354\227\264.md" | 4 ++-- ...\261\354\260\250\354\210\230\354\227\264.md" | 6 +++--- .../\354\236\220\353\246\277\354\210\230.md" | 2 +- .../\355\217\211\352\267\240\352\260\222.md" | 2 +- ...264\353\202\230\354\271\230 \354\210\230.md" | 2 +- .../\353\260\260\354\227\264.md" | 17 +++++++++++++++++ 6 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 "ko/\354\236\220\353\243\214\352\265\254\354\241\260/\353\260\260\354\227\264/\353\260\260\354\227\264.md" diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" index f41df493..016de1e4 100644 --- "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" @@ -47,8 +47,8 @@ ## 영상 URL -- [등비수열의 개념](https://youtu.be/gua96ju_FBk) -- [동적 계획법을 이용한 등비수열 구현 (C++)](https://youtu.be/92ZldzuGUHs) +- [Don't Memorise](https://youtu.be/gua96ju_FBk) +- [Code Bashers (C++)](https://youtu.be/92ZldzuGUHs) ## 출처 diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\354\260\250\354\210\230\354\227\264.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\354\260\250\354\210\230\354\227\264.md" index 83ce8763..a760d77b 100644 --- "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\354\260\250\354\210\230\354\227\264.md" +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\354\260\250\354\210\230\354\227\264.md" @@ -38,9 +38,9 @@ ## 영상 URL -- [등차수열의 개념](https://youtu.be/gua96ju_FBk) -- [동적 계획법을 이용한 등차수열 구현 (C++)](https://youtu.be/U_qtSRQYoPs) +- [Don't Memorise](https://youtu.be/gua96ju_FBk) +- [iBytes Academy (C++)](https://youtu.be/U_qtSRQYoPs) ## 출처 -- [GeeksForGeeks](https://www.geeksforgeeks.org/arithmetic-progression) +- [GeeksforGeeks](https://www.geeksforgeeks.org/arithmetic-progression) diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\354\236\220\353\246\277\354\210\230.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\354\236\220\353\246\277\354\210\230.md" index 175b2bb8..3640aced 100644 --- "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\354\236\220\353\246\277\354\210\230.md" +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\354\236\220\353\246\277\354\210\230.md" @@ -96,7 +96,7 @@ K = floor(log10(N) + 1) ## 영상 URL -- [자릿수 찾기 프로그램 구현 (C, C++)](https://www.youtube.com/watch?v=ngWnvWR8NkE) +- [Programming Tutorials (C, C++)](https://www.youtube.com/watch?v=ngWnvWR8NkE) ## 출처 diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\217\211\352\267\240\352\260\222.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\217\211\352\267\240\352\260\222.md" index bf26c698..746a0ae9 100644 --- "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\217\211\352\267\240\352\260\222.md" +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\217\211\352\267\240\352\260\222.md" @@ -62,7 +62,7 @@ count = 7 ## 영상 URL -- [평균값, 중앙값, 최빈값](https://www.khanacademy.org/math/ap-statistics/summarizing-quantitative-data-ap/measuring-center-quantitative/v/mean-median-and-mode) +- [Khan Academy](https://www.khanacademy.org/math/ap-statistics/summarizing-quantitative-data-ap/measuring-center-quantitative/v/mean-median-and-mode) ## 기타 diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230.md" index 0cca3f49..2ce282e4 100644 --- "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230.md" +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230.md" @@ -74,7 +74,7 @@ F(8) = 21 ## 영상 URL -- [행렬 거듭제곱을 이용한 피보나치 수열 구현](https://www.youtube.com/watch?v=EEb6JP3NXBI) +- [Gaurav Sen](https://www.youtube.com/watch?v=EEb6JP3NXBI) ## 기타 diff --git "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\353\260\260\354\227\264/\353\260\260\354\227\264.md" "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\353\260\260\354\227\264/\353\260\260\354\227\264.md" new file mode 100644 index 00000000..a817bf7a --- /dev/null +++ "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\353\260\260\354\227\264/\353\260\260\354\227\264.md" @@ -0,0 +1,17 @@ +# 배열 + +배열은 프로그래밍에서 가장 기본적인 데이터 구조이다. 배열은 정적 배열과 동적 배열로 나눠진다. 정적 배열은 요소의 수가 고정되어 있고, 각각은 메모리의 동일한 공간을 차지한다. 즉, 정적 배열이 차지하는 메모리는 컴파일 시간에 결정되지만, 동적 배열의 경우 크기가 고정되지 않는다. + +배열 요소의 값은 `O(1)` 시간 안에 검색할 수 있다. + +모든 배열은 연속된 메모리 주소를 가진다. 우리는 인덱스로 각 요소에 접근할 수 있다. +가장 낮은 인덱스는 첫 요소에 해당하고 가장 높은 인덱스는 마지막 요소에 해당한다. + +## YouTube + +- [The Coding Train](https://youtu.be/NptnmWvkbTw) +- [Simple Snippets (C++)](https://youtu.be/ibeGtDEQGz0) + +## 영상 URL + +- [GeeksforGeeks](https://www.geeksforgeeks.org/introduction-to-arrays/) From d6f5d747cd3a0e96140af71c39ddcff04512a221 Mon Sep 17 00:00:00 2001 From: Lee Joonhun Date: Fri, 27 Aug 2021 16:26:15 +0900 Subject: [PATCH 09/17] added Bellman-Ford in ko data structure --- ...14\352\263\240\353\246\254\354\246\230.md" | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 "ko/\354\236\220\353\243\214\352\265\254\354\241\260/\352\267\270\353\236\230\355\224\204/\353\262\250\353\250\274-\355\217\254\353\223\234 \354\225\214\352\263\240\353\246\254\354\246\230.md" diff --git "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\352\267\270\353\236\230\355\224\204/\353\262\250\353\250\274-\355\217\254\353\223\234 \354\225\214\352\263\240\353\246\254\354\246\230.md" "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\352\267\270\353\236\230\355\224\204/\353\262\250\353\250\274-\355\217\254\353\223\234 \354\225\214\352\263\240\353\246\254\354\246\230.md" new file mode 100644 index 00000000..a2228016 --- /dev/null +++ "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\352\267\270\353\236\230\355\224\204/\353\262\250\353\250\274-\355\217\254\353\223\234 \354\225\214\352\263\240\353\246\254\354\246\230.md" @@ -0,0 +1,112 @@ +# 벨먼-포드 알고리즘 + +## 문제 + +방향 가중치 그래프 $G(V,E)$와 시작점 $s \in V$가 주어졌을 때, 각 점 $v \in V$에 대하여 $s$와 $v$를 잇는 가장 짧은 경로를 구하라. ($V$는 꼭짓점의 집합, $E$는 간선의 집합) + +## 절차 + +1. 시작점에서 모든 꼭짓점까지의 거리를 무한대로 초기화한다. +2. 시작점으로의 거리를 0으로 초기화한다. +3. `dist[s]`를 제외한 모든 값을 무한대로 하는 크기가 $|V|$인 `dist`라는 배열을 만든다. +4. 다음을 $|V|-1$회 반복한다. +5. $E$에 속한 모든 간선 `(u,v)`에 대해 다음을 반복한다: + + ``` + dist[v] = minimum(dist[v], dist[u] + weight of edge) + ``` + +6. 마지막으로 모든 간선에 대해 음의 사이클(negative cycle)이 없는지 확인한다. + +## 시간 복잡도 + +$O(VE)$ + +## 공간 복잡도 + +$O(V^2)$ + +## 만든 사람 + +- [리처드 벨먼](https://ko.wikipedia.org/wiki/%EB%A6%AC%EC%B2%98%EB%93%9C_%EB%B2%A8%EB%A8%BC) +- [래스터 포드 주니어](https://en.wikipedia.org/wiki/L._R._Ford_Jr.) + +## 예시 + +``` + 꼭짓점: [A, B, C, D, E] + + 간선: [A->B, A->C, B->C, B->D, B->E, D->C, D->B, E->D] + 가중치: [ -1, 4, 3, 2, 2, 5, 1, -4 ] + 시작점: [ A, A, B, B, B, D, D, E ] + + + + 꼭짓점 개수 = 5 + 간선 개수 = 8 + + // A->B + graph->edge[0].src = A + graph->edge[0].dest = B + graph->edge[0].weight = -1 + + // A->C + graph->edge[1].src = A + graph->edge[1].dest = C + graph->edge[1].weight = 4 + + // B->C + graph->edge[2].src = B + graph->edge[2].dest = C + graph->edge[2].weight = 3 + + // B->D + graph->edge[3].src = B + graph->edge[3].dest = D + graph->edge[3].weight = 2 + + // B->E + graph->edge[4].src = B + graph->edge[4].dest = E + graph->edge[4].weight = 2 + + // D->C + graph->edge[5].src = D + graph->edge[5].dest = C + graph->edge[5].weight = 5 + + // D->B + graph->edge[6].src = D + graph->edge[6].dest = B + graph->edge[6].weight = 1 + + // E->D + graph->edge[7].src = E + graph->edge[7].dest = D + graph->edge[7].weight = -3 + + for source = A + + Vertex Distance from Source + A 0 (A->A) + B -1 (A->B) + C 2 (A->B->C = -1 + 3) + D -2 (A->B->E->D = -1 + 2 + -3) + E 1 (A->B->E = -1 + 2) +``` + +## 구현 + +- [Java](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/BellmanFord.java) +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/Dynamic%20Programming/Bellman-Ford.cpp) +- [Python](https://github.com/TheAlgorithms/Python/blob/master/data_structures/graph/bellman_ford.py) +- [C](https://github.com/TheAlgorithms/C/blob/master/data_structures/graphs/Bellman-Ford.c) + +## 영상 URL + +- [Yusuf Shakeel (C)](https://www.youtube.com/watch?v=hxMWBBCpR6A) + +## 출처 + +- [GeeksforGeeks](https://www.geeksforgeeks.org/bellman-ford-algorithm-dp-23/) +- [위키피디아 "벨먼-포드 알고리즘" 항목](https://ko.wikipedia.org/wiki/%EB%B2%A8%EB%A8%BC-%ED%8F%AC%EB%93%9C_%EC%95%8C%EA%B3%A0%EB%A6%AC%EC%A6%98) From 066faf8999df960c6fbf15d527f055b91b2ad857 Mon Sep 17 00:00:00 2001 From: Lee Joonhun Date: Tue, 5 Oct 2021 15:29:49 +0900 Subject: [PATCH 10/17] Add singly linked list in ko data structure --- ...0 \353\246\254\354\212\244\355\212\270.md" | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 "ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" diff --git "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" new file mode 100644 index 00000000..2896534a --- /dev/null +++ "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" @@ -0,0 +1,49 @@ +# 단일 연결 리스트 + +단일 연결 리스트는 선형으로 연결된 데이터 구조로, 노드로 구성되어 있다. 각 노드는 내용이 저장된 `data` 변수와 다음 노드를 가리키는 `pointer`로 구성되어 있다. 연결 리스트는 이런 노드들의 첫 원소를 가리키는 포인터를 가지며, 연산에 걸리는 시간을 훨씬 절약하기 위해 마지막 노드를 가리키는 포인터를 가질 수도 있다. 전체 노드 수를 저장하는 `length` 변수를 추가할 수도 있다. + +### 배열보다 우수한 점 + +- 연결 리스트의 크기는 고정되어 있지 않다. (가변 크기) +- 배열에 비해 원소의 제거와 추가가 쉽다. + +### 단점 + +- 원소에 순차적으로 접근해야 한다. (임의 접근 불가) +- 포인터를 저장하기 위해 추가적인 메모리가 필요하다. + +### 시간 복잡도 + +| 연산 | 평균 | 최악 | +| ---- | ------ | ------ | +| 접근 | $O(n)$ | $O(n)$ | +| 탐색 | $O(n)$ | $O(n)$ | +| 삽입 | $O(1)$ | $O(1)$ | +| 제거 | $O(1)$ | $O(1)$ | + +## 예시 + +```java +class LinkedList { + Node head; // Pointer to the first element + Node tail; // Optional. Points to the last element + + int length; // Optional + + class Node { + int data; // Node data. Can be int, string, float, templates, etc + Node next; // Pointer to the next node on the list + } +} +``` + +## 구현 + +- [Java](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/SinglyLinkedList.java) +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/Data%20Structure/Linked%20List.cpp) +- [Python](https://github.com/TheAlgorithms/Python/blob/master/data_structures/linked_list/singly_linked_list.py) +- [Ruby](https://github.com/TheAlgorithms/Ruby/blob/master/data_structures/linked_lists/single_list.rb) + +## 영상 URL + +[CS50](https://www.youtube.com/watch?v=5nsKtQuT6E8) From 714563d681af3f3ab5ae486d3bdad53e3d094981 Mon Sep 17 00:00:00 2001 From: Lee Joonhun Date: Tue, 5 Oct 2021 15:52:37 +0900 Subject: [PATCH 11/17] Add doubly linked list in ko data structure --- ...0 \353\246\254\354\212\244\355\212\270.md" | 4 +- ...0 \353\246\254\354\212\244\355\212\270.md" | 114 ++++++++++++++++++ 2 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 "ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\354\235\264\354\244\221 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" diff --git "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" index 2896534a..f57161cd 100644 --- "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" +++ "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" @@ -14,7 +14,7 @@ ### 시간 복잡도 -| 연산 | 평균 | 최악 | +| 작업 | 평균 | 최악 | | ---- | ------ | ------ | | 접근 | $O(n)$ | $O(n)$ | | 탐색 | $O(n)$ | $O(n)$ | @@ -46,4 +46,4 @@ class LinkedList { ## 영상 URL -[CS50](https://www.youtube.com/watch?v=5nsKtQuT6E8) +- [CS50](https://www.youtube.com/watch?v=5nsKtQuT6E8) diff --git "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\354\235\264\354\244\221 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\354\235\264\354\244\221 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" new file mode 100644 index 00000000..823272ed --- /dev/null +++ "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\354\235\264\354\244\221 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" @@ -0,0 +1,114 @@ +# 이중 연결 리스트 + +단일 연결 리스트는 선형으로 연결된 데이터 구조로, 노드로 구성되어 있다. 각 노드는 내용이 저장된 `data` 변수와 다음 노드를 가리키는 `pointer`로 구성되어 있다. 연결 리스트는 이런 노드들의 첫 원소를 가리키는 포인터를 가지며, 연산에 걸리는 시간을 훨씬 절약하기 위해 마지막 노드를 가리키는 포인터를 가질 수도 있다. 전체 노드 수를 저장하는 `length` 변수를 추가할 수도 있다. + +**이중 연결 리스트 (DLL)** 는 여기에 더해 이전 노드를 가리키는 `previous pointer`라는 추가적인 포인터도 가진다. + +### 단일 연결 리스트보다 우수한 점 + +- 정방향과 역방향 순회가 가능하다. +- 제거될 노드를 가리키는 포인터가 알려져 있다면, 원소의 제거가 더 효율적이다. +- 특정 노드 앞에 새로운 노드를 빠르게 삽입할 수 있다. +- 단일 연결 리스트에서 노드를 제거하려면 이전 노드의 `pointer`를 알아야 한다. 어쩌면 이 노드를 찾기 위해 리스트를 전부 순회해야 할 수도 있다. 그러나 DLL에서는 `previous pointer`를 이용하여 이전 노드를 찾을 수 있다. + +### 단점 + +- 포인터를 저장하기 위한 메모리가 단일 연결 리스트보다 더 많이 필요하다. 그러나 포인터 하나로 DLL을 구현할 수도 있다. +- 모든 작업에 추가적인 연산이 필요하다. 예를 들어, 삽입 시 `pointer`와 `previous pointer`를 모두 수정해야 한다. + +### 시간 복잡도 + +| 작업 | 평균 | 최악 | +| ---- | ------ | ------ | +| 접근 | $Θ(n)$ | $O(n)$ | +| 탐색 | $Θ(n)$ | $O(n)$ | +| 삽입 | $Θ(1)$ | $O(1)$ | +| 제거 | $Θ(1)$ | $O(1)$ | + +## 예시 + +```java +class LinkedList { + + Node head; // Pointer to the first element + Node tail; // Optional. Points to the last element + + int length; // Optional + + class Node { + int data; // Node data. Can be int, string, float, templates, etc + Node next; // Pointer to the next node on the list + Node prev; + + Node(int data) { + this.data = data; + } + } +``` + +- 맨 앞에 노드 추가하기 + ![Tracing of algorithm](https://www.geeksforgeeks.org/wp-content/uploads/gq/2014/03/DLL_add_front1.png) + + ```java + public void push(int new_data) { + + /* 1. allocate node + 2. put in the data */ + Node new_Node = new Node(new_data); + + /* 3. Make next of new node as head and previous as NULL */ + new_Node.next = head; + new_Node.prev = null; + + /* 4. change prev of head node to new node */ + if (head != null) + head.prev = new_Node; + + /* 5. move the head to point to the new node */ + head = new_Node; + } + ``` + +- 주어진 노드 뒤에 노드 추가하기 + ![Tracing of algorithm](https://www.geeksforgeeks.org/wp-content/uploads/gq/2014/03/DLL_add_middle1.png) + + ```java + public void InsertAfter(Node prev_Node, int new_data) { + + /*1. check if the given prev_node is NULL */ + if (prev_Node == null) { + System.out.println("The given previous node cannot be NULL "); + return; + } + + /* 2. allocate node + 3. put in the data */ + Node new_node = new Node(new_data); + + /* 4. Make next of new node as next of prev_node */ + new_node.next = prev_Node.next; + + /* 5. Make the next of prev_node as new_node */ + prev_Node.next = new_node; + + /* 6. Make prev_node as previous of new_node */ + new_node.prev = prev_Node; + + /* 7. Change previous of new_node's next node */ + if (new_node.next != null) + new_node.next.prev = new_node; + } + } + ``` + +## 구현 + +- [Java](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/DoublyLinkedList.java) +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/Data%20Structure/Doubly%20Linked%20List.cpp) +- [Python](https://github.com/TheAlgorithms/Python/blob/master/data_structures/linked_list/doubly_linked_list.py) +- [Go](https://github.com/TheAlgorithms/Go/blob/master/data-structures/linked-list/double-linkedlist.go) +- [Ruby](https://github.com/TheAlgorithms/Ruby/blob/master/data_structures/linked_lists/double_list.rb) + +## 영상 URL + +- [CS50](https://www.youtube.com/watch?v=FHMPswJDCvU) From 6b34bfc4ac53fcc2b242c5846ced1288566e9bde Mon Sep 17 00:00:00 2001 From: Lee Joonhun Date: Wed, 6 Oct 2021 12:08:31 +0900 Subject: [PATCH 12/17] Revise ko data structure --- ...227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" | 2 +- ...227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" index f57161cd..f07f5144 100644 --- "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" +++ "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" @@ -1,6 +1,6 @@ # 단일 연결 리스트 -단일 연결 리스트는 선형으로 연결된 데이터 구조로, 노드로 구성되어 있다. 각 노드는 내용이 저장된 `data` 변수와 다음 노드를 가리키는 `pointer`로 구성되어 있다. 연결 리스트는 이런 노드들의 첫 원소를 가리키는 포인터를 가지며, 연산에 걸리는 시간을 훨씬 절약하기 위해 마지막 노드를 가리키는 포인터를 가질 수도 있다. 전체 노드 수를 저장하는 `length` 변수를 추가할 수도 있다. +단일 연결 리스트는 선형으로 연결된 자료구조로, 노드로 구성되어 있다. 각 노드는 내용이 저장된 `data` 변수와 다음 노드를 가리키는 `pointer`로 구성되어 있다. 연결 리스트는 이런 노드들의 첫 원소를 가리키는 포인터를 가지며, 연산에 걸리는 시간을 훨씬 절약하기 위해 마지막 노드를 가리키는 포인터를 가질 수도 있다. 전체 노드 수를 저장하는 `length` 변수를 추가할 수도 있다. ### 배열보다 우수한 점 diff --git "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\354\235\264\354\244\221 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\354\235\264\354\244\221 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" index 823272ed..5e4e25a0 100644 --- "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\354\235\264\354\244\221 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" +++ "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\354\235\264\354\244\221 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" @@ -1,6 +1,6 @@ # 이중 연결 리스트 -단일 연결 리스트는 선형으로 연결된 데이터 구조로, 노드로 구성되어 있다. 각 노드는 내용이 저장된 `data` 변수와 다음 노드를 가리키는 `pointer`로 구성되어 있다. 연결 리스트는 이런 노드들의 첫 원소를 가리키는 포인터를 가지며, 연산에 걸리는 시간을 훨씬 절약하기 위해 마지막 노드를 가리키는 포인터를 가질 수도 있다. 전체 노드 수를 저장하는 `length` 변수를 추가할 수도 있다. +단일 연결 리스트는 선형으로 연결된 자료구조로, 노드로 구성되어 있다. 각 노드는 내용이 저장된 `data` 변수와 다음 노드를 가리키는 `pointer`로 구성되어 있다. 연결 리스트는 이런 노드들의 첫 원소를 가리키는 포인터를 가지며, 연산에 걸리는 시간을 훨씬 절약하기 위해 마지막 노드를 가리키는 포인터를 가질 수도 있다. 전체 노드 수를 저장하는 `length` 변수를 추가할 수도 있다. **이중 연결 리스트 (DLL)** 는 여기에 더해 이전 노드를 가리키는 `previous pointer`라는 추가적인 포인터도 가진다. From 2d306ae2b3d8cb205faf53d838a302d87d04f941 Mon Sep 17 00:00:00 2001 From: Lee Joonhun Date: Wed, 6 Oct 2021 12:39:11 +0900 Subject: [PATCH 13/17] Add ko binary search and revise previous works --- ...14\352\263\240\353\246\254\354\246\230.md" | 3 +- .../\353\260\260\354\227\264.md" | 2 +- ...0 \353\246\254\354\212\244\355\212\270.md" | 10 +-- ...0 \353\246\254\354\212\244\355\212\270.md" | 47 ++++++------- ...4\354\247\204 \355\203\220\354\203\211.md" | 70 +++++++++++++++++++ 5 files changed, 100 insertions(+), 32 deletions(-) create mode 100644 "ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\235\264\354\247\204 \355\203\220\354\203\211.md" diff --git "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\352\267\270\353\236\230\355\224\204/\353\262\250\353\250\274-\355\217\254\353\223\234 \354\225\214\352\263\240\353\246\254\354\246\230.md" "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\352\267\270\353\236\230\355\224\204/\353\262\250\353\250\274-\355\217\254\353\223\234 \354\225\214\352\263\240\353\246\254\354\246\230.md" index a2228016..00494f51 100644 --- "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\352\267\270\353\236\230\355\224\204/\353\262\250\353\250\274-\355\217\254\353\223\234 \354\225\214\352\263\240\353\246\254\354\246\230.md" +++ "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\352\267\270\353\236\230\355\224\204/\353\262\250\353\250\274-\355\217\254\353\223\234 \354\225\214\352\263\240\353\246\254\354\246\230.md" @@ -41,7 +41,6 @@ $O(V^2)$ 시작점: [ A, A, B, B, B, D, D, E ] - 꼭짓점 개수 = 5 간선 개수 = 8 @@ -87,7 +86,7 @@ $O(V^2)$ for source = A - Vertex Distance from Source + 꼭짓점 시작점으로부터의 거리 A 0 (A->A) B -1 (A->B) C 2 (A->B->C = -1 + 3) diff --git "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\353\260\260\354\227\264/\353\260\260\354\227\264.md" "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\353\260\260\354\227\264/\353\260\260\354\227\264.md" index a817bf7a..5f57efc1 100644 --- "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\353\260\260\354\227\264/\353\260\260\354\227\264.md" +++ "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\353\260\260\354\227\264/\353\260\260\354\227\264.md" @@ -2,7 +2,7 @@ 배열은 프로그래밍에서 가장 기본적인 데이터 구조이다. 배열은 정적 배열과 동적 배열로 나눠진다. 정적 배열은 요소의 수가 고정되어 있고, 각각은 메모리의 동일한 공간을 차지한다. 즉, 정적 배열이 차지하는 메모리는 컴파일 시간에 결정되지만, 동적 배열의 경우 크기가 고정되지 않는다. -배열 요소의 값은 `O(1)` 시간 안에 검색할 수 있다. +배열 요소의 값은 $O(1)$ 시간 안에 검색할 수 있다. 모든 배열은 연속된 메모리 주소를 가진다. 우리는 인덱스로 각 요소에 접근할 수 있다. 가장 낮은 인덱스는 첫 요소에 해당하고 가장 높은 인덱스는 마지막 요소에 해당한다. diff --git "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" index f07f5144..3bdd7cec 100644 --- "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" +++ "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" @@ -25,14 +25,14 @@ ```java class LinkedList { - Node head; // Pointer to the first element - Node tail; // Optional. Points to the last element + Node head; // 첫 원소를 가리키는 포인터 + Node tail; // (Optional) 마지막 원소를 가리키는 포인터 - int length; // Optional + int length; // (Optional) 전체 노드 수 class Node { - int data; // Node data. Can be int, string, float, templates, etc - Node next; // Pointer to the next node on the list + int data; // 노드의 데이터 + Node next; // 다음 노드를 가리키는 포인터 } } ``` diff --git "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\354\235\264\354\244\221 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\354\235\264\354\244\221 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" index 5e4e25a0..499d2586 100644 --- "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\354\235\264\354\244\221 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" +++ "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\354\235\264\354\244\221 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" @@ -29,15 +29,14 @@ ```java class LinkedList { + Node head; // 첫 원소를 가리키는 포인터 + Node tail; // (Optional) 마지막 원소를 가리키는 포인터 - Node head; // Pointer to the first element - Node tail; // Optional. Points to the last element - - int length; // Optional + int length; // (Optional) 전체 노드 수 class Node { - int data; // Node data. Can be int, string, float, templates, etc - Node next; // Pointer to the next node on the list + int data; // 노드의 데이터 + Node next; // 다음 노드를 가리키는 포인터 Node prev; Node(int data) { @@ -52,19 +51,19 @@ class LinkedList { ```java public void push(int new_data) { - /* 1. allocate node - 2. put in the data */ + /* 1. 노드를 만든다 + 2. 데이터를 입력한다다 */ Node new_Node = new Node(new_data); - /* 3. Make next of new node as head and previous as NULL */ + /* 3. 새로운 노드의 next 변수를 head로, prev 변수를 NULL로 설정한다 */ new_Node.next = head; new_Node.prev = null; - /* 4. change prev of head node to new node */ + /* 4. head의 prev 변수를 새로운 노드로 변경한다 */ if (head != null) head.prev = new_Node; - /* 5. move the head to point to the new node */ + /* 5. head를 새로운 노드로 변경한다 */ head = new_Node; } ``` @@ -75,28 +74,28 @@ class LinkedList { ```java public void InsertAfter(Node prev_Node, int new_data) { - /*1. check if the given prev_node is NULL */ + /*1. 주어진 prev_Node가 NULL인지 확인한다 */ if (prev_Node == null) { System.out.println("The given previous node cannot be NULL "); return; } - /* 2. allocate node - 3. put in the data */ - Node new_node = new Node(new_data); + /* 2. 노드를 만든다 + 3. 데이터를 입력한다 */ + Node new_Node = new Node(new_data); - /* 4. Make next of new node as next of prev_node */ - new_node.next = prev_Node.next; + /* 4. 새로운 노드의 next 변수를 prev_Node의 next 변수값으로 설정한다 */ + new_Node.next = prev_Node.next; - /* 5. Make the next of prev_node as new_node */ - prev_Node.next = new_node; + /* 5. prev_Node의 next 변수를 새로운 노드로 변경한다 */ + prev_Node.next = new_Node; - /* 6. Make prev_node as previous of new_node */ - new_node.prev = prev_Node; + /* 6. 새로운 노드의 prev 변수를 prev_Node로 설정한다 */ + new_Node.prev = prev_Node; - /* 7. Change previous of new_node's next node */ - if (new_node.next != null) - new_node.next.prev = new_node; + /* 7. 새로운 노드의 다음 노드의 prev 변수를 새로운 노드로 변경한다 */ + if (new_Node.next != null) + new_Node.next.prev = new_Node; } } ``` diff --git "a/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\235\264\354\247\204 \355\203\220\354\203\211.md" "b/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\235\264\354\247\204 \355\203\220\354\203\211.md" new file mode 100644 index 00000000..7dee056b --- /dev/null +++ "b/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\235\264\354\247\204 \355\203\220\354\203\211.md" @@ -0,0 +1,70 @@ +# 이진 탐색 (분할 정복 알고리즘) + +## 문제 + +n개 원소로 구성된 정렬된 배열이 주어졌을 때, 특정 원소의 인덱스를 찾는 함수를 구하라. + +## 절차 + +배열을 반복적으로 절반으로 나누어 배열을 탐색한다. + +1. 주어진 배열의 중간 원소를 고르고, 인덱스의 최소값과 최대값을 저장한다. +2. 만약 중간 원소가 찾고자 하는 원소와 같다면 중간 원소의 인덱스를 반환한다. + - 만약 중간 원소가 찾고자 하는 원소보다 크다면, 배열의 왼쪽 절반만 고려한다. + - 만약 중간 원소가 찾고자 하는 원소보다 작다면, 배열의 오른쪽 절반만 고려한다. +3. 만약 찾고자 하는 원소가 없다면 -1을 반환한다. + +## 시간 복잡도 + +- 최악: $O(\log n)$ +- 최선: $O(1)$ (중간 원소가 찾고자 하는 원소일 때) + +## 공간 복잡도 + +- 반복문 사용 시: $O(1)$ +- 재귀적인 방법 사용 시: $O(\log n)$ + +## 예시 + +``` +arr = [1, 2, 3, 4, 5, 6, 7] +target = 2 + +중간 원소는 4로, 목표인 2보다 크다. 그러므로 배열의 왼쪽 절반을 탐색한다. + +arr = [1, 2, 3] + +Here we find the middle element equal to target element so we return its index i.e. 1 +중간 원소가 목표와 같으므로 이 원소의 인덱스를 반환한다. +``` + +``` +arr = [1, 2, 3, 4, 5, 6, 7] +target = 9 + +중간 원소는 4로, 목표인 9보다 작다. 그러므로 배열의 오른쪽 절반을 탐색한다. + +arr = [5, 6, 7] + +중간 원소는 6으로, 목표보다 작다. 그러므로 오른쪽 절반을 탐색한다. + +arr = [7] + +유일한 원소가 목표와 같지 않으므로 9가 배열에 들어있지 않다고 판단하여 -1을 반환한다. +``` + +## 구현 + +- [Java](https://github.com/TheAlgorithms/Java/blob/master/Searches/BinarySearch.java) +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/Search/Binary%20Search.cpp) +- [Python](https://github.com/TheAlgorithms/Python/blob/master/searches/binary_search.py) +- [C#](https://github.com/TheAlgorithms/C-Sharp/blob/master/searches/binary_search.cs) +- [C](https://github.com/TheAlgorithms/C/blob/master/searching/Binary_Search.c) + +## 영상 URL + +- [CS50](https://www.youtube.com/watch?v=5xlIPT1FRcA) + +## 기타 + +- [Tute Board](https://boardhub.github.io/tute/?wd=binarySearchAlgo2) From 7e4913c1e55a0def6d74502f6f64e38e732d7014 Mon Sep 17 00:00:00 2001 From: Lee Joonhun Date: Wed, 6 Oct 2021 13:09:18 +0900 Subject: [PATCH 14/17] Complete searching algorithms --- ...0\355\230\225 \355\203\220\354\203\211.md" | 59 +++++++++++++++++ ...4\354\247\204 \355\203\220\354\203\211.md" | 3 +- ...0\354\210\230 \355\203\220\354\203\211.md" | 64 +++++++++++++++++++ 3 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 "ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\204\240\355\230\225 \355\203\220\354\203\211.md" create mode 100644 "ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\247\200\354\210\230 \355\203\220\354\203\211.md" diff --git "a/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\204\240\355\230\225 \355\203\220\354\203\211.md" "b/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\204\240\355\230\225 \355\203\220\354\203\211.md" new file mode 100644 index 00000000..65974985 --- /dev/null +++ "b/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\204\240\355\230\225 \355\203\220\354\203\211.md" @@ -0,0 +1,59 @@ +# 선형 탐색 + +## 문제 + +n개 원소로 구성된 배열이 주어졌을 때, 특정 원소의 인덱스를 찾는 함수를 구하라. + +## 절차 + +1. 배열의 첫 원소와 찾고자 하는 원소를 비교한다. +2. 만약 같다면 그 인덱스를 반환한다. + - 만약 다르다면, 다음 원소와 찾고자 하는 원소를 비교한다. +3. 만약 찾고자 하는 원소가 없다면 -1을 반환한다. + +## 시간 복잡도 + +- 최악: $O(n)$ +- 최선: $O(1)$ (첫 원소가 찾고자 하는 원소일 때) + +## 공간 복잡도 + +- $O(1)$ + +## 예시 + +``` +arr = [1, 3, 9, 5, 0, 2] +target = 5 + +1과 5가 같지 않으므로 다음 원소와 목표를 비교한다. +3과 5가 같지 않으므로 다음 원소와 목표를 비교한다. +9과 5가 같지 않으므로 다음 원소와 목표를 비교한다. +5가 4번째 위치에 있으므로 3을 반환한다. +``` + +``` +arr = [1, 3, 9, 5, 0, 2] +target = 6 + +1과 6이 같지 않으므로 다음 원소와 목표를 비교한다. +3과 6이 같지 않으므로 다음 원소와 목표를 비교한다. +9과 6이 같지 않으므로 다음 원소와 목표를 비교한다. +5와 6이 같지 않으므로 다음 원소와 목표를 비교한다. +0과 6이 같지 않으므로 다음 원소와 목표를 비교한다. +마지막 원소가 목표와 같지 않으므로 6이 배열에 들어있지 않다고 판단하여 -1을 반환한다. +``` + +## 구현 + +- [Java](https://github.com/TheAlgorithms/Java/blob/master/Searches/LinearSearch.java) +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/Search/Linear%20Search.cpp) +- [Python](https://github.com/TheAlgorithms/Python/blob/master/searches/linear_search.py) + +## 영상 URL + +[CS50](https://www.youtube.com/watch?v=CX2CYIJLwfg) + +## 기타 + +- [Tute Board](https://boardhub.github.io/tute/?wd=linearSearchAlgo) diff --git "a/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\235\264\354\247\204 \355\203\220\354\203\211.md" "b/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\235\264\354\247\204 \355\203\220\354\203\211.md" index 7dee056b..2a27967c 100644 --- "a/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\235\264\354\247\204 \355\203\220\354\203\211.md" +++ "b/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\235\264\354\247\204 \355\203\220\354\203\211.md" @@ -2,7 +2,7 @@ ## 문제 -n개 원소로 구성된 정렬된 배열이 주어졌을 때, 특정 원소의 인덱스를 찾는 함수를 구하라. +n개 원소로 구성된 **정렬된** 배열이 주어졌을 때, 특정 원소의 인덱스를 찾는 함수를 구하라. ## 절차 @@ -34,7 +34,6 @@ target = 2 arr = [1, 2, 3] -Here we find the middle element equal to target element so we return its index i.e. 1 중간 원소가 목표와 같으므로 이 원소의 인덱스를 반환한다. ``` diff --git "a/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\247\200\354\210\230 \355\203\220\354\203\211.md" "b/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\247\200\354\210\230 \355\203\220\354\203\211.md" new file mode 100644 index 00000000..f3140f2a --- /dev/null +++ "b/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\247\200\354\210\230 \355\203\220\354\203\211.md" @@ -0,0 +1,64 @@ +# 지수 탐색 + +## 알아야 하는 내용 + +- [이진 탐색](./이진%20탐색.md) + +## 문제 + +n개 원소로 구성된 **정렬된** 배열이 주어졌을 때, 특정 원소의 인덱스를 찾는 함수를 구하라. + +## 절차 + +1. 인덱스를 2배씩 늘려가며 찾고자 하는 원소가 속하는 범위를 찾는다. +2. 만약 찾고자 하는 원소가 속하는 범위를 찾는다면, 해당 범위에서 이진 탐색을 수행한다. +3. 만약 찾고자 하는 원소가 속하는 범위가 없다면 -1을 반환한다. + +## 시간 복잡도 + +- 최악: $O(\log i)$ ($i$는 찾고자 하는 원소의 인덱스) +- 최선: $O(1)$ + +$i$가 찾고자 하는 원소의 인덱스라고 할 때, 탐색을 $\lceil \log i \rceil$번 수행하기 때문에 찾고자 하는 원소가 속하는 범위를 찾는 과정의 복잡도는 $O(\log i)$이다. + +이진 탐색을 수행하는 과정의 복잡도는 이진 탐색의 복잡도와 동일하게 $O(\log i)$이다. (참고: [이진 탐색](./이진%20탐색.md)) + +그러므로, 지수 탐색의 복잡도는 다음과 같이 쓸 수 있다. + +```mathematica +O(log i) + O(log i) = 2O(log i) = O(log i) +``` + +## 예시 + +``` +arr = [1, 2, 3, 4, 5, 6, 7, ... 998, 999, 1000] +target = 998 + +1. 찾고자 하는 원소가 속하는 범위 탐색 + arr[1]이 998보다 작으므로 인덱스를 2배 늘린다. + arr[2]이 998보다 작으므로 인덱스를 2배 늘린다. + arr[4]이 998보다 작으므로 인덱스를 2배 늘린다. + arr[8]이 998보다 작으므로 인덱스를 2배 늘린다. + arr[16]이 998보다 작으므로 인덱스를 2배 늘린다. + arr[32]이 998보다 작으므로 인덱스를 2배 늘린다. + arr[64]이 998보다 작으므로 인덱스를 2배 늘린다. + arr[128]이 998보다 작으므로 인덱스를 2배 늘린다. + arr[256]이 998보다 작으므로 인덱스를 2배 늘린다. + arr[512]이 998보다 작으므로 인덱스를 2배 늘린다. + arr[1024]가 존재하지 않으므로 512 이상의 범위에 대해 이진 탐색을 수행한다. + +2. 이진 탐색 +``` + +## 이진 탐색과의 비교 + +논의의 편의를 위해 덜 이론적인 예시를 살펴보자. 1,000,000개 원소로 이루어진 배열에서 4번째에 위치한 원소를 찾는다고 할 때, + +- 이진 탐색은 배열의 중간부터 시작하여 많은 반복문을 지나야 4번째 원소에 도착한다. +- 지수 탐색은 2번 만에 4번째 원소에 도착한다. + +## 구현 + +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/search/exponential_search.cpp) +- [JavaScript](https://github.com/TheAlgorithms/Javascript/blob/master/Search/ExponentialSearch.js) From b4337639e9e667fbc649558de443768976596987 Mon Sep 17 00:00:00 2001 From: Lee Joonhun Date: Wed, 6 Oct 2021 13:34:45 +0900 Subject: [PATCH 15/17] Make latex visible on github --- ...3\223\261\353\271\204\354\210\230\354\227\264.md" | 12 +++++------- ...3\223\261\354\260\250\354\210\230\354\227\264.md" | 9 ++++----- .../\354\236\220\353\246\277\354\210\230.md" | 2 +- .../\355\217\211\352\267\240\352\260\222.md" | 6 +++--- ...4\225\214\352\263\240\353\246\254\354\246\230.md" | 12 ++++++------ .../\353\260\260\354\227\264.md" | 9 +++------ ...\262\260 \353\246\254\354\212\244\355\212\270.md" | 12 ++++++------ ...\262\260 \353\246\254\354\212\244\355\212\270.md" | 12 ++++++------ ...\204\240\355\230\225 \355\203\220\354\203\211.md" | 6 +++--- ...\235\264\354\247\204 \355\203\220\354\203\211.md" | 8 ++++---- ...\247\200\354\210\230 \355\203\220\354\203\211.md" | 8 +++----- 11 files changed, 44 insertions(+), 52 deletions(-) diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" index 016de1e4..71c9c6cf 100644 --- "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\353\271\204\354\210\230\354\227\264.md" @@ -23,7 +23,7 @@ **등비수열의 n번째 항 공식:** -`a`가 초항이고, `r`이 공비일 때, n번째 항은: +가 초항, 이 공비일 때, 번째 항은:

@@ -37,13 +37,11 @@ **등비수열에 관련된 문제를 풀기 위한 일반적인 공식:** -`a`가 초항, `r`이 공비일 때: +가 초항, 이 공비일 때: -- 등비수열의 n번째 항 = `a * r^(n-1)`. -- 기하평균 = `n개 항의 곱의 n제곱근`. -- 등비급수 (r < 1) = `[a (1 – r^n)] / [1 – r]`. -- 등비급수 (r > 1) = `[a (r^n – 1)] / [r – 1]`. -- 무한등비급수 (r < 1) = `(a) / (1 – r)`. +- 등비급수 (r < 1) = +- 등비급수 (r > 1) = +- 무한등비급수 (r < 1) = ## 영상 URL diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\354\260\250\354\210\230\354\227\264.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\354\260\250\354\210\230\354\227\264.md" index a760d77b..03a96763 100644 --- "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\354\260\250\354\210\230\354\227\264.md" +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\353\223\261\354\260\250\354\210\230\354\227\264.md" @@ -16,7 +16,7 @@ **등차수열의 n번째 항 공식:** -`a`가 초항이고, `d`가 공차일 때, n번째 항은: +가 초항, 가 공차일 때, 번째 항은:

@@ -30,11 +30,10 @@ **등차수열에 관련된 물제를 풀기 위한 일반적인 공식:** -`a`가 초항, `d`가 공차일 때: +가 초항, 가 공차일 때: -- 등차수열의 n번째 항 = `a + d*(n-1)`. -- 산술평균 = `전체 항의 합 / 항의 개수`. -- 등차급수 = `0.5 * n * (초항 + 말항)` = `0.5 * n * [2a + (n-1) d]`. +- 산술평균 = `전체 항의 합 / 항의 개수` +- 등차급수 = `n * (초항 + 말항) / 2` = ## 영상 URL diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\354\236\220\353\246\277\354\210\230.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\354\236\220\353\246\277\354\210\230.md" index 3640aced..09c2f4fe 100644 --- "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\354\236\220\353\246\277\354\210\230.md" +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\354\236\220\353\246\277\354\210\230.md" @@ -24,7 +24,7 @@ N = 10000 [양수] 3. N을 10으로 나눈다. 4. N이 0이 될 때까지 위의 과정을 반복한다. -**알고리즘 분석:** 위 방법에서 수행되는 작업의 수는 숫자 N의 자릿수와 같다는 사실을 쉽게 알 수 있다. 따라서 이 방법의 시간 복잡도는 $O(자릿수)$이다. +**알고리즘 분석:** 위 방법에서 수행되는 작업의 수는 숫자 N의 자릿수와 같다는 사실을 쉽게 알 수 있다. 따라서 이 방법의 시간 복잡도는 이다. (는 숫자 N의 자릿수) **모의 실행:** `N = 58964`라고 할 때, diff --git "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\217\211\352\267\240\352\260\222.md" "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\217\211\352\267\240\352\260\222.md" index 746a0ae9..7212ef98 100644 --- "a/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\217\211\352\267\240\352\260\222.md" +++ "b/ko/\352\270\260\354\264\210 \354\210\230\355\225\231/\355\217\211\352\267\240\352\260\222.md" @@ -47,13 +47,13 @@ sum = 160 count = 7 ``` -유효숫자를 무시하면: `sum / count = `22.857142 +유효숫자를 무시하면 22.857142 -유효숫자를 고려하면: `sum / count = 23` +유효숫자를 고려하면 23 ### 5단계 -22.857142나 `23`을 반환한다. +22.857142나 23을 반환한다. ## 구현 diff --git "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\352\267\270\353\236\230\355\224\204/\353\262\250\353\250\274-\355\217\254\353\223\234 \354\225\214\352\263\240\353\246\254\354\246\230.md" "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\352\267\270\353\236\230\355\224\204/\353\262\250\353\250\274-\355\217\254\353\223\234 \354\225\214\352\263\240\353\246\254\354\246\230.md" index 00494f51..33ea01f2 100644 --- "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\352\267\270\353\236\230\355\224\204/\353\262\250\353\250\274-\355\217\254\353\223\234 \354\225\214\352\263\240\353\246\254\354\246\230.md" +++ "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\352\267\270\353\236\230\355\224\204/\353\262\250\353\250\274-\355\217\254\353\223\234 \354\225\214\352\263\240\353\246\254\354\246\230.md" @@ -2,15 +2,15 @@ ## 문제 -방향 가중치 그래프 $G(V,E)$와 시작점 $s \in V$가 주어졌을 때, 각 점 $v \in V$에 대하여 $s$와 $v$를 잇는 가장 짧은 경로를 구하라. ($V$는 꼭짓점의 집합, $E$는 간선의 집합) +방향 가중치 그래프 와 시작점 가 주어졌을 때, 각 점 에 대하여 를 잇는 가장 짧은 경로를 구하라. (는 꼭짓점의 집합, 는 간선의 집합) ## 절차 1. 시작점에서 모든 꼭짓점까지의 거리를 무한대로 초기화한다. 2. 시작점으로의 거리를 0으로 초기화한다. -3. `dist[s]`를 제외한 모든 값을 무한대로 하는 크기가 $|V|$인 `dist`라는 배열을 만든다. -4. 다음을 $|V|-1$회 반복한다. -5. $E$에 속한 모든 간선 `(u,v)`에 대해 다음을 반복한다: +3. `dist[s]`를 제외한 모든 값을 무한대로 하는 크기가 인 `dist`라는 배열을 만든다. +4. 다음을 회 반복한다. +5. 에 속한 모든 간선 `(u,v)`에 대해 다음을 반복한다: ``` dist[v] = minimum(dist[v], dist[u] + weight of edge) @@ -20,11 +20,11 @@ ## 시간 복잡도 -$O(VE)$ + ## 공간 복잡도 -$O(V^2)$ + ## 만든 사람 diff --git "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\353\260\260\354\227\264/\353\260\260\354\227\264.md" "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\353\260\260\354\227\264/\353\260\260\354\227\264.md" index 5f57efc1..35612e38 100644 --- "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\353\260\260\354\227\264/\353\260\260\354\227\264.md" +++ "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\353\260\260\354\227\264/\353\260\260\354\227\264.md" @@ -2,16 +2,13 @@ 배열은 프로그래밍에서 가장 기본적인 데이터 구조이다. 배열은 정적 배열과 동적 배열로 나눠진다. 정적 배열은 요소의 수가 고정되어 있고, 각각은 메모리의 동일한 공간을 차지한다. 즉, 정적 배열이 차지하는 메모리는 컴파일 시간에 결정되지만, 동적 배열의 경우 크기가 고정되지 않는다. -배열 요소의 값은 $O(1)$ 시간 안에 검색할 수 있다. +배열 요소의 값은 시간 안에 검색할 수 있다. 모든 배열은 연속된 메모리 주소를 가진다. 우리는 인덱스로 각 요소에 접근할 수 있다. 가장 낮은 인덱스는 첫 요소에 해당하고 가장 높은 인덱스는 마지막 요소에 해당한다. -## YouTube - -- [The Coding Train](https://youtu.be/NptnmWvkbTw) -- [Simple Snippets (C++)](https://youtu.be/ibeGtDEQGz0) - ## 영상 URL - [GeeksforGeeks](https://www.geeksforgeeks.org/introduction-to-arrays/) +- [The Coding Train](https://youtu.be/NptnmWvkbTw) +- [Simple Snippets (C++)](https://youtu.be/ibeGtDEQGz0) diff --git "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" index 3bdd7cec..89c59399 100644 --- "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" +++ "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\353\213\250\354\235\274 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" @@ -14,12 +14,12 @@ ### 시간 복잡도 -| 작업 | 평균 | 최악 | -| ---- | ------ | ------ | -| 접근 | $O(n)$ | $O(n)$ | -| 탐색 | $O(n)$ | $O(n)$ | -| 삽입 | $O(1)$ | $O(1)$ | -| 제거 | $O(1)$ | $O(1)$ | +| 작업 | 평균 | 최악 | +| ---- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | +| 접근 | | | +| 탐색 | | | +| 삽입 | | | +| 제거 | | | ## 예시 diff --git "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\354\235\264\354\244\221 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\354\235\264\354\244\221 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" index 499d2586..40c5d687 100644 --- "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\354\235\264\354\244\221 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" +++ "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270/\354\235\264\354\244\221 \354\227\260\352\262\260 \353\246\254\354\212\244\355\212\270.md" @@ -18,12 +18,12 @@ ### 시간 복잡도 -| 작업 | 평균 | 최악 | -| ---- | ------ | ------ | -| 접근 | $Θ(n)$ | $O(n)$ | -| 탐색 | $Θ(n)$ | $O(n)$ | -| 삽입 | $Θ(1)$ | $O(1)$ | -| 제거 | $Θ(1)$ | $O(1)$ | +| 작업 | 평균 | 최악 | +| ---- | --------------------------------------------------------------------------- | ---------------------------------------------------------------------- | +| 접근 | | | +| 탐색 | | | +| 삽입 | | | +| 제거 | | | ## 예시 diff --git "a/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\204\240\355\230\225 \355\203\220\354\203\211.md" "b/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\204\240\355\230\225 \355\203\220\354\203\211.md" index 65974985..27fdc324 100644 --- "a/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\204\240\355\230\225 \355\203\220\354\203\211.md" +++ "b/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\204\240\355\230\225 \355\203\220\354\203\211.md" @@ -13,12 +13,12 @@ n개 원소로 구성된 배열이 주어졌을 때, 특정 원소의 인덱스 ## 시간 복잡도 -- 최악: $O(n)$ -- 최선: $O(1)$ (첫 원소가 찾고자 하는 원소일 때) +- 최악: +- 최선: (첫 원소가 찾고자 하는 원소일 때) ## 공간 복잡도 -- $O(1)$ +- ## 예시 diff --git "a/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\235\264\354\247\204 \355\203\220\354\203\211.md" "b/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\235\264\354\247\204 \355\203\220\354\203\211.md" index 2a27967c..ddb5dde1 100644 --- "a/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\235\264\354\247\204 \355\203\220\354\203\211.md" +++ "b/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\235\264\354\247\204 \355\203\220\354\203\211.md" @@ -16,13 +16,13 @@ n개 원소로 구성된 **정렬된** 배열이 주어졌을 때, 특정 원소 ## 시간 복잡도 -- 최악: $O(\log n)$ -- 최선: $O(1)$ (중간 원소가 찾고자 하는 원소일 때) +- 최악: +- 최선: (중간 원소가 찾고자 하는 원소일 때) ## 공간 복잡도 -- 반복문 사용 시: $O(1)$ -- 재귀적인 방법 사용 시: $O(\log n)$ +- 반복문 사용 시: +- 재귀적인 방법 사용 시: ## 예시 diff --git "a/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\247\200\354\210\230 \355\203\220\354\203\211.md" "b/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\247\200\354\210\230 \355\203\220\354\203\211.md" index f3140f2a..e3580eef 100644 --- "a/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\247\200\354\210\230 \355\203\220\354\203\211.md" +++ "b/ko/\355\203\220\354\203\211 \354\225\214\352\263\240\353\246\254\354\246\230/\354\247\200\354\210\230 \355\203\220\354\203\211.md" @@ -16,8 +16,8 @@ n개 원소로 구성된 **정렬된** 배열이 주어졌을 때, 특정 원소 ## 시간 복잡도 -- 최악: $O(\log i)$ ($i$는 찾고자 하는 원소의 인덱스) -- 최선: $O(1)$ +- 최악: ($i$는 찾고자 하는 원소의 인덱스) +- 최선: $i$가 찾고자 하는 원소의 인덱스라고 할 때, 탐색을 $\lceil \log i \rceil$번 수행하기 때문에 찾고자 하는 원소가 속하는 범위를 찾는 과정의 복잡도는 $O(\log i)$이다. @@ -25,9 +25,7 @@ $i$가 찾고자 하는 원소의 인덱스라고 할 때, 탐색을 $\lceil \lo 그러므로, 지수 탐색의 복잡도는 다음과 같이 쓸 수 있다. -```mathematica -O(log i) + O(log i) = 2O(log i) = O(log i) -``` + ## 예시 From 6c7bac576f9c62e33439c55fde9264bb4b4dc037 Mon Sep 17 00:00:00 2001 From: Lee Joonhun Date: Mon, 11 Oct 2021 13:55:22 +0900 Subject: [PATCH 16/17] Start working on ko sorting algorithms --- ...4\354\210\230 \354\240\225\353\240\254.md" | 59 +++++++++++ ...0\354\210\230 \354\240\225\353\240\254.md" | 51 ++++++++++ ...\352\267\200 \353\262\204\354\240\204).md" | 79 +++++++++++++++ ...4\353\270\224 \354\240\225\353\240\254.md" | 98 +++++++++++++++++++ ...1\355\225\251 \354\240\225\353\240\254.md" | 45 +++++++++ ...5\354\236\205 \354\240\225\353\240\254.md" | 66 +++++++++++++ ...0\355\203\235 \354\240\225\353\240\254.md" | 67 +++++++++++++ .../\354\205\270 \354\240\225\353\240\254.md" | 68 +++++++++++++ .../\355\200\265 \354\240\225\353\240\254.md" | 79 +++++++++++++++ .../\355\236\231 \354\240\225\353\240\254.md" | 70 +++++++++++++ 10 files changed, 682 insertions(+) create mode 100644 "ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\352\263\204\354\210\230 \354\240\225\353\240\254.md" create mode 100644 "ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\352\270\260\354\210\230 \354\240\225\353\240\254.md" create mode 100644 "ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\353\262\204\353\270\224 \354\240\225\353\240\254 (\354\236\254\352\267\200 \353\262\204\354\240\204).md" create mode 100644 "ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\353\262\204\353\270\224 \354\240\225\353\240\254.md" create mode 100644 "ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\353\263\221\355\225\251 \354\240\225\353\240\254.md" create mode 100644 "ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\354\202\275\354\236\205 \354\240\225\353\240\254.md" create mode 100644 "ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\354\204\240\355\203\235 \354\240\225\353\240\254.md" create mode 100644 "ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\354\205\270 \354\240\225\353\240\254.md" create mode 100644 "ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\355\200\265 \354\240\225\353\240\254.md" create mode 100644 "ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\355\236\231 \354\240\225\353\240\254.md" diff --git "a/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\352\263\204\354\210\230 \354\240\225\353\240\254.md" "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\352\263\204\354\210\230 \354\240\225\353\240\254.md" new file mode 100644 index 00000000..a388f7e0 --- /dev/null +++ "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\352\263\204\354\210\230 \354\240\225\353\240\254.md" @@ -0,0 +1,59 @@ +# 계수 정렬 + +## 문제 + +n개 원소로 구성된 배열이 주어졌을 때, 이 배열을 정렬하는 함수를 구하라. + +## 절차 + +- Find out the maximum element (let's call it `max`) from the given array. +- Initialize an array of length `max+1` with all elements set to 0 to store the array's count. +- Store the count of each element at their respective index in the array's count. +- Store cumulative sum of the elements of the count array. It helps in placing the elements into the correct index of the sorted array. +- Find the index of each element of the original array in the array's count. This gives the cumulative count. +- Place the element at the index calculated and decrease its count by one. + +## 시간 복잡도 + +- (는 음수가 아닌 key 값의 범위) + +## 공간 복잡도 + +- (는 음수가 아닌 key 값의 범위) + +## 만든 사람 + +- [해롤드 H. 수어드](https://en.wikipedia.org/wiki/Harold_H._Seward) + +## 예시 + +``` +countingSort(array, size) + max <- find largest element in array + initialize count array with all zeros + for j <- 0 to size + find the total count of each unique element and + store the count at jth index in count array + for i <- 1 to max + find the cumulative sum and store it in count array itself + for j <- size down to 1 + restore the elements to array + decrease count of each element restored by 1 +``` + +## 구현 + +- [C](https://github.com/TheAlgorithms/C/blob/master/sorting/counting_sort.c) +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/sorting/counting_sort.cpp) +- [JavaScript](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/CountingSort.js) +- [Matlab](https://github.com/TheAlgorithms/MATLAB-Octave/blob/master/algorithms/sorting/counting_sort.m) +- [Python](https://github.com/TheAlgorithms/Python/blob/master/sorts/counting_sort.py) +- [Rust](https://github.com/TheAlgorithms/Rust/blob/master/src/sorting/counting_sort.rs) + +## 영상 URL + +- [GeeksforGeeks](https://www.youtube.com/watch?v=7zuGmKfUt7s) + +## 기타 + +- [David Galles (University of San Francisco)](https://www.cs.usfca.edu/~galles/visualization/CountingSort.html) diff --git "a/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\352\270\260\354\210\230 \354\240\225\353\240\254.md" "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\352\270\260\354\210\230 \354\240\225\353\240\254.md" new file mode 100644 index 00000000..1048889e --- /dev/null +++ "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\352\270\260\354\210\230 \354\240\225\353\240\254.md" @@ -0,0 +1,51 @@ +# 기수 정렬 + +The lower bound for Comparison based sorting algorithm (Merge Sort, Heap Sort, Quick-Sort .. etc) is `Ω(nlogn)`, i.e., they cannot do better than `nlogn`. + +Counting sort is a linear time sorting algorithm that sort in `O(n+k)` time when elements are in the range from 1 to k. + +What if the elements are in the range from 1 to n2? We can’t use counting sort because counting sort will take `O(n2)` which is worse than comparison-based sorting algorithms. Can we sort such an array in linear time? + +Radix Sort is the answer. The idea of Radix Sort is to do digit by digit sort starting from least significant digit to most significant digit. Radix sort uses counting sort as a subroutine to sort. + +## 절차 + +Do following for each digit i where i varies from least significant digit to the most significant digit. +Sort input array using counting sort (or any stable sort) according to the i’th digit. + +## 예시 + +Original, unsorted list: +`170, 45, 75, 90, 802, 24, 2, 66` + +Sorting by least significant digit (1s place) gives: + +[*Notice that we keep 802 before 2, because 802 occurred +before 2 in the original list, and similarly for pairs +170 & 90 and 45 & 75.] + +Sorting by next digit (10s place) gives: + +[*Notice that 802 again comes before 2 as 802 comes before 2 in the previous list.] + +`802, 2, 24, 45, 66, 170, 75, 90` + +Sorting by the most significant digit (100s place) gives: +`2, 24, 45, 66, 75, 90, 170, 802` + +## 시간 복잡도 + +Let there be d digits in input integers. Radix Sort takes `O(d*(n+b))` time where b is the base for representing numbers, for example, for the decimal system, b is 10. +What is the value of d? If `k` is the maximum possible value, then d would be `O(logb(k))`. So overall time complexity is `O((n+b) * logb(k))`. Which looks more than the +time complexity of comparison-based sorting algorithms for a large k. Let us first limit k. Let k <= nc where c is a constant. In that case, the complexity becomes +`O(n logb(n))`. But it still doesn’t beat comparison-based sorting algorithms. + +## Is Radix Sort preferable to Comparison based sorting algorithms like Quick-Sort? + +If we have `log2n` bits for every digit, the running time of Radix appears to be better than Quick Sort for a wide range of input numbers. The constant factors hidden in +asymptotic notation are higher for Radix Sort and Quick-Sort uses hardware caches more effectively. Also, Radix sort uses counting sort as a subroutine and counting sort +takes extra space to sort numbers. + +## 영상 URL + +- [](https://youtu.be/nu4gDuFabIM) diff --git "a/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\353\262\204\353\270\224 \354\240\225\353\240\254 (\354\236\254\352\267\200 \353\262\204\354\240\204).md" "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\353\262\204\353\270\224 \354\240\225\353\240\254 (\354\236\254\352\267\200 \353\262\204\354\240\204).md" new file mode 100644 index 00000000..2ef2515e --- /dev/null +++ "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\353\262\204\353\270\224 \354\240\225\353\240\254 (\354\236\254\352\267\200 \353\262\204\354\240\204).md" @@ -0,0 +1,79 @@ +# 버블 정렬 (재귀 버전) + +Bubble Sort is one of the simplest sorting algorithms that compares two elements at a time and swaps them if they are in the wrong order. This process is repeated until the entire sequence is in order. + +## 절차 + +Base case: If the size of the array is 1, return. + +- We need to fix the last element of the current sub-array. For this, iterate over the entire array using normal Bubble Sort, and perform swapping. +- Next, call the function on the entire array excluding the last element(which was fixed by the iteration in the above step) +- Repeat until Base Case is reached. + +## 시간 복잡도 + +- 최선: +- 평균: + +## 공간 복잡도 + +- 최악: (참고: 기존 버블 정렬의 공간 복잡도는 ) + +## 예시 + +Let the given array be: `{5, 3, 2, 1, 4}` + +**First Iteration:** + +- {`5`, `3`, 2, 1, 4} -> {`3`, `5`, 2, 1, 4} Swap since `5 > 3` +- {3, `5`, `2`, 1, 4} -> {3, `2`, `5`, 1, 4} Swap since `5 > 2` +- {3, 2, `5`, `1`, 4} -> {3, 2, `1`, `5`, 4} Swap since `5 > 1` +- {3, 2, 1, `5`, `4`} -> {3, 2, 1, `4`, `5`} Swap since `5 > 4` + +This iteration has fixed the position of 5. Now, we will consider the array up to index 3. + +**Second Iteration:** + +- {`3`, `2`, 1, 4, 5} -> {`2`, `3`, 1, 4, 5} Swap since `3 > 2` +- {2, `3`, `1`, 4, 5} -> {2, `1`, `3`, 4, 5} Swap since `3 > 1` +- {2, 1, `3`, `4`, 5}; As `3 < 4`, do not swap + +Note: As we check one less element with every iteration, we do not need elements at index 3 and 4 i.e., `4` and `5`, as 5 is already in order. Formally, for an array with `n` integers, we consider elements only up to index `n - i`, where `i` is the iteration number. + +**Third Iteration:** + +- {`2`, `1`, 3, 4, 5} -> {`1`, `2`, 3, 4, 5} Swap since `1 > 2` +- {1, `2`, `3`, 4, 5}; As `2 < 3`, do not swap + +**Fourth Iteration:** + +- {`1`, `2`, 3, 4, 5}; As `1 < 2`, do not swap + +**Fifth Iteration:** + +- {`1`, 2, 3, 4, 5}; As the size of the array is 1, return. + +Note: This is the base case. + +## Pseudo Code + +``` +void bubbleSort(arr[], n) + if(n==1) + return; + + for(i = 0; i arr[i+1]) + swap(arr[i], arr[i+1]) + + bubbleSort(arr, n-1) +``` + +## 구현 + +- [Java](https://github.com/TheAlgorithms/Java/blob/master/Sorts/BubbleSortRecursion.java) +- [C](https://github.com/TheAlgorithms/C/blob/master/sorting/bubble_sort_recursion.c) + +## 영상 URL + +- [Programming Tutorials](https://www.youtube.com/watch?v=gDMDVLBfCI0) diff --git "a/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\353\262\204\353\270\224 \354\240\225\353\240\254.md" "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\353\262\204\353\270\224 \354\240\225\353\240\254.md" new file mode 100644 index 00000000..a24025dd --- /dev/null +++ "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\353\262\204\353\270\224 \354\240\225\353\240\254.md" @@ -0,0 +1,98 @@ +# 버블 정렬 + +## 문제 + +n개 원소로 구성된 배열이 주어졌을 때, 이 배열을 정렬하는 함수를 구하라. + +## 절차 + +- select the first element of the array +- compare it with its next element +- if it is larger than the next element then swap them +- else do nothing +- keep doing this for every index of the array +- repeat the above process n times. + +## 시간 복잡도 + +- 최악: +- 최선: +- 평균: + +## 공간 복잡도 + +- 최악: + +## 만든 사람 + +- [케네스 아이버슨](https://ko.wikipedia.org/wiki/%EC%BC%80%EB%84%A4%EC%8A%A4_%EC%95%84%EC%9D%B4%EB%B2%84%EC%8A%A8): "버블 정렬"이라는 용어를 1962년에 처음으로 사용했다. + +## 예시 + +``` +arr[] = {10, 80, 40, 30} +Indexes: 0 1 2 3 + +1. Index = 0, Number = 10 +2. 10 < 80, do nothing and continue + +3. Index = 1, Number = 80 +4. 80 > 40, swap 80 and 40 +5. The array now is {10, 40, 80, 30} + +6. Index = 2, Number = 80 +7. 80 > 30, swap 80 and 30 +8. The array now is {10, 40, 30, 80} + +Repeat the Above Steps again + +arr[] = {10, 40, 30, 80} +Indexes: 0 1 2 3 + +1. Index = 0, Number = 10 +2. 10 < 40, do nothing and continue + +3. Index = 1, Number = 40 +4. 40 > 30, swap 40 and 30 +5. The array now is {10, 30, 40, 80} + +6. Index = 2, Number = 40 +7. 40 < 80, do nothing +8. The array now is {10, 30, 40, 80} + +Repeat the Above Steps again + +arr[] = {10, 30, 40, 80} +Indexes: 0 1 2 3 + +1. Index = 0, Number = 10 +2. 10 < 30, do nothing and continue + +3. Index = 1, Number = 30 +4. 30 < 40, do nothing and continue + +5. Index = 2, Number = 40 +6. 40 < 80, do nothing + +Since there are no swaps in above steps, it means the array is sorted and we can stop here. +``` + +## 구현 + +- [Java](https://github.com/TheAlgorithms/Java/blob/master/Sorts/BubbleSort.java) +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/sorting/bubble_sort.cpp) +- [Python](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) +- [Go](https://github.com/TheAlgorithms/Go/blob/master/sorts/bubblesort.go) +- [Ruby](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/bubble_sort.rb) +- [C](https://github.com/TheAlgorithms/C/blob/master/sorting/bubble_sort.c) +- [Scala](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/BubbleSort.scala) +- [JavaScript](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/BubbleSort.js) + +## 영상 URL + +- [mycodeschool](https://www.youtube.com/watch?v=Jdtq5uKz-w4) + +## 기타 + +- [Tute Board](https://boardhub.github.io/tute/?wd=bubbleSortAlgo2) diff --git "a/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\353\263\221\355\225\251 \354\240\225\353\240\254.md" "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\353\263\221\355\225\251 \354\240\225\353\240\254.md" new file mode 100644 index 00000000..93669e29 --- /dev/null +++ "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\353\263\221\355\225\251 \354\240\225\353\240\254.md" @@ -0,0 +1,45 @@ +# 병합 정렬 (분할 정복 알고리즘) + +## 문제 + +n개 원소로 구성된 배열이 주어졌을 때, 이 배열을 정렬하는 함수를 구하라. + +## 절차 + +- Find a mid point and divide the array into to halves based on the mid point +- Recursively call the merge sort function for both the halves +- Merge the two sorted halves to get the sorted array + +## 시간 복잡도 + +- + +## 공간 복잡도 + +- + +## 예시 + +``` +arr = [1, 3, 9, 5, 0, 2] + +Divide the array in two halves [1, 3, 9] and [5, 0, 2] + +Recursively call merge sort function for both these halves which will provide sorted halves +=> [1, 3, 9] & [0, 2, 5] + +Now merge both these halves to get the sorted array [0, 1, 2, 3, 5, 9] +``` + +## 구현 + +- [Java](https://github.com/TheAlgorithms/Java/blob/master/Sorts/MergeSort.java) +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/sorting/merge_sort.cpp) +- [Python](https://github.com/TheAlgorithms/Python/blob/master/sorts/merge_sort.py) +- [C#](https://github.com/TheAlgorithms/C-Sharp/blob/master/Algorithms/Sorters/Comparison/MergeSorter.cs) +- [C](https://github.com/TheAlgorithms/C/blob/master/sorting/merge_sort.c) +- [Ruby](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/merge_sort.rb) + +## 영상 URL + +- [CS50](https://www.youtube.com/watch?v=EeQ8pwjQxTM) diff --git "a/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\354\202\275\354\236\205 \354\240\225\353\240\254.md" "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\354\202\275\354\236\205 \354\240\225\353\240\254.md" new file mode 100644 index 00000000..0d66ae1a --- /dev/null +++ "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\354\202\275\354\236\205 \354\240\225\353\240\254.md" @@ -0,0 +1,66 @@ +# 삽입 정렬 + +## 문제 + +n개 원소로 구성된 배열이 주어졌을 때, 이 배열을 정렬하는 함수를 구하라. + +## 절차 + +- Define a "key" index, the subarray to the left of which is sorted. +- Initiate "key" as 1, ie. the second element of array(as there is only one element to left of the second element, which can be considered as sorted array with one element). +- If value of element at (key - 1) position is less than value of element at (key) position; increment "key". +- Else move elements of sorted subarray that are greater than value of element at "key" to one position ahead of their current position. Put the value of element at "key" in the newly created void. + +## 시간 복잡도 + +- 최악 + - 비교: + - 교환: +- 최선 + - 비교: + - 교환: + +## 공간 복잡도 + +- 최악: ([In-place 알고리즘](https://en.wikipedia.org/wiki/In-place_algorithm)으로, 추가적인 메모리 할당이 필요하지 않다) + +## 예시 + +``` + +12, 11, 13, 5, 6 + +Let us loop for i = 1 (second element of the array) to 4 (Size of input array) + +i = 1. +Since 11 is smaller than 12, move 12 and insert 11 before 12 +11, 12, 13, 5, 6 + +i = 2. +13 will remain at its position as all elements in sorted subarray are smaller than 13 +11, 12, 13, 5, 6 + +i = 3. +5 will move to the beginning, +and all other elements from 11 to 13 will move one position ahead of their current position. +5, 11, 12, 13, 6 + +i = 4. +6 will move to position after 5, +and elements from 11 to 13 will move one position ahead of their current position. +5, 6, 11, 12, 13 -- sorted array +``` + +## 구현 + +- [Java](https://github.com/TheAlgorithms/Java/blob/master/Sorts/InsertionSort.java) +- [C](https://github.com/TheAlgorithms/C/blob/master/sorting/insertion_sort.c) +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/sorting/insertion_sort.cpp) +- [C#](https://github.com/TheAlgorithms/C-Sharp/blob/master/Algorithms/Sorters/Comparison/InsertionSorter.cs) +- [Scala](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/InsertionSort.scala) +- [Python](https://github.com/TheAlgorithms/Python/blob/master/sorts/insertion_sort.py) +- [Ruby](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/insertion_sort.rb) + +## 영상 URL + +- [CS50](https://www.youtube.com/watch?v=DFG-XuyPYUQ) diff --git "a/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\354\204\240\355\203\235 \354\240\225\353\240\254.md" "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\354\204\240\355\203\235 \354\240\225\353\240\254.md" new file mode 100644 index 00000000..073421eb --- /dev/null +++ "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\354\204\240\355\203\235 \354\240\225\353\240\254.md" @@ -0,0 +1,67 @@ +# 선택 정렬 + +## 문제 + +n개 원소로 구성된 배열이 주어졌을 때, 이 배열을 정렬하는 함수를 구하라. + +## 절차 + +- select the smallest element from the array +- put it at the beginning of the array +- then select the smallest array from the remaining unsorted list +- append it to the sorted array at the beginning +- keep doing this for every element of the array +- repeat the above process n times + +## 시간 복잡도 + +- 최악: +- 최선: +- 평균: + +## 공간 복잡도 + +- 최악: + +## 예시 + +``` +arr[] = {80, 10, 40, 30} +Indexes: 0 1 2 3 + +1. Index = 0 + Select the minimum number from the array (between index 0-3), ie, 10 +2. Swap 10 and 80 (arr[0]) +3. The array now is {10, 80, 40, 30} + +4. Index = 1 + Select the minimum number from the array (between index 1-3), ie, 30 +5. Swap 30 and 80 (arr[1]) +6. The array now is {10, 30, 40, 80} + +7. Index = 2 + Select the minimum number from the array (between index 2-3), ie, 40 +8. Swap 40 and 40 (arr[2]) +9. The array now is {10, 30, 40, 80} + +The array is now sorted. +``` + +## 구현 + +- [Java](https://github.com/TheAlgorithms/Java/blob/master/Sorts/SelectionSort.java) +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/Sorting/Selection%20Sort.cpp) +- [Python](https://github.com/TheAlgorithms/Python/blob/master/sorts/selection_sort.py) +- [Go](https://github.com/TheAlgorithms/Go/blob/master/sorts/selection_sort.go) +- [Ruby](https://github.com/TheAlgorithms/Ruby/blob/master/Sorting/selection_sort.rb) +- [C](https://github.com/TheAlgorithms/C/blob/master/sorting/SelectionSort.c) +- [Scala](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/SelectionSort.scala) +- [JavaScript](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/selectionSort.js) + +## 영상 URL + +- [CS50](https://www.youtube.com/watch?v=f8hXR_Hvybo) + +## 기타 + +- [Tute Board](https://boardhub.github.io/tute/?wd=selectSortAlgo2) diff --git "a/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\354\205\270 \354\240\225\353\240\254.md" "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\354\205\270 \354\240\225\353\240\254.md" new file mode 100644 index 00000000..9579258f --- /dev/null +++ "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\354\205\270 \354\240\225\353\240\254.md" @@ -0,0 +1,68 @@ +# 셸 정렬 + +## 문제 + +n개 원소로 구성된 배열이 주어졌을 때, 이 배열을 정렬하는 함수를 구하라. + +## 절차 + +- start with the initial gap, g +- go through the first (n - g) elements in the array +- compare the element with the next element that is g distance away +- swap the two elements if the first element is bigger +- decrease the gap and repeat until gap = 1 + +## 시간 복잡도 + +셸 정렬의 시간 복잡도는 gap sequences에 따라 다르다. 아래 시간 복잡도는 의 gap sequences를 가정한다. + +- 최악: +- 최선: +- 평균: + +## 공간 복잡도 + +- 최악: + +## 만든 사람 + +- [도널드 셸](https://en.wikipedia.org/wiki/Donald_Shell) + +## 예시 + +``` +arr[] = {61, 109, 149, 111, 34, 2, 24, 119} +Initial Gap: 4 + +1. Index = 0, Next element index = 4 +2. 61 > 34, swap 61 and 34 +3. The array is now {34, 109, 149, 111, 61, 2, 24, 119} + +4. Index = 1, Next element index = 5 +5. 109 > 2, swap 109 and 2 +6. The array is now {34, 2, 149, 111, 61, 109, 24, 119} + +7. Index = 2, Next element index = 6 +8. 149 > 24, swap 149 and 24 +9. The array is now {34, 2, 24, 111, 61, 109, 149, 119} + +10. Index = 3, Next element index = 7 +11. 111 < 119, do nothing and continue + +12. Divide the gap by 2 and repeat until gap = 1 +``` + +## 구현 + +- [Java](https://github.com/TheAlgorithms/Java/blob/master/Sorts/ShellSort.java) +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/Sorting/Shell%20Sort.cpp) +- [Python](https://github.com/TheAlgorithms/Python/blob/master/sorts/shell_sort.py) +- [C#](https://github.com/TheAlgorithms/C-Sharp/blob/master/sorts/shell_sort.cs) +- [Go](https://github.com/TheAlgorithms/Go/blob/master/sorts/shell_sort.go) +- [Ruby](https://github.com/TheAlgorithms/Ruby/blob/master/Sorting/shell_sort.rb) +- [C](https://github.com/TheAlgorithms/C/blob/master/sorting/shellSort.c) +- [JavaScript](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/shellSort.js) + +## 영상 URL + +- [Computer Education for All](https://www.youtube.com/watch?v=H8NiFkGu2PY) diff --git "a/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\355\200\265 \354\240\225\353\240\254.md" "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\355\200\265 \354\240\225\353\240\254.md" new file mode 100644 index 00000000..e9ff369b --- /dev/null +++ "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\355\200\265 \354\240\225\353\240\254.md" @@ -0,0 +1,79 @@ +# 퀵 정렬 + +## 문제 + +n개 원소로 구성된 배열이 주어졌을 때, 이 배열을 정렬하는 함수를 구하라. + +## 절차 + +- Make the right-most index value pivot +- partition the array using pivot value +- quicksort left partition recursively +- quicksort right partition recursively + +## 시간 복잡도 + +- 최악: +- 최선: +- 평균: + +## 공간 복잡도 + +- 최악: + +## 만든 사람 + +- [토니 호어](https://ko.wikipedia.org/wiki/%ED%86%A0%EB%8B%88_%ED%98%B8%EC%96%B4) + +## 예시 + +``` +arr[] = {10, 80, 30, 90, 40, 50, 70} +Indexes: 0 1 2 3 4 5 6 + +low = 0, high = 6, pivot = arr[h] = 70 +Initialize index of smaller element, i = -1 + +Traverse elements from j = low to high-1 +j = 0 : Since arr[j] <= pivot, do i++ and swap(arr[i], arr[j]) +i = 0 +arr[] = {10, 80, 30, 90, 40, 50, 70} // No change as i and j + // are same + +j = 1 : Since arr[j] > pivot, do nothing +// No change in i and arr[] + +j = 2 : Since arr[j] <= pivot, do i++ and swap(arr[i], arr[j]) +i = 1 +arr[] = {10, 30, 80, 90, 40, 50, 70} // We swap 80 and 30 + +j = 3 : Since arr[j] > pivot, do nothing +// No change in i and arr[] + +j = 4 : Since arr[j] <= pivot, do i++ and swap(arr[i], arr[j]) +i = 2 +arr[] = {10, 30, 40, 90, 80, 50, 70} // 80 and 40 Swapped +j = 5 : Since arr[j] <= pivot, do i++ and swap arr[i] with arr[j] +i = 3 +arr[] = {10, 30, 40, 50, 80, 90, 70} // 90 and 50 Swapped + +We come out of loop because j is now equal to high-1. +Finally we place pivot at correct position by swapping +arr[i+1] and arr[high] (or pivot) +arr[] = {10, 30, 40, 50, 70, 90, 80} // 80 and 70 Swapped + +Now 70 is at its correct place. All elements smaller than +70 are before it and all elements greater than 70 are after +it. +``` + +## 구현 + +- [Java](https://github.com/TheAlgorithms/Java/blob/master/Sorts/QuickSort.java) +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/Sorting/Quick%20Sort.cpp) +- [Python](https://github.com/TheAlgorithms/Python/blob/master/sorts/quick_sort.py) +- [Ruby](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/quicksort.rb) + +## 영상 URL + +- [mycodeschool](https://www.youtube.com/watch?v=COk73cpQbFQ) diff --git "a/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\355\236\231 \354\240\225\353\240\254.md" "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\355\236\231 \354\240\225\353\240\254.md" new file mode 100644 index 00000000..898c08e8 --- /dev/null +++ "b/ko/\354\240\225\353\240\254 \354\225\214\352\263\240\353\246\254\354\246\230/\355\236\231 \354\240\225\353\240\254.md" @@ -0,0 +1,70 @@ +# 힙 정렬 + +## 문제 + +n개 원소로 구성된 배열이 주어졌을 때, 이 배열을 정렬하는 함수를 구하라. + +## 절차 + +- Build a max heap from the input data. +- At this point, the largest item is stored at the root of the heap. Replace it with the last item of the heap followed by reducing the size of heap by 1. Finally, heapify the root of tree. +- Repeat above steps while size of heap is greater than 1. + +## 시간 복잡도 + +- 최악: +- 최선: + distinct keys일 때 , + equal keys일 때 +- 평균: + +## 공간 복잡도 + +- 최악: + +## 예시 + +``` +Input data: 4, 10, 3, 5, 1 + 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) + / \ +5(3) 1(4) + +Applying heapify procedure to index 0: + 10(0) + / \ + 5(1) 3(2) + / \ +4(3) 1(4) +The heapify procedure calls itself recursively to build heap +in top down manner. +``` + +![heap-image](https://upload.wikimedia.org/wikipedia/commons/1/1b/Sorting_heapsort_anim.gif 'Heap Sort') + +## 구현 + +- [Java](https://github.com/TheAlgorithms/Java/blob/master/Sorts/HeapSort.java) +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/sorting/heap_sort.cpp) +- [Python](https://github.com/TheAlgorithms/Python/blob/master/sorts/heap_sort.py) +- [Go](https://github.com/TheAlgorithms/Go/blob/master/sorts/heapsort.go) +- [Ruby](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/heap_sort.rb) +- [C#](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) +- [JavaScript](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/HeapSort.js) + +## 영상 URL + +[GeeksforGeeks](https://www.youtube.com/watch?v=MtQL_ll5KhQ) From 408f46837c3dbf703356fd4b46c682c47cba0414 Mon Sep 17 00:00:00 2001 From: Lee Joonhun Date: Mon, 11 Oct 2021 14:18:18 +0900 Subject: [PATCH 17/17] Commit to merge with master --- en/Data Structures/Graph/Bellman-Ford.md | 78 +++++++++---------- ...14\352\263\240\353\246\254\354\246\230.md" | 6 +- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/en/Data Structures/Graph/Bellman-Ford.md b/en/Data Structures/Graph/Bellman-Ford.md index b5212d1f..1dda9ba6 100644 --- a/en/Data Structures/Graph/Bellman-Ford.md +++ b/en/Data Structures/Graph/Bellman-Ford.md @@ -11,7 +11,7 @@ Given a weighted directed graph G(V,E) and a source vertex s ∈ V, determine fo - Create an array dist[] of size |V| with all values as infinite except dist[s]. - Repeat the following |V| - 1 times. Where |V| is number of vertices. - Create another loop to go through each edge (u, v) in E and do the following: - 1. dist[v] = minimum(dist[v], dist[u] + weight of edge). + 1. dist[v] = minimum(dist[v], dist[u] + weight of edge). - Lastly iterate through all edges on last time to make sure there are no negatively weighted cycles. #### Time Complexity @@ -30,7 +30,7 @@ O(V^2) ``` # of vertices in graph = 5 [A, B, C, D, E] - # of edges in graph = 8 + # of edges in graph = 8 edges [A->B, A->C, B->C, B->D, B->E, D->C, D->B, E->D] weight [ -1, 4, 3, 2, 2, 5, 1, -4 ] @@ -38,44 +38,44 @@ O(V^2) - // edge A->B - graph->edge[0].src = A - graph->edge[0].dest = B - graph->edge[0].weight = -1 - - // edge A->C - graph->edge[1].src = A - graph->edge[1].dest = C - graph->edge[1].weight = 4 - - // edge B->C - graph->edge[2].src = B - graph->edge[2].dest = C - graph->edge[2].weight = 3 - - // edge B->D - graph->edge[3].src = B - graph->edge[3].dest = D - graph->edge[3].weight = 2 - - // edge B->E - graph->edge[4].src = B - graph->edge[4].dest = E - graph->edge[4].weight = 2 - - // edge D->C + // edge A->B + graph->edge[0].src = A + graph->edge[0].dest = B + graph->edge[0].weight = -1 + + // edge A->C + graph->edge[1].src = A + graph->edge[1].dest = C + graph->edge[1].weight = 4 + + // edge B->C + graph->edge[2].src = B + graph->edge[2].dest = C + graph->edge[2].weight = 3 + + // edge B->D + graph->edge[3].src = B + graph->edge[3].dest = D + graph->edge[3].weight = 2 + + // edge B->E + graph->edge[4].src = B + graph->edge[4].dest = E + graph->edge[4].weight = 2 + + // edge D->C graph->edge[5].src = D - graph->edge[5].dest = C - graph->edge[5].weight = 5 - - // edge D->B + graph->edge[5].dest = C + graph->edge[5].weight = 5 + + // edge D->B graph->edge[6].src = D - graph->edge[6].dest = B - graph->edge[6].weight = 1 - - // edge E->D + graph->edge[6].dest = B + graph->edge[6].weight = 1 + + // edge E->D graph->edge[7].src = E - graph->edge[7].dest = D + graph->edge[7].dest = D graph->edge[7].weight = -3 for source = A @@ -86,8 +86,7 @@ O(V^2) C 2 A->B->C = -1 + 3 D -2 A->B->E->D = -1 + 2 + -3 E 1 A->B->E = -1 + 2 - ``` - +``` #### Code Implementation Links @@ -103,5 +102,6 @@ O(V^2) #### Others Sources Used: + - https://www.geeksforgeeks.org/bellman-ford-algorithm-dp-23/ - https://en.wikipedia.org/wiki/Bellman%E2%80%93Ford_algorithm diff --git "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\352\267\270\353\236\230\355\224\204/\353\262\250\353\250\274-\355\217\254\353\223\234 \354\225\214\352\263\240\353\246\254\354\246\230.md" "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\352\267\270\353\236\230\355\224\204/\353\262\250\353\250\274-\355\217\254\353\223\234 \354\225\214\352\263\240\353\246\254\354\246\230.md" index 33ea01f2..83ab1cf8 100644 --- "a/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\352\267\270\353\236\230\355\224\204/\353\262\250\353\250\274-\355\217\254\353\223\234 \354\225\214\352\263\240\353\246\254\354\246\230.md" +++ "b/ko/\354\236\220\353\243\214\352\265\254\354\241\260/\352\267\270\353\236\230\355\224\204/\353\262\250\353\250\274-\355\217\254\353\223\234 \354\225\214\352\263\240\353\246\254\354\246\230.md" @@ -97,9 +97,9 @@ ## 구현 - [Java](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/BellmanFord.java) -- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/Dynamic%20Programming/Bellman-Ford.cpp) -- [Python](https://github.com/TheAlgorithms/Python/blob/master/data_structures/graph/bellman_ford.py) -- [C](https://github.com/TheAlgorithms/C/blob/master/data_structures/graphs/Bellman-Ford.c) +- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/dynamic_programming/bellman_ford.cpp) +- [Python](https://github.com/TheAlgorithms/Python/blob/master/graphs/bellman_ford.py) +- [C](https://github.com/TheAlgorithms/C/blob/master/data_structures/graphs/bellman_ford.c) ## 영상 URL