data-structure-typed 0.9.16 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +665 -172
- package/dist/bundle.js +2 -0
- package/dist/bundle.js.LICENSE.txt +13 -0
- package/dist/data-structures/binary-tree/aa-tree.js +2 -5
- package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +364 -0
- package/dist/data-structures/binary-tree/abstract-binary-tree.js +1308 -0
- package/dist/data-structures/binary-tree/avl-tree.d.ts +85 -14
- package/dist/data-structures/binary-tree/avl-tree.js +142 -116
- package/dist/data-structures/binary-tree/b-tree.js +2 -5
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +39 -1
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +54 -13
- package/dist/data-structures/binary-tree/binary-tree.d.ts +29 -126
- package/dist/data-structures/binary-tree/binary-tree.js +31 -1093
- package/dist/data-structures/binary-tree/bst.d.ts +117 -23
- package/dist/data-structures/binary-tree/bst.js +233 -240
- package/dist/data-structures/binary-tree/index.d.ts +1 -0
- package/dist/data-structures/binary-tree/index.js +1 -0
- package/dist/data-structures/binary-tree/rb-tree.d.ts +18 -1
- package/dist/data-structures/binary-tree/rb-tree.js +40 -5
- package/dist/data-structures/binary-tree/segment-tree.d.ts +61 -11
- package/dist/data-structures/binary-tree/segment-tree.js +126 -93
- package/dist/data-structures/binary-tree/splay-tree.js +2 -5
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +213 -6
- package/dist/data-structures/binary-tree/tree-multiset.js +687 -34
- package/dist/data-structures/binary-tree/two-three-tree.js +2 -5
- package/dist/data-structures/graph/abstract-graph.d.ts +270 -36
- package/dist/data-structures/graph/abstract-graph.js +610 -572
- package/dist/data-structures/graph/directed-graph.d.ts +173 -16
- package/dist/data-structures/graph/directed-graph.js +345 -313
- package/dist/data-structures/graph/index.d.ts +1 -0
- package/dist/data-structures/graph/index.js +1 -0
- package/dist/data-structures/graph/map-graph.d.ts +79 -0
- package/dist/data-structures/graph/map-graph.js +111 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +111 -9
- package/dist/data-structures/graph/undirected-graph.js +203 -178
- package/dist/data-structures/hash/coordinate-map.d.ts +38 -1
- package/dist/data-structures/hash/coordinate-map.js +59 -36
- package/dist/data-structures/hash/coordinate-set.d.ts +32 -2
- package/dist/data-structures/hash/coordinate-set.js +49 -33
- package/dist/data-structures/hash/hash-table.d.ts +2 -1
- package/dist/data-structures/hash/hash-table.js +4 -0
- package/dist/data-structures/hash/pair.d.ts +2 -1
- package/dist/data-structures/hash/pair.js +4 -0
- package/dist/data-structures/hash/tree-map.d.ts +2 -1
- package/dist/data-structures/hash/tree-map.js +4 -0
- package/dist/data-structures/hash/tree-set.d.ts +2 -1
- package/dist/data-structures/hash/tree-set.js +4 -0
- package/dist/data-structures/heap/heap.d.ts +62 -45
- package/dist/data-structures/heap/heap.js +124 -86
- package/dist/data-structures/heap/max-heap.d.ts +13 -5
- package/dist/data-structures/heap/max-heap.js +18 -28
- package/dist/data-structures/heap/min-heap.d.ts +14 -5
- package/dist/data-structures/heap/min-heap.js +19 -28
- package/dist/data-structures/index.d.ts +1 -1
- package/dist/data-structures/index.js +1 -1
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +193 -56
- package/dist/data-structures/linked-list/doubly-linked-list.js +484 -220
- package/dist/data-structures/linked-list/index.d.ts +1 -0
- package/dist/data-structures/linked-list/index.js +1 -0
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +117 -315
- package/dist/data-structures/linked-list/singly-linked-list.js +374 -727
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -1
- package/dist/data-structures/linked-list/skip-linked-list.js +4 -0
- package/dist/data-structures/matrix/matrix.d.ts +12 -0
- package/dist/data-structures/matrix/matrix.js +21 -8
- package/dist/data-structures/matrix/matrix2d.d.ts +85 -2
- package/dist/data-structures/matrix/matrix2d.js +146 -80
- package/dist/data-structures/matrix/navigator.d.ts +36 -1
- package/dist/data-structures/matrix/navigator.js +46 -37
- package/dist/data-structures/matrix/vector2d.d.ts +142 -15
- package/dist/data-structures/matrix/vector2d.js +215 -109
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -2
- package/dist/data-structures/priority-queue/max-priority-queue.js +33 -26
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +12 -2
- package/dist/data-structures/priority-queue/min-priority-queue.js +34 -26
- package/dist/data-structures/priority-queue/priority-queue.d.ts +153 -3
- package/dist/data-structures/priority-queue/priority-queue.js +244 -143
- package/dist/data-structures/queue/deque.d.ts +141 -13
- package/dist/data-structures/queue/deque.js +200 -82
- package/dist/data-structures/queue/queue.d.ts +65 -38
- package/dist/data-structures/queue/queue.js +110 -66
- package/dist/data-structures/stack/stack.d.ts +27 -32
- package/dist/data-structures/stack/stack.js +47 -53
- package/dist/data-structures/tree/index.d.ts +1 -0
- package/dist/data-structures/tree/index.js +17 -0
- package/dist/data-structures/tree/tree.d.ts +14 -0
- package/dist/data-structures/tree/tree.js +60 -0
- package/dist/data-structures/trie/trie.d.ts +33 -10
- package/dist/data-structures/trie/trie.js +123 -208
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/interfaces/abstract-binary-tree.d.ts +90 -0
- package/dist/interfaces/abstract-graph.d.ts +17 -0
- package/dist/interfaces/avl-tree.d.ts +9 -0
- package/dist/interfaces/binary-tree.d.ts +6 -0
- package/dist/interfaces/bst.d.ts +17 -0
- package/dist/interfaces/directed-graph.d.ts +12 -0
- package/{src/data-structures/types/index.ts → dist/interfaces/index.d.ts} +10 -8
- package/dist/interfaces/index.js +31 -0
- package/{src/data-structures/hash/hash-table.ts → dist/interfaces/priority-queue.d.ts} +1 -1
- package/dist/interfaces/rb-tree.d.ts +8 -0
- package/dist/interfaces/segment-tree.d.ts +1 -0
- package/dist/interfaces/singly-linked-list.d.ts +1 -0
- package/dist/interfaces/singly-linked-list.js +2 -0
- package/dist/interfaces/tree-multiset.d.ts +7 -0
- package/dist/interfaces/tree-multiset.js +2 -0
- package/dist/interfaces/undirected-graph.d.ts +5 -0
- package/dist/interfaces/undirected-graph.js +2 -0
- package/dist/types/data-structures/abstract-binary-tree.d.ts +34 -0
- package/dist/types/data-structures/abstract-binary-tree.js +25 -0
- package/dist/types/data-structures/abstract-graph.d.ts +11 -0
- package/dist/types/data-structures/abstract-graph.js +2 -0
- package/dist/types/data-structures/avl-tree.d.ts +4 -0
- package/dist/types/data-structures/avl-tree.js +2 -0
- package/dist/types/data-structures/binary-tree.d.ts +4 -0
- package/dist/types/data-structures/binary-tree.js +2 -0
- package/dist/types/data-structures/bst.d.ts +13 -0
- package/dist/types/data-structures/bst.js +9 -0
- package/dist/types/data-structures/directed-graph.d.ts +6 -0
- package/dist/types/data-structures/directed-graph.js +9 -0
- package/dist/types/data-structures/doubly-linked-list.d.ts +1 -0
- package/dist/types/data-structures/doubly-linked-list.js +2 -0
- package/dist/types/data-structures/heap.d.ts +3 -0
- package/dist/types/data-structures/heap.js +2 -0
- package/dist/{data-structures/types → types/data-structures}/index.d.ts +3 -1
- package/dist/{data-structures/types → types/data-structures}/index.js +3 -1
- package/dist/types/data-structures/map-graph.d.ts +1 -0
- package/dist/types/data-structures/map-graph.js +2 -0
- package/dist/{data-structures/types → types/data-structures}/navigator.d.ts +2 -2
- package/dist/types/data-structures/navigator.js +2 -0
- package/dist/{data-structures/types → types/data-structures}/priority-queue.d.ts +2 -2
- package/dist/types/data-structures/priority-queue.js +2 -0
- package/dist/types/data-structures/rb-tree.d.ts +8 -0
- package/dist/types/data-structures/rb-tree.js +8 -0
- package/dist/types/data-structures/segment-tree.js +2 -0
- package/dist/types/data-structures/singly-linked-list.d.ts +1 -0
- package/dist/types/data-structures/singly-linked-list.js +2 -0
- package/dist/types/data-structures/tree-multiset.d.ts +4 -0
- package/dist/types/data-structures/tree-multiset.js +2 -0
- package/dist/types/helpers.d.ts +1 -0
- package/dist/types/helpers.js +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +19 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.js +18 -0
- package/dist/types/utils/utils.d.ts +7 -0
- package/dist/types/utils/utils.js +2 -0
- package/dist/types/utils/validate-type.d.ts +19 -0
- package/dist/types/utils/validate-type.js +2 -0
- package/dist/utils/utils.d.ts +17 -103
- package/dist/utils/utils.js +40 -625
- package/package.json +96 -23
- package/.idea/data-structure-typed.iml +0 -12
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/dist/data-structures/trampoline.d.ts +0 -16
- package/dist/data-structures/trampoline.js +0 -130
- package/dist/data-structures/types/abstract-graph.d.ts +0 -29
- package/dist/data-structures/types/avl-tree.d.ts +0 -5
- package/dist/data-structures/types/binary-tree.d.ts +0 -16
- package/dist/data-structures/types/bst.d.ts +0 -7
- package/dist/data-structures/types/directed-graph.d.ts +0 -10
- package/dist/data-structures/types/doubly-linked-list.d.ts +0 -1
- package/dist/data-structures/types/heap.d.ts +0 -7
- package/dist/data-structures/types/singly-linked-list.d.ts +0 -5
- package/dist/data-structures/types/tree-multiset.d.ts +0 -5
- package/dist/data-structures/types/utils.d.ts +0 -52
- package/dist/data-structures/types/utils.js +0 -54
- package/src/data-structures/binary-tree/aa-tree.ts +0 -3
- package/src/data-structures/binary-tree/avl-tree.ts +0 -227
- package/src/data-structures/binary-tree/b-tree.ts +0 -3
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -33
- package/src/data-structures/binary-tree/binary-tree.ts +0 -1133
- package/src/data-structures/binary-tree/bst.ts +0 -395
- package/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
- package/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
- package/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
- package/src/data-structures/binary-tree/index.ts +0 -11
- package/src/data-structures/binary-tree/rb-tree.ts +0 -3
- package/src/data-structures/binary-tree/segment-tree.ts +0 -172
- package/src/data-structures/binary-tree/splay-tree.ts +0 -3
- package/src/data-structures/binary-tree/tree-multiset.ts +0 -18
- package/src/data-structures/binary-tree/two-three-tree.ts +0 -3
- package/src/data-structures/diagrams/README.md +0 -7
- package/src/data-structures/graph/abstract-graph.ts +0 -753
- package/src/data-structures/graph/diagrams/adjacency-list-pros-cons.png +0 -0
- package/src/data-structures/graph/diagrams/adjacency-list.png +0 -0
- package/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.png +0 -0
- package/src/data-structures/graph/diagrams/adjacency-matrix.png +0 -0
- package/src/data-structures/graph/diagrams/dfs-can-do.png +0 -0
- package/src/data-structures/graph/diagrams/edge-list-pros-cons.png +0 -0
- package/src/data-structures/graph/diagrams/edge-list.png +0 -0
- package/src/data-structures/graph/diagrams/max-flow.png +0 -0
- package/src/data-structures/graph/diagrams/mst.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
- package/src/data-structures/graph/directed-graph.ts +0 -306
- package/src/data-structures/graph/index.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +0 -155
- package/src/data-structures/hash/coordinate-map.ts +0 -24
- package/src/data-structures/hash/coordinate-set.ts +0 -20
- package/src/data-structures/hash/index.ts +0 -6
- package/src/data-structures/heap/heap.ts +0 -127
- package/src/data-structures/heap/index.ts +0 -3
- package/src/data-structures/heap/max-heap.ts +0 -23
- package/src/data-structures/heap/min-heap.ts +0 -25
- package/src/data-structures/index.ts +0 -12
- package/src/data-structures/linked-list/doubly-linked-list.ts +0 -250
- package/src/data-structures/linked-list/index.ts +0 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +0 -736
- package/src/data-structures/linked-list/skip-linked-list.ts +0 -1
- package/src/data-structures/matrix/index.ts +0 -4
- package/src/data-structures/matrix/matrix.ts +0 -13
- package/src/data-structures/matrix/matrix2d.ts +0 -125
- package/src/data-structures/matrix/navigator.ts +0 -87
- package/src/data-structures/matrix/vector2d.ts +0 -189
- package/src/data-structures/priority-queue/index.ts +0 -3
- package/src/data-structures/priority-queue/max-priority-queue.ts +0 -13
- package/src/data-structures/priority-queue/min-priority-queue.ts +0 -13
- package/src/data-structures/priority-queue/priority-queue.ts +0 -200
- package/src/data-structures/queue/deque.ts +0 -139
- package/src/data-structures/queue/index.ts +0 -2
- package/src/data-structures/queue/queue.ts +0 -122
- package/src/data-structures/stack/index.ts +0 -1
- package/src/data-structures/stack/stack.ts +0 -103
- package/src/data-structures/trampoline.ts +0 -51
- package/src/data-structures/trie/index.ts +0 -1
- package/src/data-structures/trie/trie.ts +0 -203
- package/src/data-structures/types/abstract-graph.ts +0 -51
- package/src/data-structures/types/avl-tree.ts +0 -6
- package/src/data-structures/types/binary-tree.ts +0 -15
- package/src/data-structures/types/bst.ts +0 -5
- package/src/data-structures/types/directed-graph.ts +0 -18
- package/src/data-structures/types/doubly-linked-list.ts +0 -1
- package/src/data-structures/types/heap.ts +0 -8
- package/src/data-structures/types/navigator.ts +0 -12
- package/src/data-structures/types/priority-queue.ts +0 -9
- package/src/data-structures/types/segment-tree.ts +0 -1
- package/src/data-structures/types/singly-linked-list.ts +0 -15
- package/src/data-structures/types/tree-multiset.ts +0 -3
- package/src/data-structures/types/utils.ts +0 -173
- package/src/index.ts +0 -1
- package/src/utils/index.ts +0 -1
- package/src/utils/utils.ts +0 -505
- package/tsconfig.json +0 -56
- /package/dist/{data-structures/types/abstract-graph.js → interfaces/abstract-binary-tree.js} +0 -0
- /package/dist/{data-structures/types/avl-tree.js → interfaces/abstract-graph.js} +0 -0
- /package/dist/{data-structures/types/binary-tree.js → interfaces/avl-tree.js} +0 -0
- /package/dist/{data-structures/types/bst.js → interfaces/binary-tree.js} +0 -0
- /package/dist/{data-structures/types/directed-graph.js → interfaces/bst.js} +0 -0
- /package/dist/{data-structures/types/doubly-linked-list.js → interfaces/directed-graph.js} +0 -0
- /package/{src/data-structures/hash/pair.ts → dist/interfaces/doubly-linked-list.d.ts} +0 -0
- /package/dist/{data-structures/types/heap.js → interfaces/doubly-linked-list.js} +0 -0
- /package/{src/data-structures/hash/tree-map.ts → dist/interfaces/heap.d.ts} +0 -0
- /package/dist/{data-structures/types/navigator.js → interfaces/heap.js} +0 -0
- /package/{src/data-structures/hash/tree-set.ts → dist/interfaces/navigator.d.ts} +0 -0
- /package/dist/{data-structures/types/priority-queue.js → interfaces/navigator.js} +0 -0
- /package/dist/{data-structures/types/segment-tree.js → interfaces/priority-queue.js} +0 -0
- /package/dist/{data-structures/types/singly-linked-list.js → interfaces/rb-tree.js} +0 -0
- /package/dist/{data-structures/types/tree-multiset.js → interfaces/segment-tree.js} +0 -0
- /package/dist/{data-structures/types → types/data-structures}/segment-tree.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,197 +1,690 @@
|
|
|
1
|
-
#
|
|
1
|
+
# What
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Brief
|
|
4
|
+
Data Structures of Javascript & TypeScript.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
## Built-in classic algorithms
|
|
7
|
+
DFS(Depth-First Search), DFSIterative, BFS(Breadth-First Search),
|
|
8
|
+
morris, Bellman-Ford Algorithm, Dijkstra's Algorithm, Floyd-Warshall Algorithm,
|
|
9
|
+
Tarjan's Algorithm.
|
|
6
10
|
|
|
11
|
+
# How
|
|
12
|
+
## install
|
|
13
|
+
### npm
|
|
14
|
+
```bash
|
|
15
|
+
npm install data-structure-typed --save
|
|
16
|
+
```
|
|
17
|
+
### yarn
|
|
7
18
|
```bash
|
|
8
19
|
yarn add data-structure-typed
|
|
9
20
|
```
|
|
21
|
+
### CDN
|
|
22
|
+
```html
|
|
23
|
+
<script src="https://cdn.jsdelivr.net/npm/data-structure-typed/dist/bundle.js"></script>
|
|
24
|
+
```
|
|
25
|
+
```javascript
|
|
26
|
+
const {AVLTree} = dataStructureTyped;
|
|
27
|
+
const {Heap, MinHeap, SinglyLinkedList, Stack, AVLTreeNode, BST, Trie, DirectedGraph, DirectedVertex, TreeMultiset} = dataStructureTyped;
|
|
28
|
+
```
|
|
10
29
|
|
|
11
|
-
|
|
30
|
+

