Skip to content

Korean translation #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions ko/자료구조/연결 리스트/원형 연결 리스트.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# 원형 연결 리스트

원형 연결 리스트는 노드로 이루어진 최종 연결 데이터 구조이다. 단일 및 이중 연결 리스트와 마찬가지로, 각 노드는 그 내용이 저장되는 변수 `data`와 목록의 다음 노드에 대한 `pointer`로 구성된다.
연결 리스트는 인접한 요소에 대해 `pointer`를 가지고 있지만 마지막 노드는 헤드 노드, 즉 첫 번째 노드 자체를 향해 연결되어 원형 모양을 형성한다.

### 배열 & 단일 연결 리스트 & 이중 연결 리스트보다 우수한 점

- 모든 노드가 시작점이 될 수 있다.
- 큐 구현에 유용하다.
- 원형 연결 리스트는 응용프로그램에서 목록을 반복적으로 순환하는 데 유용하다.
- 원형 이중 연결 리스트는 `Fibonacci Heap`과 같은 고급 자료구조의 구현을 위해 사용된다.
- 연결 리스트의 크기가 고정되어 있지 않다(가변 크기).
- 배열에 비해 `element`삭제, 추가비용이 적다.

### 단점

- 원형 연결 리스트는 단일 연결 리스트에 비해 복잡하다.
- 원형 연결 리스트의 `reversing`이 단일 연결 리스트나 이중 연결 리스트에 비해 복잡하다.
- 주의하지 않으면 무한 루프에 빠질 수 있다.
- `element`는 배열과 비교하여 직접 접근할 수 없고 순차적으로 접근해야 한다.
- 연결된 리스트의 `element`를 연결하는 `pointer`에 대한 추가 메모리 할당을 필요하다.

### 시간 복잡도

| Operation | Average | Worst |
|-----------|---------|-------|
| Initialize| O(1) | - |
| Access | O(n) | O(n) |
| Search | O(n) | O(n) |
| Insertion | O(1) | O(n) |
| Deletion | O(1) | O(n) |

### 실제 적용 사례

- CPU 자원 할당
- 멀티플레이어 보드 게임

### SLL v.s. CLL

![image](https://i0.wp.com/algorithms.tutorialhorizon.com/files/2016/03/Circular-Linked-List.png)

### 예시

<u>Insertion</u>
```java
public void insertHead(int data)
{
Node temp = new Node(data);
Node cur = head;
while(cur.getNext() != head)
cur = cur.getNext();
if(head == null)
{
head = temp;
head.setNext(head);
}
else
{
temp.setNext(head);
head = temp;
cur.setNext(temp);
}
size++;
}
```

## 구현

- [JavaScript](https://github.com/TheAlgorithms/Javascript/blob/master/Data-Structures/Linked-List/SingleCircularLinkedList.js.js)
- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/cll/cll.cpp)
- [Python](https://github.com/TheAlgorithms/Python/blob/master/data_structures/linked_list/circular_linked_list.py)

## 영상 URL

[Video explanation on YouTube](https://youtu.be/HMkdlu5sP4A)
39 changes: 39 additions & 0 deletions ko/탐색/플로이드 순환 탐색 알고리즘.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 배열에서 중복 번호를 찾는 플로이드 순환 탐색 알고리즘

## 문제

`n + 1` 정수를 포함하는 정수 배열이 주어지면 각 정수는 `[1, n]`을 포함한 범위에 있다. 입력 배열에 중복 숫자가 하나만 있으면 이 알고리즘은 원래 배열을 수정하지 않고 중복 숫자를 반환하고, 그렇지 않으면 `-1`을 반환한다.

## 접근 방식


- 함수 `f(x) = arr[x]`를 사용하여 시퀀스를 구성한다.
<예시> `arr[0]`, `arr[arr[0]]`, `arr[arr[arr[0]]]`, `arr[arr[arr[arr[0]]]]`
- 시퀀스의 각각의 새로운 원소는 이전 요소의 인덱스에 있는 `arr[]`의 원소입니다.
- `x = arr[0]`부터 시작하여 원형 연결 리스트를 생성한다.
- `arr[]`에 중복 원소(최소 하나)가 포함되어 있기 때문에 `cycle`이 나타난다. 중복 값은 순환의 시작점이다.

## 시간 복잡도

O(n)

## 공간 복잡도

O(1)

## 예시

```
arr = [3, 4, 8, 5, 9, 1, 2, 6, 7, 4]

return value = 4
```

## 구현

- [C++](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/search/floyd_cycle_detection_algo.cpp)
- [C](https://github.com/TheAlgorithms/C/blob/master/searching/floyd_cycle_detection_algorithm.c)

#### 영상 URL

[YouTube video explaining the Floyd Cycle Detection algorithm](https://www.youtube.com/watch?v=B6smdk7pZ14)