From 619c8ff1d4c2fa2286bf45fff43420a08985ea62 Mon Sep 17 00:00:00 2001 From: Woo-Cheol Kim Date: Mon, 9 Dec 2019 15:23:05 +0900 Subject: [PATCH 1/2] copy origin doc --- .../linked-list/README.ko-KR.md | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 src/data-structures/linked-list/README.ko-KR.md diff --git a/src/data-structures/linked-list/README.ko-KR.md b/src/data-structures/linked-list/README.ko-KR.md new file mode 100644 index 0000000000..3fd10e24db --- /dev/null +++ b/src/data-structures/linked-list/README.ko-KR.md @@ -0,0 +1,162 @@ +# Linked List + +_Read this in other languages:_ +[_简体中文_](README.zh-CN.md), +[_Русский_](README.ru-RU.md), +[_日本語_](README.ja-JP.md), +[_Português_](README.pt-BR.md) + +In computer science, a **linked list** is a linear collection +of data elements, in which linear order is not given by +their physical placement in memory. Instead, each +element points to the next. It is a data structure +consisting of a group of nodes which together represent +a sequence. Under the simplest form, each node is +composed of data and a reference (in other words, +a link) to the next node in the sequence. This structure +allows for efficient insertion or removal of elements +from any position in the sequence during iteration. +More complex variants add additional links, allowing +efficient insertion or removal from arbitrary element +references. A drawback of linked lists is that access +time is linear (and difficult to pipeline). Faster +access, such as random access, is not feasible. Arrays +have better cache locality as compared to linked lists. + +![Linked List](https://upload.wikimedia.org/wikipedia/commons/6/6d/Singly-linked-list.svg) + +## Pseudocode for Basic Operations + +### Insert + +```text +Add(value) + Pre: value is the value to add to the list + Post: value has been placed at the tail of the list + n ← node(value) + if head = ø + head ← n + tail ← n + else + tail.next ← n + tail ← n + end if +end Add +``` + +```text +Prepend(value) + Pre: value is the value to add to the list + Post: value has been placed at the head of the list + n ← node(value) + n.next ← head + head ← n + if tail = ø + tail ← n + end +end Prepend +``` + +### Search + +```text +Contains(head, value) + Pre: head is the head node in the list + value is the value to search for + Post: the item is either in the linked list, true; otherwise false + n ← head + while n != ø and n.value != value + n ← n.next + end while + if n = ø + return false + end if + return true +end Contains +``` + +### Delete + +```text +Remove(head, value) + Pre: head is the head node in the list + value is the value to remove from the list + Post: value is removed from the list, true, otherwise false + if head = ø + return false + end if + n ← head + if n.value = value + if head = tail + head ← ø + tail ← ø + else + head ← head.next + end if + return true + end if + while n.next != ø and n.next.value != value + n ← n.next + end while + if n.next != ø + if n.next = tail + tail ← n + end if + n.next ← n.next.next + return true + end if + return false +end Remove +``` + +### Traverse + +```text +Traverse(head) + Pre: head is the head node in the list + Post: the items in the list have been traversed + n ← head + while n != ø + yield n.value + n ← n.next + end while +end Traverse +``` + +### Traverse in Reverse + +```text +ReverseTraversal(head, tail) + Pre: head and tail belong to the same list + Post: the items in the list have been traversed in reverse order + if tail != ø + curr ← tail + while curr != head + prev ← head + while prev.next != curr + prev ← prev.next + end while + yield curr.value + curr ← prev + end while + yield curr.value + end if +end ReverseTraversal +``` + +## Complexities + +### Time Complexity + +| Access | Search | Insertion | Deletion | +| :-------: | :-------: | :-------: | :-------: | +| O(n) | O(n) | O(1) | O(n) | + +### Space Complexity + +O(n) + +## References + +- [Wikipedia](https://en.wikipedia.org/wiki/Linked_list) +- [YouTube](https://www.youtube.com/watch?v=njTh_OwMljA&index=2&t=1s&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8) From fbd0687e8ac8b92d961b73fd5c8bce7df3a0d7f9 Mon Sep 17 00:00:00 2001 From: Woo-Cheol Kim Date: Mon, 9 Dec 2019 17:43:43 +0900 Subject: [PATCH 2/2] add README.ko-KR.md(translation) in 'data-structures/linked-list' --- .../linked-list/README.ko-KR.md | 83 +++++++++---------- 1 file changed, 39 insertions(+), 44 deletions(-) diff --git a/src/data-structures/linked-list/README.ko-KR.md b/src/data-structures/linked-list/README.ko-KR.md index 3fd10e24db..d4a35e47fb 100644 --- a/src/data-structures/linked-list/README.ko-KR.md +++ b/src/data-structures/linked-list/README.ko-KR.md @@ -4,35 +4,30 @@ _Read this in other languages:_ [_简体中文_](README.zh-CN.md), [_Русский_](README.ru-RU.md), [_日本語_](README.ja-JP.md), -[_Português_](README.pt-BR.md) - -In computer science, a **linked list** is a linear collection -of data elements, in which linear order is not given by -their physical placement in memory. Instead, each -element points to the next. It is a data structure -consisting of a group of nodes which together represent -a sequence. Under the simplest form, each node is -composed of data and a reference (in other words, -a link) to the next node in the sequence. This structure -allows for efficient insertion or removal of elements -from any position in the sequence during iteration. -More complex variants add additional links, allowing -efficient insertion or removal from arbitrary element -references. A drawback of linked lists is that access -time is linear (and difficult to pipeline). Faster -access, such as random access, is not feasible. Arrays -have better cache locality as compared to linked lists. +[_Português_](README.pt-BR.md), +[_한국어_](README.ko-KR.md) + +컴퓨터과학에서 **연결 리스트**는 데이터 원소의 선형 컬렉션이고, +그 선형 순서는 메모리의 물리적 위치로 결정되지 않습니다. +대신, 각 원소는 다음 원소를 가리 킵니다. +시퀀스를 나타내는 노드의 그룹으로 이루어진 데이터 구조입니다. +가장 간단한 형태로, 각 노드는 데이터와 시퀀스의 다음 노드에 대한 참조(다른 말로 연결)로 구성되어 있습니다. +이 구조는 반복을 통해 시퀀스의 어떤 위치의 원소라도 효율적으로 추가와 삭제할 수 있습니다. +보다 복잡한 변형은 연결을 추가해 임의 위치의 원소인 경우에도 효율적으로 추가와 삭제가 가능합니다. +연결 리스트의 단점은 접근 시간이 선형이라는 것입니다(그리고 파이프라인하기 어렵). +임의 접근과 같이 빠른 접근은 불가능합니다. +배열은 연결 리스트와 비교하면 캐쉬 지역성(locality)이 더 좋습니다. ![Linked List](https://upload.wikimedia.org/wikipedia/commons/6/6d/Singly-linked-list.svg) -## Pseudocode for Basic Operations +## 기본 연산을 위한 의사 코드 -### Insert +### 추가 ```text Add(value) - Pre: value is the value to add to the list - Post: value has been placed at the tail of the list + Pre: value는 리스트에 추가되어야할 값 + Post: value가 리스트 끝에 추가됨 n ← node(value) if head = ø head ← n @@ -46,8 +41,8 @@ end Add ```text Prepend(value) - Pre: value is the value to add to the list - Post: value has been placed at the head of the list + Pre: value는 리스트에 추가되어야할 값 + Post: value가 리스트 앞에 추가됨 n ← node(value) n.next ← head head ← n @@ -57,13 +52,13 @@ Prepend(value) end Prepend ``` -### Search +### 검색 ```text Contains(head, value) - Pre: head is the head node in the list - value is the value to search for - Post: the item is either in the linked list, true; otherwise false + Pre: head는 리스트의 헤드 노드 + value는 리스트에서 검색하려는 값 + Post: value가 리스트에 있으면, true; 그렇지 않으면 false n ← head while n != ø and n.value != value n ← n.next @@ -74,14 +69,14 @@ Contains(head, value) return true end Contains ``` - -### Delete + +### 삭제 ```text Remove(head, value) - Pre: head is the head node in the list - value is the value to remove from the list - Post: value is removed from the list, true, otherwise false + Pre: head는 리스트의 헤드 노드 + value는 리스트에서 삭제하려는 값 + Post: value가 리스트에서 삭제되면, true; 그렇지 않으면 false if head = ø return false end if @@ -109,12 +104,12 @@ Remove(head, value) end Remove ``` -### Traverse +### 탐색 ```text Traverse(head) - Pre: head is the head node in the list - Post: the items in the list have been traversed + Pre: head는 리스트의 헤드 노드 + Post: 탐색된 리스트의 원소값들 n ← head while n != ø yield n.value @@ -123,12 +118,12 @@ Traverse(head) end Traverse ``` -### Traverse in Reverse +### 역탐색 ```text ReverseTraversal(head, tail) - Pre: head and tail belong to the same list - Post: the items in the list have been traversed in reverse order + Pre: head와 tail은 같은 리스트에 속해있음 + Post: 역방향으로 탐색된 리스트의 원소값들 if tail != ø curr ← tail while curr != head @@ -144,19 +139,19 @@ ReverseTraversal(head, tail) end ReverseTraversal ``` -## Complexities +## 복잡도 -### Time Complexity +### 시간 복잡도 -| Access | Search | Insertion | Deletion | +| 접근 | 검색 | 추가 | 삭제 | | :-------: | :-------: | :-------: | :-------: | | O(n) | O(n) | O(1) | O(n) | -### Space Complexity +### 공간 복잡도 O(n) -## References +## 참조 - [Wikipedia](https://en.wikipedia.org/wiki/Linked_list) - [YouTube](https://www.youtube.com/watch?v=njTh_OwMljA&index=2&t=1s&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8)