|
|
31
|
+

|
|
32
|
+

|
|
33
|
+

|
|
34
|
+

|
|
35
|
+

|
|
36
|
+

|
|
37
|
+
|
|
38
|
+
## API docs & Examples
|
|
39
|
+
|
|
40
|
+
[API Docs](https://data-structure-typed-docs.vercel.app)
|
|
41
|
+
|
|
42
|
+
[Live Examples](https://vivid-algorithm.vercel.app)
|
|
43
|
+
|
|
44
|
+
<a href="https://github.com/zrwusa/vivid-algorithm" target="_blank">Examples Repository</a>
|
|
45
|
+
|
|
46
|
+
## Code Snippet
|
|
47
|
+
### Binary Search Tree (BST) snippet
|
|
48
|
+
#### TS
|
|
49
|
+
```typescript
|
|
50
|
+
import {BST, BSTNode} from 'data-structure-typed';
|
|
51
|
+
|
|
52
|
+
const bst = new BST();
|
|
53
|
+
bst.add(11);
|
|
54
|
+
bst.add(3);
|
|
55
|
+
bst.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]);
|
|
56
|
+
bst.size === 16; // true
|
|
57
|
+
bst.has(6); // true
|
|
58
|
+
const node6 = bst.get(6);
|
|
59
|
+
bst.getHeight(6) === 2; // true
|
|
60
|
+
bst.getHeight() === 5; // true
|
|
61
|
+
bst.getDepth(6) === 3; // true
|
|
62
|
+
const leftMost = bst.getLeftMost();
|
|
63
|
+
leftMost?.id === 1; // true
|
|
64
|
+
expect(leftMost?.id).toBe(1);
|
|
65
|
+
bst.remove(6);
|
|
66
|
+
bst.get(6); // null
|
|
67
|
+
bst.isAVLBalanced(); // true or false
|
|
68
|
+
const bfsIDs = bst.BFS();
|
|
69
|
+
bfsIDs[0] === 11; // true
|
|
70
|
+
expect(bfsIDs[0]).toBe(11);
|
|
71
|
+
|
|
72
|
+
const objBST = new BST<BSTNode<{ id: number, keyA: number }>>();
|
|
73
|
+
objBST.add(11, {id: 11, keyA: 11});
|
|
74
|
+
objBST.add(3, {id: 3, keyA: 3});
|
|
75
|
+
|
|
76
|
+
objBST.addMany([{id: 15, keyA: 15}, {id: 1, keyA: 1}, {id: 8, keyA: 8},
|
|
77
|
+
{id: 13, keyA: 13}, {id: 16, keyA: 16}, {id: 2, keyA: 2},
|
|
78
|
+
{id: 6, keyA: 6}, {id: 9, keyA: 9}, {id: 12, keyA: 12},
|
|
79
|
+
{id: 14, keyA: 14}, {id: 4, keyA: 4}, {id: 7, keyA: 7},
|
|
80
|
+
{id: 10, keyA: 10}, {id: 5, keyA: 5}]);
|
|
81
|
+
|
|
82
|
+
objBST.remove(11);
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
const avlTree = new AVLTree();
|
|
86
|
+
avlTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5])
|
|
87
|
+
avlTree.isAVLBalanced(); // true
|
|
88
|
+
avlTree.remove(10);
|
|
89
|
+
avlTree.isAVLBalanced(); // true
|
|
12
90
|
|
|
13
|
-
```bash
|
|
14
|
-
npm install data-structure-typed
|
|
15
91
|
```
|
|
92
|
+
#### JS
|
|
93
|
+
```javascript
|
|
94
|
+
const {BST, BSTNode} = require('data-structure-typed');
|
|
16
95
|
|
|
17
|
-
|
|
96
|
+
const bst = new BST();
|
|
97
|
+
bst.add(11);
|
|
98
|
+
bst.add(3);
|
|
99
|
+
bst.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]);
|
|
100
|
+
bst.size === 16; // true
|
|
101
|
+
bst.has(6); // true
|
|
102
|
+
const node6 = bst.get(6);
|
|
103
|
+
bst.getHeight(6) === 2; // true
|
|
104
|
+
bst.getHeight() === 5; // true
|
|
105
|
+
bst.getDepth(6) === 3; // true
|
|
106
|
+
const leftMost = bst.getLeftMost();
|
|
107
|
+
leftMost?.id === 1; // true
|
|
108
|
+
expect(leftMost?.id).toBe(1);
|
|
109
|
+
bst.remove(6);
|
|
110
|
+
bst.get(6); // null
|
|
111
|
+
bst.isAVLBalanced(); // true or false
|
|
112
|
+
const bfsIDs = bst.BFS();
|
|
113
|
+
bfsIDs[0] === 11; // true
|
|
114
|
+
expect(bfsIDs[0]).toBe(11);
|
|
115
|
+
|
|
116
|
+
const objBST = new BST();
|
|
117
|
+
objBST.add(11, {id: 11, keyA: 11});
|
|
118
|
+
objBST.add(3, {id: 3, keyA: 3});
|
|
119
|
+
|
|
120
|
+
objBST.addMany([{id: 15, keyA: 15}, {id: 1, keyA: 1}, {id: 8, keyA: 8},
|
|
121
|
+
{id: 13, keyA: 13}, {id: 16, keyA: 16}, {id: 2, keyA: 2},
|
|
122
|
+
{id: 6, keyA: 6}, {id: 9, keyA: 9}, {id: 12, keyA: 12},
|
|
123
|
+
{id: 14, keyA: 14}, {id: 4, keyA: 4}, {id: 7, keyA: 7},
|
|
124
|
+
{id: 10, keyA: 10}, {id: 5, keyA: 5}]);
|
|
125
|
+
|
|
126
|
+
objBST.remove(11);
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
const avlTree = new AVLTree();
|
|
130
|
+
avlTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5])
|
|
131
|
+
avlTree.isAVLBalanced(); // true
|
|
132
|
+
avlTree.remove(10);
|
|
133
|
+
avlTree.isAVLBalanced(); // true
|
|
18
134
|
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Directed Graph simple snippet
|
|
138
|
+
#### TS or JS
|
|
139
|
+
```typescript
|
|
140
|
+
import {DirectedGraph} from 'data-structure-typed';
|
|
141
|
+
|
|
142
|
+
const graph = new DirectedGraph();
|
|
143
|
+
|
|
144
|
+
graph.addVertex('A');
|
|
145
|
+
graph.addVertex('B');
|
|
146
|
+
|
|
147
|
+
graph.hasVertex('A'); // true
|
|
148
|
+
graph.hasVertex('B'); // true
|
|
149
|
+
graph.hasVertex('C'); // false
|
|
150
|
+
|
|
151
|
+
graph.addEdge('A', 'B');
|
|
152
|
+
graph.hasEdge('A', 'B'); // true
|
|
153
|
+
graph.hasEdge('B', 'A'); // false
|
|
154
|
+
|
|
155
|
+
graph.removeEdgeSrcToDest('A', 'B');
|
|
156
|
+
graph.hasEdge('A', 'B'); // false
|
|
157
|
+
|
|
158
|
+
graph.addVertex('C');
|
|
159
|
+
|
|
160
|
+
graph.addEdge('A', 'B');
|
|
161
|
+
graph.addEdge('B', 'C');
|
|
162
|
+
|
|
163
|
+
const topologicalOrderIds = graph.topologicalSort(); // ['A', 'B', 'C']
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Undirected Graph snippet
|
|
167
|
+
#### TS or JS
|
|
168
|
+
```typescript
|
|
169
|
+
import {UndirectedGraph} from 'data-structure-typed';
|
|
170
|
+
|
|
171
|
+
const graph = new UndirectedGraph();
|
|
172
|
+
graph.addVertex('A');
|
|
173
|
+
graph.addVertex('B');
|
|
174
|
+
graph.addVertex('C');
|
|
175
|
+
graph.addVertex('D');
|
|
176
|
+
graph.removeVertex('C');
|
|
177
|
+
graph.addEdge('A', 'B');
|
|
178
|
+
graph.addEdge('B', 'D');
|
|
179
|
+
|
|
180
|
+
const dijkstraResult = graph.dijkstra('A');
|
|
181
|
+
Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.id) // ['A', 'B', 'D']
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Data Structures
|
|
19
185
|
<table>
|
|
20
186
|
<thead>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
187
|
+
<tr>
|
|
188
|
+
<th>Data Structure</th>
|
|
189
|
+
<th>Unit Test</th>
|
|
190
|
+
<th>Performance Test</th>
|
|
191
|
+
<th>API Documentation</th>
|
|
192
|
+
<th>Implemented</th>
|
|
193
|
+
</tr>
|
|
27
194
|
</thead>
|
|
195
|
+
<tbody>
|
|
196
|
+
<tr>
|
|
197
|
+
<td>Binary Tree</td>
|
|
198
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
199
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
200
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTree.html"><span>Binary Tree</span></a></td>
|
|
201
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
202
|
+
</tr>
|
|
203
|
+
<tr>
|
|
204
|
+
<td>Binary Search Tree (BST)</td>
|
|
205
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
206
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
207
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BST.html"><span>BST</span></a></td>
|
|
208
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
209
|
+
</tr>
|
|
210
|
+
<tr>
|
|
211
|
+
<td>AVL Tree</td>
|
|
212
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
213
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
214
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTree.html"><span>AVLTree</span></a></td>
|
|
215
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
216
|
+
</tr>
|
|
217
|
+
<tr>
|
|
218
|
+
<td>Tree Multiset</td>
|
|
219
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
220
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
221
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/TreeMultiset.html"><span>TreeMultiset</span></a></td>
|
|
222
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
223
|
+
</tr>
|
|
224
|
+
<tr>
|
|
225
|
+
<td>Segment Tree</td>
|
|
226
|
+
<td></td>
|
|
227
|
+
<td></td>
|
|
228
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTree.html"><span>SegmentTree</span></a></td>
|
|
229
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
230
|
+
</tr>
|
|
231
|
+
<tr>
|
|
232
|
+
<td>Binary Indexed Tree</td>
|
|
233
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
234
|
+
<td></td>
|
|
235
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryIndexedTree.html"><span>BinaryIndexedTree</span></a></td>
|
|
236
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
237
|
+
</tr>
|
|
238
|
+
<tr>
|
|
239
|
+
<td>Graph</td>
|
|
240
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
241
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
242
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractGraph.html"><span>AbstractGraph</span></a></td>
|
|
243
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
244
|
+
</tr>
|
|
245
|
+
<tr>
|
|
246
|
+
<td>Directed Graph</td>
|
|
247
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
248
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
249
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedGraph.html"><span>DirectedGraph</span></a></td>
|
|
250
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
251
|
+
</tr>
|
|
252
|
+
<tr>
|
|
253
|
+
<td>Undirected Graph</td>
|
|
254
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
255
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
256
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedGraph.html"><span>UndirectedGraph</span></a></td>
|
|
257
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
258
|
+
</tr>
|
|
259
|
+
<tr>
|
|
260
|
+
<td>Linked List</td>
|
|
261
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
262
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
263
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>SinglyLinkedList</span></a></td>
|
|
264
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
265
|
+
</tr>
|
|
266
|
+
<tr>
|
|
267
|
+
<td>Singly Linked List</td>
|
|
268
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
269
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
270
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>SinglyLinkedList</span></a></td>
|
|
271
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
272
|
+
</tr>
|
|
273
|
+
<tr>
|
|
274
|
+
<td>Doubly Linked List</td>
|
|
275
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
276
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
277
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedList.html"><span>DoublyLinkedList</span></a></td>
|
|
278
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
279
|
+
</tr>
|
|
280
|
+
<tr>
|
|
281
|
+
<td>Queue</td>
|
|
282
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
283
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
284
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Queue.html"><span>Queue</span></a></td>
|
|
285
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
286
|
+
</tr>
|
|
287
|
+
<tr>
|
|
288
|
+
<td>Object Deque</td>
|
|
289
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
290
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
291
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/ObjectDeque.html"><span>ObjectDeque</span></a></td>
|
|
292
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
293
|
+
</tr>
|
|
294
|
+
<tr>
|
|
295
|
+
<td>Array Deque</td>
|
|
296
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
297
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
298
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/ArrayDeque.html"><span>ArrayDeque</span></a></td>
|
|
299
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
300
|
+
</tr>
|
|
301
|
+
<tr>
|
|
302
|
+
<td>Stack</td>
|
|
303
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
304
|
+
<td></td>
|
|
305
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Stack.html"><span>Stack</span></a></td>
|
|
306
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
307
|
+
</tr>
|
|
308
|
+
|
|
309
|
+
[//]: # (<tr>)
|
|
310
|
+
|
|
311
|
+
[//]: # (<td>Hash</td>)
|
|
312
|
+
|
|
313
|
+
[//]: # (<td></td>)
|
|
314
|
+
|
|
315
|
+
[//]: # (<td></td>)
|
|
28
316
|
|
|
317
|
+
[//]: # (<td><a href="https://data-structure-typed-docs.vercel.app/classes/HashTable.html"><span>HashTable</span></a></td>)
|
|
318
|
+
|
|
319
|
+
[//]: # (<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>)
|
|
320
|
+
|
|
321
|
+
[//]: # (</tr>)
|
|
322
|
+
<tr>
|
|
323
|
+
<td>Coordinate Set</td>
|
|
324
|
+
<td></td>
|
|
325
|
+
<td></td>
|
|
326
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/CoordinateSet.html"><span>CoordinateSet</span></a></td>
|
|
327
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
328
|
+
</tr>
|
|
329
|
+
<tr>
|
|
330
|
+
<td>Coordinate Map</td>
|
|
331
|
+
<td></td>
|
|
332
|
+
<td></td>
|
|
333
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/CoordinateMap.html"><span>CoordinateMap</span></a></td>
|
|
334
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
335
|
+
</tr>
|
|
336
|
+
<tr>
|
|
337
|
+
<td>Heap</td>
|
|
338
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
339
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
340
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Heap.html"><span>Heap</span></a></td>
|
|
341
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
342
|
+
</tr>
|
|
343
|
+
<tr>
|
|
344
|
+
<td>Priority Queue</td>
|
|
345
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
346
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
347
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/PriorityQueue.html"><span>PriorityQueue</span></a></td>
|
|
348
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
349
|
+
</tr>
|
|
350
|
+
<tr>
|
|
351
|
+
<td>Max Priority Queue</td>
|
|
352
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
353
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
354
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/MaxPriorityQueue.html"><span>MaxPriorityQueue</span></a></td>
|
|
355
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
356
|
+
</tr>
|
|
357
|
+
<tr>
|
|
358
|
+
<td>Min Priority Queue</td>
|
|
359
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
360
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
361
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/MinPriorityQueue.html"><span>MinPriorityQueue</span></a></td>
|
|
362
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
363
|
+
</tr>
|
|
364
|
+
<tr>
|
|
365
|
+
<td>Trie</td>
|
|
366
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
367
|
+
<td></td>
|
|
368
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Trie.html"><span>Trie</span></a></td>
|
|
369
|
+
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
370
|
+
</tr>
|
|
371
|
+
</tbody>
|
|
372
|
+
</table>
|
|
373
|
+
|
|
374
|
+
## API docs
|
|
375
|
+
<ul>
|
|
376
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTree.html" rel="nofollow"><span>AVLTree</span></a></li>
|
|
377
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTreeNode.html" rel="nofollow"><span>AVLTreeNode</span></a></li>
|
|
378
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractEdge.html" rel="nofollow"><span>AbstractEdge</span></a></li>
|
|
379
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractGraph.html" rel="nofollow"><span>AbstractGraph</span></a></li>
|
|
380
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractVertex.html" rel="nofollow"><span>AbstractVertex</span></a></li>
|
|
381
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/ArrayDeque.html" rel="nofollow"><span>ArrayDeque</span></a></li>
|
|
382
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BST.html" rel="nofollow"><span>BST</span></a></li>
|
|
383
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BSTNode.html" rel="nofollow"><span>BSTNode</span></a></li>
|
|
384
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryIndexedTree.html" rel="nofollow"><span>BinaryIndexedTree</span></a></li>
|
|
385
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTree.html" rel="nofollow"><span>BinaryTree</span></a></li>
|
|
386
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTreeNode.html" rel="nofollow"><span>BinaryTreeNode</span></a></li>
|
|
387
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Character.html" rel="nofollow"><span>Character</span></a></li>
|
|
388
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/CoordinateMap.html" rel="nofollow"><span>CoordinateMap</span></a></li>
|
|
389
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/CoordinateSet.html" rel="nofollow"><span>CoordinateSet</span></a></li>
|
|
390
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Deque.html" rel="nofollow"><span>Deque</span></a></li>
|
|
391
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedEdge.html" rel="nofollow"><span>DirectedEdge</span></a></li>
|
|
392
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedGraph.html" rel="nofollow"><span>DirectedGraph</span></a></li>
|
|
393
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedVertex.html" rel="nofollow"><span>DirectedVertex</span></a></li>
|
|
394
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedList.html" rel="nofollow"><span>DoublyLinkedList</span></a></li>
|
|
395
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedListNode.html" rel="nofollow"><span>DoublyLinkedListNode</span></a></li>
|
|
396
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Heap.html" rel="nofollow"><span>Heap</span></a></li>
|
|
397
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Matrix2D.html" rel="nofollow"><span>Matrix2D</span></a></li>
|
|
398
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MatrixNTI2D.html" rel="nofollow"><span>MatrixNTI2D</span></a></li>
|
|
399
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MaxHeap.html" rel="nofollow"><span>MaxHeap</span></a></li>
|
|
400
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MaxPriorityQueue.html" rel="nofollow"><span>MaxPriorityQueue</span></a></li>
|
|
401
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MinHeap.html" rel="nofollow"><span>MinHeap</span></a></li>
|
|
402
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MinPriorityQueue.html" rel="nofollow"><span>MinPriorityQueue</span></a></li>
|
|
403
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Navigator.html" rel="nofollow"><span>Navigator</span></a></li>
|
|
404
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/ObjectDeque.html" rel="nofollow"><span>ObjectDeque</span></a></li>
|
|
405
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/PriorityQueue.html" rel="nofollow"><span>PriorityQueue</span></a></li>
|
|
406
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Queue.html" rel="nofollow"><span>Queue</span></a></li>
|
|
407
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTree.html" rel="nofollow"><span>SegmentTree</span></a></li>
|
|
408
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTreeNode.html" rel="nofollow"><span>SegmentTreeNode</span></a></li>
|
|
409
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html" rel="nofollow"><span>SinglyLinkedList</span></a></li>
|
|
410
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedListNode.html" rel="nofollow"><span>SinglyLinkedListNode</span></a></li>
|
|
411
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Stack.html" rel="nofollow"><span>Stack</span></a></li>
|
|
412
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/TreeMultiSet.html" rel="nofollow"><span>TreeMultiSet</span></a></li>
|
|
413
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Trie.html" rel="nofollow"><span>Trie</span></a></li>
|
|
414
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/TrieNode.html" rel="nofollow"><span>TrieNode</span></a></li>
|
|
415
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedEdge.html" rel="nofollow"><span>UndirectedEdge</span></a></li>
|
|
416
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedGraph.html" rel="nofollow"><span>UndirectedGraph</span></a></li>
|
|
417
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedVertex.html" rel="nofollow"><span>UndirectedVertex</span></a></li>
|
|
418
|
+
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Vector2D.html" rel="nofollow"><span>Vector2D</span></a></li>
|
|
419
|
+
</ul>
|
|
420
|
+
|
|
421
|
+
# Why
|
|
422
|
+
|
|
423
|
+
## Complexities
|
|
424
|
+
|
|
425
|
+
### performance of Big O
|
|
426
|
+
<table>
|
|
427
|
+
<thead>
|
|
428
|
+
<tr>
|
|
429
|
+
<th>Big O Notation</th>
|
|
430
|
+
<th>Type</th>
|
|
431
|
+
<th>Computations for 10 elements</th>
|
|
432
|
+
<th>Computations for 100 elements</th>
|
|
433
|
+
<th>Computations for 1000 elements</th>
|
|
434
|
+
</tr>
|
|
435
|
+
</thead>
|
|
29
436
|
<tbody>
|
|
30
437
|
<tr>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
<td></td>
|
|
80
|
-
<td>All the features inherited from Graph, getEdge, addEdge, removeEdgeBetween, removeEdge, removeAllEdges, incomingEdgesOf, outgoingEdgesOf, degreeOf, inDegreeOf, outDegreeOf, edgesOf, getEdgeSrc, getEdgeDest, getDestinations, edgeSet, getNeighbors, getEndsOfEdge</td>
|
|
81
|
-
<td>All the features inherited from Graph, topologicalSort</td>
|
|
82
|
-
</tr>
|
|
83
|
-
<tr>
|
|
84
|
-
<td>Undirected Graph</td>
|
|
85
|
-
<td></td>
|
|
86
|
-
<td>All the features inherited from Graph, getEdge, addEdge, removeEdgeBetween, removeEdge, degreeOf, edgesOf, edgeSet, getEdgesOf, getNeighbors, getEndsOfEdge</td>
|
|
87
|
-
<td>All the features inherited from Graph</td>
|
|
88
|
-
</tr>
|
|
89
|
-
<tr>
|
|
90
|
-
<td>Singly Linked List</td>
|
|
91
|
-
<td></td>
|
|
92
|
-
<td>length, head, tail, size, get, getNode, findNodeIndex, findNode, find, findIndex, append, push, prepend, insertAt, removeNode, removeAt, insertBefore, sort, insertAfter, shift, pop, merge, clear, slice, reverse, forEach, map, filter, reduce, toArray, toString</td>
|
|
93
|
-
<td></td>
|
|
94
|
-
|
|
95
|
-
</tr>
|
|
96
|
-
<tr>
|
|
97
|
-
<td>Hash</td>
|
|
98
|
-
<td>CoordinateSet, CoordinateMap</td>
|
|
99
|
-
<td></td>
|
|
100
|
-
<td></td>
|
|
101
|
-
</tr>
|
|
102
|
-
<tr>
|
|
103
|
-
<td>CoordinateSet</td>
|
|
104
|
-
<td></td>
|
|
105
|
-
<td>has, set, get, delete</td>
|
|
106
|
-
<td></td>
|
|
107
|
-
</tr>
|
|
108
|
-
<tr>
|
|
109
|
-
<td>CoordinateMap</td>
|
|
110
|
-
<td></td>
|
|
111
|
-
<td>has, add, delete</td>
|
|
112
|
-
<td></td>
|
|
113
|
-
</tr>
|
|
114
|
-
<tr>
|
|
115
|
-
<td>Heap</td>
|
|
116
|
-
<td></td>
|
|
117
|
-
<td></td>
|
|
118
|
-
</tr>
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
<tr>
|
|
122
|
-
<td>Doubly Linked List</td>
|
|
123
|
-
<td></td>
|
|
124
|
-
<td>size, offerFirst, offerLast, peekFirst, peekLast, pollFirst, pollLast, get, isEmpty, insert, remove, </td>
|
|
125
|
-
<td></td>
|
|
126
|
-
</tr>
|
|
127
|
-
|
|
128
|
-
[//]: # ( <tr>)
|
|
129
|
-
|
|
130
|
-
[//]: # ( <td>Matrix</td>)
|
|
131
|
-
|
|
132
|
-
[//]: # ( <td></td>)
|
|
133
|
-
|
|
134
|
-
[//]: # ( <td></td>)
|
|
135
|
-
|
|
136
|
-
[//]: # ( <td></td>)
|
|
137
|
-
|
|
138
|
-
[//]: # ( </tr>)
|
|
139
|
-
|
|
140
|
-
<tr>
|
|
141
|
-
<td>Priority Queue</td>
|
|
142
|
-
<td>Max Priority Queue, Min Priority Queue</td>
|
|
143
|
-
<td>offer, peek, poll, leaf, isEmpty, clear, toArray, clone</td>
|
|
144
|
-
<td>isValid, sort, DFS</td>
|
|
145
|
-
</tr>
|
|
146
|
-
<tr>
|
|
147
|
-
<td>Max Priority Queue</td>
|
|
148
|
-
<td></td>
|
|
149
|
-
<td>All the features inherited from Priority Queue</td>
|
|
150
|
-
<td>All the features inherited from Priority Queue</td>
|
|
151
|
-
</tr>
|
|
152
|
-
<tr>
|
|
153
|
-
<td>Min Priority Queue</td>
|
|
154
|
-
<td></td>
|
|
155
|
-
<td>All the features inherited from Priority Queue</td>
|
|
156
|
-
<td>All the features inherited from Priority Queue</td>
|
|
157
|
-
</tr>
|
|
158
|
-
<tr>
|
|
159
|
-
<td>Queue</td>
|
|
160
|
-
<td>Queue, Dequeue</td>
|
|
161
|
-
<td>offer, poll, peek, peekLast, size, isEmpty, toArray, clear, clone, Queue.fromArray</td>
|
|
162
|
-
<td></td>
|
|
163
|
-
</tr>
|
|
164
|
-
<tr>
|
|
165
|
-
<td>ObjectDeque</td>
|
|
166
|
-
<td></td>
|
|
167
|
-
<td>size, offerFirst, offerLast, pollFirst, peekFirst, pollLast, peekLast, get, isEmpty</td>
|
|
168
|
-
<td></td>
|
|
169
|
-
</tr>
|
|
170
|
-
<tr>
|
|
171
|
-
<td>ArrayDeque</td>
|
|
172
|
-
<td></td>
|
|
173
|
-
<td>offerLast, pollLast, pollFirst, offerFirst, peekFirst, peekLast, get, set, insert, remove, isEmpty</td>
|
|
174
|
-
<td></td>
|
|
175
|
-
</tr>
|
|
176
|
-
<tr>
|
|
177
|
-
<td>Stack</td>
|
|
178
|
-
<td></td>
|
|
179
|
-
<td>isEmpty, size, peek, push, pop, toArray, clear, clone, Stack.fromArray</td>
|
|
180
|
-
<td></td>
|
|
181
|
-
</tr>
|
|
182
|
-
<tr>
|
|
183
|
-
<td>Trie</td>
|
|
184
|
-
<td></td>
|
|
185
|
-
<td>put, has, remove, isAbsPrefix, isPrefix, getAll</td>
|
|
186
|
-
<td></td>
|
|
187
|
-
</tr>
|
|
438
|
+
<td><strong>O(1)</strong></td>
|
|
439
|
+
<td>Constant</td>
|
|
440
|
+
<td>1</td>
|
|
441
|
+
<td>1</td>
|
|
442
|
+
<td>1</td>
|
|
443
|
+
</tr>
|
|
444
|
+
<tr>
|
|
445
|
+
<td><strong>O(log N)</strong></td>
|
|
446
|
+
<td>Logarithmic</td>
|
|
447
|
+
<td>3</td>
|
|
448
|
+
<td>6</td>
|
|
449
|
+
<td>9</td>
|
|
450
|
+
</tr>
|
|
451
|
+
<tr>
|
|
452
|
+
<td><strong>O(N)</strong></td>
|
|
453
|
+
<td>Linear</td>
|
|
454
|
+
<td>10</td>
|
|
455
|
+
<td>100</td>
|
|
456
|
+
<td>1000</td>
|
|
457
|
+
</tr>
|
|
458
|
+
<tr>
|
|
459
|
+
<td><strong>O(N log N)</strong></td>
|
|
460
|
+
<td>n log(n)</td>
|
|
461
|
+
<td>30</td>
|
|
462
|
+
<td>600</td>
|
|
463
|
+
<td>9000</td>
|
|
464
|
+
</tr>
|
|
465
|
+
<tr>
|
|
466
|
+
<td><strong>O(N^2)</strong></td>
|
|
467
|
+
<td>Quadratic</td>
|
|
468
|
+
<td>100</td>
|
|
469
|
+
<td>10000</td>
|
|
470
|
+
<td>1000000</td>
|
|
471
|
+
</tr>
|
|
472
|
+
<tr>
|
|
473
|
+
<td><strong>O(2^N)</strong></td>
|
|
474
|
+
<td>Exponential</td>
|
|
475
|
+
<td>1024</td>
|
|
476
|
+
<td>1.26e+29</td>
|
|
477
|
+
<td>1.07e+301</td>
|
|
478
|
+
</tr>
|
|
479
|
+
<tr>
|
|
480
|
+
<td><strong>O(N!)</strong></td>
|
|
481
|
+
<td>Factorial</td>
|
|
482
|
+
<td>3628800</td>
|
|
483
|
+
<td>9.3e+157</td>
|
|
484
|
+
<td>4.02e+2567</td>
|
|
485
|
+
</tr>
|
|
188
486
|
</tbody>
|
|
487
|
+
</table>
|
|
189
488
|
|
|
489
|
+
### Data Structure Complexity
|
|
490
|
+
<table>
|
|
491
|
+
<thead>
|
|
492
|
+
<tr>
|
|
493
|
+
<th>Data Structure</th>
|
|
494
|
+
<th>Access</th>
|
|
495
|
+
<th>Search</th>
|
|
496
|
+
<th>Insertion</th>
|
|
497
|
+
<th>Deletion</th>
|
|
498
|
+
<th>Comments</th>
|
|
499
|
+
</tr>
|
|
500
|
+
</thead>
|
|
501
|
+
<tbody>
|
|
502
|
+
<tr>
|
|
503
|
+
<td><strong>Array</strong></td>
|
|
504
|
+
<td>1</td>
|
|
505
|
+
<td>n</td>
|
|
506
|
+
<td>n</td>
|
|
507
|
+
<td>n</td>
|
|
508
|
+
<td></td>
|
|
509
|
+
</tr>
|
|
510
|
+
<tr>
|
|
511
|
+
<td><strong>Stack</strong></td>
|
|
512
|
+
<td>n</td>
|
|
513
|
+
<td>n</td>
|
|
514
|
+
<td>1</td>
|
|
515
|
+
<td>1</td>
|
|
516
|
+
<td></td>
|
|
517
|
+
</tr>
|
|
518
|
+
<tr>
|
|
519
|
+
<td><strong>Queue</strong></td>
|
|
520
|
+
<td>n</td>
|
|
521
|
+
<td>n</td>
|
|
522
|
+
<td>1</td>
|
|
523
|
+
<td>1</td>
|
|
524
|
+
<td></td>
|
|
525
|
+
</tr>
|
|
526
|
+
<tr>
|
|
527
|
+
<td><strong>Linked List</strong></td>
|
|
528
|
+
<td>n</td>
|
|
529
|
+
<td>n</td>
|
|
530
|
+
<td>1</td>
|
|
531
|
+
<td>n</td>
|
|
532
|
+
<td></td>
|
|
533
|
+
</tr>
|
|
534
|
+
<tr>
|
|
535
|
+
<td><strong>Hash Table</strong></td>
|
|
536
|
+
<td>-</td>
|
|
537
|
+
<td>n</td>
|
|
538
|
+
<td>n</td>
|
|
539
|
+
<td>n</td>
|
|
540
|
+
<td>In case of perfect hash function costs would be O(1)</td>
|
|
541
|
+
</tr>
|
|
542
|
+
<tr>
|
|
543
|
+
<td><strong>Binary Search Tree</strong></td>
|
|
544
|
+
<td>n</td>
|
|
545
|
+
<td>n</td>
|
|
546
|
+
<td>n</td>
|
|
547
|
+
<td>n</td>
|
|
548
|
+
<td>In case of balanced tree costs would be O(log(n))</td>
|
|
549
|
+
</tr>
|
|
550
|
+
<tr>
|
|
551
|
+
<td><strong>B-Tree</strong></td>
|
|
552
|
+
<td>log(n)</td>
|
|
553
|
+
<td>log(n)</td>
|
|
554
|
+
<td>log(n)</td>
|
|
555
|
+
<td>log(n)</td>
|
|
556
|
+
<td></td>
|
|
557
|
+
</tr>
|
|
558
|
+
<tr>
|
|
559
|
+
<td><strong>Red-Black Tree</strong></td>
|
|
560
|
+
<td>log(n)</td>
|
|
561
|
+
<td>log(n)</td>
|
|
562
|
+
<td>log(n)</td>
|
|
563
|
+
<td>log(n)</td>
|
|
564
|
+
<td></td>
|
|
565
|
+
</tr>
|
|
566
|
+
<tr>
|
|
567
|
+
<td><strong>AVL Tree</strong></td>
|
|
568
|
+
<td>log(n)</td>
|
|
569
|
+
<td>log(n)</td>
|
|
570
|
+
<td>log(n)</td>
|
|
571
|
+
<td>log(n)</td>
|
|
572
|
+
<td></td>
|
|
573
|
+
</tr>
|
|
574
|
+
<tr>
|
|
575
|
+
<td><strong>Bloom Filter</strong></td>
|
|
576
|
+
<td>-</td>
|
|
577
|
+
<td>1</td>
|
|
578
|
+
<td>1</td>
|
|
579
|
+
<td>-</td>
|
|
580
|
+
<td>False positives are possible while searching</td>
|
|
581
|
+
</tr>
|
|
582
|
+
</tbody>
|
|
190
583
|
</table>
|
|
191
584
|
|
|
585
|
+
### Sorting Complexity
|
|
586
|
+
<table>
|
|
587
|
+
<thead>
|
|
588
|
+
<tr>
|
|
589
|
+
<th>Name</th>
|
|
590
|
+
<th>Best</th>
|
|
591
|
+
<th>Average</th>
|
|
592
|
+
<th>Worst</th>
|
|
593
|
+
<th>Memory</th>
|
|
594
|
+
<th>Stable</th>
|
|
595
|
+
<th>Comments</th>
|
|
596
|
+
</tr>
|
|
597
|
+
</thead>
|
|
598
|
+
<tbody>
|
|
599
|
+
<tr>
|
|
600
|
+
<td><strong>Bubble sort</strong></td>
|
|
601
|
+
<td>n</td>
|
|
602
|
+
<td>n<sup>2</sup></td>
|
|
603
|
+
<td>n<sup>2</sup></td>
|
|
604
|
+
<td>1</td>
|
|
605
|
+
<td>Yes</td>
|
|
606
|
+
<td></td>
|
|
607
|
+
</tr>
|
|
608
|
+
<tr>
|
|
609
|
+
<td><strong>Insertion sort</strong></td>
|
|
610
|
+
<td>n</td>
|
|
611
|
+
<td>n<sup>2</sup></td>
|
|
612
|
+
<td>n<sup>2</sup></td>
|
|
613
|
+
<td>1</td>
|
|
614
|
+
<td>Yes</td>
|
|
615
|
+
<td></td>
|
|
616
|
+
</tr>
|
|
617
|
+
<tr>
|
|
618
|
+
<td><strong>Selection sort</strong></td>
|
|
619
|
+
<td>n<sup>2</sup></td>
|
|
620
|
+
<td>n<sup>2</sup></td>
|
|
621
|
+
<td>n<sup>2</sup></td>
|
|
622
|
+
<td>1</td>
|
|
623
|
+
<td>No</td>
|
|
624
|
+
<td></td>
|
|
625
|
+
</tr>
|
|
626
|
+
<tr>
|
|
627
|
+
<td><strong>Heap sort</strong></td>
|
|
628
|
+
<td>n log(n)</td>
|
|
629
|
+
<td>n log(n)</td>
|
|
630
|
+
<td>n log(n)</td>
|
|
631
|
+
<td>1</td>
|
|
632
|
+
<td>No</td>
|
|
633
|
+
<td></td>
|
|
634
|
+
</tr>
|
|
635
|
+
<tr>
|
|
636
|
+
<td><strong>Merge sort</strong></td>
|
|
637
|
+
<td>n log(n)</td>
|
|
638
|
+
<td>n log(n)</td>
|
|
639
|
+
<td>n log(n)</td>
|
|
640
|
+
<td>n</td>
|
|
641
|
+
<td>Yes</td>
|
|
642
|
+
<td></td>
|
|
643
|
+
</tr>
|
|
644
|
+
<tr>
|
|
645
|
+
<td><strong>Quick sort</strong></td>
|
|
646
|
+
<td>n log(n)</td>
|
|
647
|
+
<td>n log(n)</td>
|
|
648
|
+
<td>n<sup>2</sup></td>
|
|
649
|
+
<td>log(n)</td>
|
|
650
|
+
<td>No</td>
|
|
651
|
+
<td>Quicksort is usually done in-place with O(log(n)) stack space</td>
|
|
652
|
+
</tr>
|
|
653
|
+
<tr>
|
|
654
|
+
<td><strong>Shell sort</strong></td>
|
|
655
|
+
<td>n log(n)</td>
|
|
656
|
+
<td>depends on gap sequence</td>
|
|
657
|
+
<td>n (log(n))<sup>2</sup></td>
|
|
658
|
+
<td>1</td>
|
|
659
|
+
<td>No</td>
|
|
660
|
+
<td></td>
|
|
661
|
+
</tr>
|
|
662
|
+
<tr>
|
|
663
|
+
<td><strong>Counting sort</strong></td>
|
|
664
|
+
<td>n + r</td>
|
|
665
|
+
<td>n + r</td>
|
|
666
|
+
<td>n + r</td>
|
|
667
|
+
<td>n + r</td>
|
|
668
|
+
<td>Yes</td>
|
|
669
|
+
<td>r - biggest number in array</td>
|
|
670
|
+
</tr>
|
|
671
|
+
<tr>
|
|
672
|
+
<td><strong>Radix sort</strong></td>
|
|
673
|
+
<td>n * k</td>
|
|
674
|
+
<td>n * k</td>
|
|
675
|
+
<td>n * k</td>
|
|
676
|
+
<td>n + k</td>
|
|
677
|
+
<td>Yes</td>
|
|
678
|
+
<td>k - length of longest key</td>
|
|
679
|
+
</tr>
|
|
680
|
+
</tbody>
|
|
681
|
+
</table>
|
|
192
682
|
|
|
683
|
+
## Code design
|
|
684
|
+
By strictly adhering to object-oriented design (BinaryTree -> BST -> AVLTree -> TreeMultiset), you can seamlessly inherit the existing data structures to implement the customized ones you need. Object-oriented design stands as the optimal approach to data structure design.
|
|
193
685
|
|
|
686
|
+
[//]: # ()
|
|
194
687
|
|
|
195
|
-

|
|
196
689
|
|
|
197
|
-

|