diff --git a/README.md b/README.md index 4a870ccf..f0e90fc8 100644 --- a/README.md +++ b/README.md @@ -301,7 +301,8 @@ npm test -- 'playground' ### References -[▶ Data Structures and Algorithms on YouTube](https://www.youtube.com/playlist?list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8) +- [▶ Data Structures and Algorithms on YouTube](https://www.youtube.com/playlist?list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8) +- [✍🏻 Data Structure Sketches](https://okso.app/showcase/data-structures) ### Big O Notation diff --git a/src/data-structures/doubly-linked-list/images/doubly-linked-list.jpeg b/src/data-structures/doubly-linked-list/images/doubly-linked-list.jpeg index 01b6eb29..3483e69f 100644 Binary files a/src/data-structures/doubly-linked-list/images/doubly-linked-list.jpeg and b/src/data-structures/doubly-linked-list/images/doubly-linked-list.jpeg differ diff --git a/src/data-structures/graph/README.fr-FR.md b/src/data-structures/graph/README.fr-FR.md index 48d3ccd7..c6a6c908 100644 --- a/src/data-structures/graph/README.fr-FR.md +++ b/src/data-structures/graph/README.fr-FR.md @@ -1,23 +1,25 @@ # Graph En informatique, un **graphe** est une structure de -données abstraite qui implémente les concepts de +données abstraite qui implémente les concepts de graphe orienté et de graphe non-orienté venant des mathématiques, plus précisément du domaine de la théorie des graphes. -La structure de données abstraite de graphe consiste -en un ensemble fini, éventuellement mutable de sommets -ou nœuds ou points, avec un ensemble de paires ordonnées -ou non de tels éléments. Ces paires sont des arêtes, arcs +La structure de données abstraite de graphe consiste +en un ensemble fini, éventuellement mutable de sommets +ou nœuds ou points, avec un ensemble de paires ordonnées +ou non de tels éléments. Ces paires sont des arêtes, arcs non orientés, ou lignes pour un graphe non orienté, et -flèches, arêtes orientées , arcs, ou lignes orientées -dans le cas orienté. Les sommets peuvent faire partie -de la structure, ou être des entités extérieures, +flèches, arêtes orientées , arcs, ou lignes orientées +dans le cas orienté. Les sommets peuvent faire partie +de la structure, ou être des entités extérieures, représentées par des entiers ou des références. -![Graph](https://www.tutorialspoint.com/data_structures_algorithms/images/graph.jpg) +![Graph](./images/graph.jpeg) + +*Made with [okso.app](https://okso.app)* ## References -- [Wikipedia](https://fr.wikipedia.org/wiki/Graphe_(type_abstrait)) \ No newline at end of file +- [Wikipedia](https://fr.wikipedia.org/wiki/Graphe_(type_abstrait)) diff --git a/src/data-structures/graph/README.md b/src/data-structures/graph/README.md index 2c8602d9..99300537 100644 --- a/src/data-structures/graph/README.md +++ b/src/data-structures/graph/README.md @@ -6,23 +6,25 @@ _Read this in other languages:_ [_Français_](README.fr-FR.md), [_Português_](README.pt-BR.md) -In computer science, a **graph** is an abstract data type -that is meant to implement the undirected graph and +In computer science, a **graph** is an abstract data type +that is meant to implement the undirected graph and directed graph concepts from mathematics, specifically the field of graph theory -A graph data structure consists of a finite (and possibly -mutable) set of vertices or nodes or points, together -with a set of unordered pairs of these vertices for an -undirected graph or a set of ordered pairs for a -directed graph. These pairs are known as edges, arcs, -or lines for an undirected graph and as arrows, -directed edges, directed arcs, or directed lines -for a directed graph. The vertices may be part of -the graph structure, or may be external entities +A graph data structure consists of a finite (and possibly +mutable) set of vertices or nodes or points, together +with a set of unordered pairs of these vertices for an +undirected graph or a set of ordered pairs for a +directed graph. These pairs are known as edges, arcs, +or lines for an undirected graph and as arrows, +directed edges, directed arcs, or directed lines +for a directed graph. The vertices may be part of +the graph structure, or may be external entities represented by integer indices or references. -![Graph](https://www.tutorialspoint.com/data_structures_algorithms/images/graph.jpg) +![Graph](./images/graph.jpeg) + +*Made with [okso.app](https://okso.app)* ## References diff --git a/src/data-structures/graph/README.pt-BR.md b/src/data-structures/graph/README.pt-BR.md index 194a4eb0..de7947cb 100644 --- a/src/data-structures/graph/README.pt-BR.md +++ b/src/data-structures/graph/README.pt-BR.md @@ -17,7 +17,9 @@ para um grafo direcionado. Os vértices podem fazer parte a estrutura do grafo, ou podem ser entidades externas representadas por índices inteiros ou referências. -![Graph](https://www.tutorialspoint.com/data_structures_algorithms/images/graph.jpg) +![Graph](./images/graph.jpeg) + +*Made with [okso.app](https://okso.app)* ## Referências diff --git a/src/data-structures/graph/README.ru-RU.md b/src/data-structures/graph/README.ru-RU.md index 2f656730..95019845 100644 --- a/src/data-structures/graph/README.ru-RU.md +++ b/src/data-structures/graph/README.ru-RU.md @@ -3,7 +3,7 @@ **Граф** в информатике - абстрактный тип данных, который должен реализовывать концепции направленного и ненаправленного графа в математике, особенно в области теории графов. -Структура данных графа состоит из конечного (и возможно изменяющегося) набора вершин или узлов, или точек, совместно с +Структура данных графа состоит из конечного (и возможно изменяющегося) набора вершин или узлов, или точек, совместно с набором ненаправленных пар этих вершин для ненаправленного графа или с набором направленных пар для направленного графа. Эти пары известны как рёбра, арки или линии для ненаправленного графа и как стрелки, направленные рёбра, направленные арки или направленные линии для направленного графа. Эти вершины могут быть частью структуры графа, или внешними @@ -14,7 +14,9 @@ информатике, могут быть представлены графами. Например, строение Википедии можно смоделировать при помощи ориентированного графа, в котором вершины — это статьи, а дуги (ориентированные рёбра) — гиперссылки. -![Граф](https://www.tutorialspoint.com/data_structures_algorithms/images/graph.jpg) +![Граф](./images/graph.jpeg) + +*Made with [okso.app](https://okso.app)* ## Ссылки diff --git a/src/data-structures/graph/README.zh-CN.md b/src/data-structures/graph/README.zh-CN.md index 49c97715..1f885a43 100644 --- a/src/data-structures/graph/README.zh-CN.md +++ b/src/data-structures/graph/README.zh-CN.md @@ -11,9 +11,9 @@ 如果顶点对之间的边是有权重的,该图可称为加权图。 +![Graph](./images/graph.jpeg) - -![Graph](https://www.tutorialspoint.com/data_structures_algorithms/images/graph.jpg) +*Made with [okso.app](https://okso.app)* ## 参考 diff --git a/src/data-structures/graph/images/graph.jpeg b/src/data-structures/graph/images/graph.jpeg new file mode 100644 index 00000000..e49ecc0b Binary files /dev/null and b/src/data-structures/graph/images/graph.jpeg differ diff --git a/src/data-structures/hash-table/README.fr-FR.md b/src/data-structures/hash-table/README.fr-FR.md index f32d8e56..2fd41c88 100644 --- a/src/data-structures/hash-table/README.fr-FR.md +++ b/src/data-structures/hash-table/README.fr-FR.md @@ -17,11 +17,13 @@ hachage où la fonction de hachage génère le même index pour plusieurs clés. De telles collisions doivent être accommodées d'une manière ou d'une autre. -![Hash Table](https://upload.wikimedia.org/wikipedia/commons/7/7d/Hash_table_3_1_1_0_1_0_0_SP.svg) +![Hash Table](./images/hash-table.jpeg) Collision de hachage résolue par chaînage séparé. -![Hash Collision](https://upload.wikimedia.org/wikipedia/commons/d/d0/Hash_table_5_0_1_1_1_1_1_LL.svg) +![Hash Collision](./images/collision-resolution.jpeg) + +*Made with [okso.app](https://okso.app)* ## Références diff --git a/src/data-structures/hash-table/README.ja-JP.md b/src/data-structures/hash-table/README.ja-JP.md index 85bf71d1..d71cb273 100644 --- a/src/data-structures/hash-table/README.ja-JP.md +++ b/src/data-structures/hash-table/README.ja-JP.md @@ -1,14 +1,16 @@ # ハッシュテーブル - + コンピュータサイエンスにおいて、**ハッシュテーブル**(ハッシュマップ)は*キーを値にマッピング*できる*連想配列*の機能を持ったデータ構造です。ハッシュテーブルは*ハッシュ関数*を使ってバケットやスロットの配列へのインデックスを計算し、そこから目的の値を見つけることができます。 理想的には、ハッシュ関数は各キーを一意のバケットに割り当てますが、ほとんどのハッシュテーブルは不完全なハッシュ関数を採用しているため、複数のキーに対して同じインデックスを生成した時にハッシュの衝突が起こります。このような衝突は何らかの方法で対処する必要があります。 -![Hash Table](https://upload.wikimedia.org/wikipedia/commons/7/7d/Hash_table_3_1_1_0_1_0_0_SP.svg) +![Hash Table](./images/hash-table.jpeg) チェイン法によるハッシュの衝突の解決例 -![Hash Collision](https://upload.wikimedia.org/wikipedia/commons/d/d0/Hash_table_5_0_1_1_1_1_1_LL.svg) +![Hash Collision](./images/collision-resolution.jpeg) + +*Made with [okso.app](https://okso.app)* ## 参考 diff --git a/src/data-structures/hash-table/README.ko-KR.md b/src/data-structures/hash-table/README.ko-KR.md index 0b847df5..b3a8c940 100644 --- a/src/data-structures/hash-table/README.ko-KR.md +++ b/src/data-structures/hash-table/README.ko-KR.md @@ -11,13 +11,17 @@ _Read this in other languages:_ 이상적으로, 해시 함수는 각 키들을 고유 버킷에 할당하지만 대부분의 해시 테이블은 불완전한 해시 함수를 사용하기 때문에 해시 함수를 통해 두 개 이상의 키에 대해 동일한 인덱스를 생성하는 해시 충돌이 발생할 수 있습니다. 이러한 해시 충돌은 어떠한 방법으로든 해결되어야 합니다. -![Hash Table](https://upload.wikimedia.org/wikipedia/commons/7/7d/Hash_table_3_1_1_0_1_0_0_SP.svg) +![Hash Table](./images/hash-table.jpeg) + +*Made with [okso.app](https://okso.app)* 다음은 분리 연결법을 통해 해시 충돌을 해결한 예시입니다. -![Hash Collision](https://upload.wikimedia.org/wikipedia/commons/d/d0/Hash_table_5_0_1_1_1_1_1_LL.svg) +![Hash Collision](./images/collision-resolution.jpeg) + +*Made with [okso.app](https://okso.app)* ## 참고 - [Wikipedia](https://en.wikipedia.org/wiki/Hash_table) -- [YouTube](https://www.youtube.com/watch?v=shs0KM3wKv8&index=4&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8) \ No newline at end of file +- [YouTube](https://www.youtube.com/watch?v=shs0KM3wKv8&index=4&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8) diff --git a/src/data-structures/hash-table/README.md b/src/data-structures/hash-table/README.md index 3aec51b5..8711bd9b 100644 --- a/src/data-structures/hash-table/README.md +++ b/src/data-structures/hash-table/README.md @@ -22,11 +22,13 @@ collisions where the hash function generates the same index for more than one key. Such collisions must be accommodated in some way. -![Hash Table](https://upload.wikimedia.org/wikipedia/commons/7/7d/Hash_table_3_1_1_0_1_0_0_SP.svg) +![Hash Table](./images/hash-table.jpeg) Hash collision resolved by separate chaining. -![Hash Collision](https://upload.wikimedia.org/wikipedia/commons/d/d0/Hash_table_5_0_1_1_1_1_1_LL.svg) +![Hash Collision](./images/collision-resolution.jpeg) + +*Made with [okso.app](https://okso.app)* ## References diff --git a/src/data-structures/hash-table/README.pt-BR.md b/src/data-structures/hash-table/README.pt-BR.md index 0adf9ca9..9abbb488 100644 --- a/src/data-structures/hash-table/README.pt-BR.md +++ b/src/data-structures/hash-table/README.pt-BR.md @@ -13,11 +13,13 @@ imperfeita, pela qual poderá causar colisões de hashes onde a função de hash gera o mesmo índice para mais de uma chave.Tais colisões devem ser acomodados de alguma forma. -![Hash Table](https://upload.wikimedia.org/wikipedia/commons/7/7d/Hash_table_3_1_1_0_1_0_0_SP.svg) +![Hash Table](./images/hash-table.jpeg) Colisão de hash resolvida por encadeamento separado. -![Hash Collision](https://upload.wikimedia.org/wikipedia/commons/d/d0/Hash_table_5_0_1_1_1_1_1_LL.svg) +![Hash Collision](./images/collision-resolution.jpeg) + +*Made with [okso.app](https://okso.app)* ## Referências diff --git a/src/data-structures/hash-table/README.ru-RU.md b/src/data-structures/hash-table/README.ru-RU.md index 1b829049..e1e21129 100644 --- a/src/data-structures/hash-table/README.ru-RU.md +++ b/src/data-structures/hash-table/README.ru-RU.md @@ -2,10 +2,10 @@ **Хеш-таблица** - структура данных, реализующая абстрактный тип данных *ассоциативный массив*, т.е. структура, которая *связывает ключи со значениями*. Хеш-таблица использует *хеш-функцию* для вычисления индекса в массиве, в котором может -быть найдено желаемое значение. Ниже представлена хеш-таблица, в которой ключом выступает имя человека, а значениями +быть найдено желаемое значение. Ниже представлена хеш-таблица, в которой ключом выступает имя человека, а значениями являются телефонные номера. Хеш-функция преобразует ключ-имя в индекс массива с телефонными номерами. -![Хеш-таблица](https://upload.wikimedia.org/wikipedia/commons/7/7d/Hash_table_3_1_1_0_1_0_0_SP.svg) +![Hash Table](./images/hash-table.jpeg) В идеале хеш-функция будет присваивать элементу массива уникальный ключ. Однако большинство реальных хеш-таблиц используют несовершенные хеш-функции. Это может привести к ситуациям, когда хеш-функция генерирует одинаковый индекс для @@ -14,9 +14,13 @@ Существует два варианта решения коллизий - хеш-таблица с цепочками и с открытой адресацией. Метод цепочек подразумевает хранение значений, соответствующих одному и тому же индексу в виде связного списка(цепочки). -![Хеш цепочки](https://upload.wikimedia.org/wikipedia/commons/d/d0/Hash_table_5_0_1_1_1_1_1_LL.svg) + +![Hash Collision](./images/collision-resolution.jpeg) + +*Made with [okso.app](https://okso.app)* Метод открытой адресации помещает значение, для которого получен дублирующий индекс, в первую свободную ячейку. + ![Хеш открытая адресация](https://upload.wikimedia.org/wikipedia/commons/thumb/b/bf/Hash_table_5_0_1_1_1_1_0_SP.svg/380px-Hash_table_5_0_1_1_1_1_0_SP.svg.png) ## Ссылки diff --git a/src/data-structures/hash-table/README.zh-CN.md b/src/data-structures/hash-table/README.zh-CN.md index f9219df8..c53214aa 100644 --- a/src/data-structures/hash-table/README.zh-CN.md +++ b/src/data-structures/hash-table/README.zh-CN.md @@ -1,6 +1,6 @@ # 哈希表 -在计算中, 一个 **哈希表(hash table 或hash map)** 是一种实现 *关联数组(associative array)* +在计算中, 一个 **哈希表(hash table 或hash map)** 是一种实现 *关联数组(associative array)* 的抽象数据类型, 该结构可以将 *键映射到值*。 哈希表使用 *哈希函数/散列函数* 来计算一个值在数组或桶(buckets)中或槽(slots)中对应的索引,可使用该索引找到所需的值。 @@ -9,11 +9,15 @@ 以某种方式进行处理。 -![Hash Table](https://upload.wikimedia.org/wikipedia/commons/7/7d/Hash_table_3_1_1_0_1_0_0_SP.svg) +![Hash Table](./images/hash-table.jpeg) + +*Made with [okso.app](https://okso.app)* 通过单独的链接解决哈希冲突 -![Hash Collision](https://upload.wikimedia.org/wikipedia/commons/d/d0/Hash_table_5_0_1_1_1_1_1_LL.svg) +![Hash Collision](./images/collision-resolution.jpeg) + +*Made with [okso.app](https://okso.app)* ## 参考 diff --git a/src/data-structures/hash-table/images/collision-resolution.jpeg b/src/data-structures/hash-table/images/collision-resolution.jpeg new file mode 100644 index 00000000..1e0c9792 Binary files /dev/null and b/src/data-structures/hash-table/images/collision-resolution.jpeg differ diff --git a/src/data-structures/hash-table/images/hash-table.jpeg b/src/data-structures/hash-table/images/hash-table.jpeg new file mode 100644 index 00000000..f350453c Binary files /dev/null and b/src/data-structures/hash-table/images/hash-table.jpeg differ diff --git a/src/data-structures/heap/images/array-representation.jpeg b/src/data-structures/heap/images/array-representation.jpeg index 123b641c..8914e710 100644 Binary files a/src/data-structures/heap/images/array-representation.jpeg and b/src/data-structures/heap/images/array-representation.jpeg differ diff --git a/src/data-structures/heap/images/max-heap.jpeg b/src/data-structures/heap/images/max-heap.jpeg index 1ec1fea2..c1585d03 100644 Binary files a/src/data-structures/heap/images/max-heap.jpeg and b/src/data-structures/heap/images/max-heap.jpeg differ diff --git a/src/data-structures/heap/images/min-heap.jpeg b/src/data-structures/heap/images/min-heap.jpeg index 14867c1a..646923b2 100644 Binary files a/src/data-structures/heap/images/min-heap.jpeg and b/src/data-structures/heap/images/min-heap.jpeg differ diff --git a/src/data-structures/linked-list/images/linked-list.jpeg b/src/data-structures/linked-list/images/linked-list.jpeg index fbeab631..61a07120 100644 Binary files a/src/data-structures/linked-list/images/linked-list.jpeg and b/src/data-structures/linked-list/images/linked-list.jpeg differ diff --git a/src/data-structures/queue/images/queue.jpeg b/src/data-structures/queue/images/queue.jpeg index 0e412d55..579f4d8c 100644 Binary files a/src/data-structures/queue/images/queue.jpeg and b/src/data-structures/queue/images/queue.jpeg differ diff --git a/src/data-structures/stack/images/stack.jpg b/src/data-structures/stack/images/stack.jpg new file mode 100644 index 00000000..8c966f27 Binary files /dev/null and b/src/data-structures/stack/images/stack.jpg differ diff --git a/src/data-structures/tree/binary-search-tree/README.md b/src/data-structures/tree/binary-search-tree/README.md index f3e448a9..d05a8915 100644 --- a/src/data-structures/tree/binary-search-tree/README.md +++ b/src/data-structures/tree/binary-search-tree/README.md @@ -3,32 +3,34 @@ _Read this in other languages:_ [_Português_](README.pt-BR.md) -In computer science, **binary search trees** (BST), sometimes called -ordered or sorted binary trees, are a particular type of container: -data structures that store "items" (such as numbers, names etc.) -in memory. They allow fast lookup, addition and removal of -items, and can be used to implement either dynamic sets of -items, or lookup tables that allow finding an item by its key +In computer science, **binary search trees** (BST), sometimes called +ordered or sorted binary trees, are a particular type of container: +data structures that store "items" (such as numbers, names etc.) +in memory. They allow fast lookup, addition and removal of +items, and can be used to implement either dynamic sets of +items, or lookup tables that allow finding an item by its key (e.g., finding the phone number of a person by name). -Binary search trees keep their keys in sorted order, so that lookup -and other operations can use the principle of binary search: -when looking for a key in a tree (or a place to insert a new key), -they traverse the tree from root to leaf, making comparisons to -keys stored in the nodes of the tree and deciding, on the basis -of the comparison, to continue searching in the left or right -subtrees. On average, this means that each comparison allows -the operations to skip about half of the tree, so that each -lookup, insertion or deletion takes time proportional to the -logarithm of the number of items stored in the tree. This is -much better than the linear time required to find items by key -in an (unsorted) array, but slower than the corresponding +Binary search trees keep their keys in sorted order, so that lookup +and other operations can use the principle of binary search: +when looking for a key in a tree (or a place to insert a new key), +they traverse the tree from root to leaf, making comparisons to +keys stored in the nodes of the tree and deciding, on the basis +of the comparison, to continue searching in the left or right +subtrees. On average, this means that each comparison allows +the operations to skip about half of the tree, so that each +lookup, insertion or deletion takes time proportional to the +logarithm of the number of items stored in the tree. This is +much better than the linear time required to find items by key +in an (unsorted) array, but slower than the corresponding operations on hash tables. A binary search tree of size 9 and depth 3, with 8 at the root. The leaves are not drawn. -![Binary Search Tree](https://upload.wikimedia.org/wikipedia/commons/d/da/Binary_search_tree.svg) +![Trie](./images/binary-search-tree.jpg) + +*Made with [okso.app](https://okso.app)* ## Pseudocode for Basic Operations @@ -45,7 +47,7 @@ insert(value) end if end insert ``` - + ```text insertNode(current, value) Pre: current is the node to start from @@ -84,8 +86,8 @@ contains(root, value) end if end contains ``` - - + + ### Deletion ```text @@ -186,7 +188,7 @@ findNode(root, value) end if end findNode ``` - + ### Find Minimum ```text @@ -200,7 +202,7 @@ findMin(root) findMin(root.left) end findMin ``` - + ### Find Maximum ```text @@ -214,7 +216,7 @@ findMax(root) findMax(root.right) end findMax ``` - + ### Traversal #### InOrder Traversal @@ -244,7 +246,7 @@ preorder(root) end if end preorder ``` - + #### PostOrder Traversal ```text @@ -258,7 +260,7 @@ postorder(root) end if end postorder ``` - + ## Complexities ### Time Complexity diff --git a/src/data-structures/tree/binary-search-tree/README.pt-BR.md b/src/data-structures/tree/binary-search-tree/README.pt-BR.md index 4565538a..1e717141 100644 --- a/src/data-structures/tree/binary-search-tree/README.pt-BR.md +++ b/src/data-structures/tree/binary-search-tree/README.pt-BR.md @@ -26,8 +26,9 @@ Uma pesquisa de árvore binária de tamanho 9 e profundidade 3, com valor 8 na raíz. As folhas não foram desenhadas. +![Trie](./images/binary-search-tree.jpg) -![Binary Search Tree](https://upload.wikimedia.org/wikipedia/commons/d/da/Binary_search_tree.svg) +*Made with [okso.app](https://okso.app)* ## Pseudocódigo para Operações Básicas @@ -44,7 +45,7 @@ insert(value) end if end insert ``` - + ```text insertNode(current, value) Pre: current is the node to start from @@ -83,8 +84,8 @@ contains(root, value) end if end contains ``` - - + + ### Remoção ```text @@ -185,7 +186,7 @@ findNode(root, value) end if end findNode ``` - + ### Encontrar Mínimo ```text @@ -199,7 +200,7 @@ findMin(root) findMin(root.left) end findMin ``` - + ### Encontrar Máximo ```text @@ -213,7 +214,7 @@ findMax(root) findMax(root.right) end findMax ``` - + ### Traversal #### Na Ordem Traversal (InOrder Traversal) @@ -243,7 +244,7 @@ preorder(root) end if end preorder ``` - + #### Pós Ordem Traversal (PostOrder Traversal) ```text @@ -257,7 +258,7 @@ postorder(root) end if end postorder ``` - + ## Complexidades ### Complexidade de Tempo diff --git a/src/data-structures/tree/binary-search-tree/images/binary-search-tree.jpg b/src/data-structures/tree/binary-search-tree/images/binary-search-tree.jpg new file mode 100644 index 00000000..1309e4ee Binary files /dev/null and b/src/data-structures/tree/binary-search-tree/images/binary-search-tree.jpg differ diff --git a/src/data-structures/tree/images/tree.jpeg b/src/data-structures/tree/images/tree.jpeg index d5919725..c888843d 100644 Binary files a/src/data-structures/tree/images/tree.jpeg and b/src/data-structures/tree/images/tree.jpeg differ diff --git a/src/data-structures/trie/README.md b/src/data-structures/trie/README.md index d07c69fe..f6f38ece 100644 --- a/src/data-structures/trie/README.md +++ b/src/data-structures/trie/README.md @@ -5,22 +5,24 @@ _Read this in other languages:_ [_Русский_](README.ru-RU.md), [_Português_](README.pt-BR.md) -In computer science, a **trie**, also called digital tree and sometimes -radix tree or prefix tree (as they can be searched by prefixes), -is a kind of search tree—an ordered tree data structure that is -used to store a dynamic set or associative array where the keys -are usually strings. Unlike a binary search tree, no node in the -tree stores the key associated with that node; instead, its +In computer science, a **trie**, also called digital tree and sometimes +radix tree or prefix tree (as they can be searched by prefixes), +is a kind of search tree—an ordered tree data structure that is +used to store a dynamic set or associative array where the keys +are usually strings. Unlike a binary search tree, no node in the +tree stores the key associated with that node; instead, its position in the tree defines the key with which it is associated. All the descendants of a node have a common prefix of the string -associated with that node, and the root is associated with the -empty string. Values are not necessarily associated with every -node. Rather, values tend only to be associated with leaves, -and with some inner nodes that correspond to keys of interest. -For the space-optimized presentation of prefix tree, see compact +associated with that node, and the root is associated with the +empty string. Values are not necessarily associated with every +node. Rather, values tend only to be associated with leaves, +and with some inner nodes that correspond to keys of interest. +For the space-optimized presentation of prefix tree, see compact prefix tree. -![Trie](https://upload.wikimedia.org/wikipedia/commons/b/be/Trie_example.svg) +![Trie](./images/trie.jpg) + +*Made with [okso.app](https://okso.app)* ## References diff --git a/src/data-structures/trie/README.pt-BR.md b/src/data-structures/trie/README.pt-BR.md index 7a141581..b0d49de1 100644 --- a/src/data-structures/trie/README.pt-BR.md +++ b/src/data-structures/trie/README.pt-BR.md @@ -3,7 +3,7 @@ Na ciência da computação, uma **trie**, também chamada de árvore digital (digital tree) e algumas vezes de _radix tree_ ou _prefix tree_ (tendo em vista que eles podem ser pesquisados por prefixos), é um tipo de árvore de pesquisa, uma -uma estrutura de dados de árvore ordenada que é usado para armazenar um +uma estrutura de dados de árvore ordenada que é usado para armazenar um conjunto dinâmico ou matriz associativa onde as chaves são geralmente _strings_. Ao contrário de uma árvore de pesquisa binária (binary search tree), nenhum nó na árvore armazena a chave associada a esse nó; em vez disso, @@ -17,7 +17,9 @@ internos que correspondem a chaves de interesse. Para a apresentação otimizada do espaço da árvore de prefixo (_prefix tree_), veja árvore de prefixo compacto. -![Trie](https://upload.wikimedia.org/wikipedia/commons/b/be/Trie_example.svg) +![Trie](./images/trie.jpg) + +*Made with [okso.app](https://okso.app)* ## Referências diff --git a/src/data-structures/trie/README.ru-RU.md b/src/data-structures/trie/README.ru-RU.md index f447f8eb..30a45363 100644 --- a/src/data-structures/trie/README.ru-RU.md +++ b/src/data-structures/trie/README.ru-RU.md @@ -16,7 +16,9 @@ дополнительную информацию, связанную с ключом, и обычно выделенными являются только листья и, возможно, некоторые внутренние узлы. -![Префиксное дерево](https://upload.wikimedia.org/wikipedia/commons/b/be/Trie_example.svg) +![Префиксное дерево](./images/trie.jpg) + +*Made with [okso.app](https://okso.app)* На рисунке представлено префиксное дерево, содержащее ключи «A», «to», «tea», «ted», «ten», «i», «in», «inn». diff --git a/src/data-structures/trie/README.zh-CN.md b/src/data-structures/trie/README.zh-CN.md index bad277d4..e812f575 100644 --- a/src/data-structures/trie/README.zh-CN.md +++ b/src/data-structures/trie/README.zh-CN.md @@ -2,13 +2,15 @@ 在计算机科学中, **字典树(trie,中文又被称为”单词查找树“或 ”键树“)**, 也称为数字树,有时候也被称为基数树或前缀树(因为它们可以通过前缀搜索),它是一种搜索树--一种已排序的数据结构,通常用于存储动态集或键为字符串的关联数组。 -与二叉搜索树不同, 树上没有节点存储与该节点关联的键; 相反,节点在树上的位置定义了与之关联的键。一个节点的全部后代节点都有一个与该节点关联的通用的字符串前缀, 与根节点关联的是空字符串。 +与二叉搜索树不同, 树上没有节点存储与该节点关联的键; 相反,节点在树上的位置定义了与之关联的键。一个节点的全部后代节点都有一个与该节点关联的通用的字符串前缀, 与根节点关联的是空字符串。 值对于字典树中关联的节点来说,不是必需的,相反,值往往和相关的叶子相关,以及与一些键相关的内部节点相关。 有关字典树的空间优化示意,请参阅紧凑前缀树 -![Trie](https://upload.wikimedia.org/wikipedia/commons/b/be/Trie_example.svg) +![Trie](./images/trie.jpg) + +*Made with [okso.app](https://okso.app)* ## 参考 diff --git a/src/data-structures/trie/images/trie.jpg b/src/data-structures/trie/images/trie.jpg new file mode 100644 index 00000000..001b04f2 Binary files /dev/null and b/src/data-structures/trie/images/trie.jpg differ