data-structure-typed 1.32.1 → 1.32.9
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/.idea/data-structure-typed.iml +19 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/CHANGELOG.md +1 -1
- package/README.md +415 -255
- package/coverage/coverage-final.json +4 -4
- package/docs/index.html +268 -21
- package/package.json +48 -16
- package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +46 -1
- package/.auto-changelog-template.hbs +0 -36
- package/coverage/clover.xml +0 -3393
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -386
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/data-structures/binary-tree/aa-tree.ts.html +0 -88
- package/coverage/lcov-report/src/data-structures/binary-tree/abstract-binary-tree.ts.html +0 -4978
- package/coverage/lcov-report/src/data-structures/binary-tree/avl-tree.ts.html +0 -1015
- package/coverage/lcov-report/src/data-structures/binary-tree/b-tree.ts.html +0 -88
- package/coverage/lcov-report/src/data-structures/binary-tree/binary-indexed-tree.ts.html +0 -313
- package/coverage/lcov-report/src/data-structures/binary-tree/binary-tree.ts.html +0 -226
- package/coverage/lcov-report/src/data-structures/binary-tree/bst.ts.html +0 -1696
- package/coverage/lcov-report/src/data-structures/binary-tree/index.html +0 -296
- package/coverage/lcov-report/src/data-structures/binary-tree/index.ts.html +0 -121
- package/coverage/lcov-report/src/data-structures/binary-tree/rb-tree.ts.html +0 -388
- package/coverage/lcov-report/src/data-structures/binary-tree/segment-tree.ts.html +0 -811
- package/coverage/lcov-report/src/data-structures/binary-tree/splay-tree.ts.html +0 -88
- package/coverage/lcov-report/src/data-structures/binary-tree/tree-multiset.ts.html +0 -2185
- package/coverage/lcov-report/src/data-structures/binary-tree/two-three-tree.ts.html +0 -88
- package/coverage/lcov-report/src/data-structures/graph/abstract-graph.ts.html +0 -3205
- package/coverage/lcov-report/src/data-structures/graph/directed-graph.ts.html +0 -1495
- package/coverage/lcov-report/src/data-structures/graph/index.html +0 -176
- package/coverage/lcov-report/src/data-structures/graph/index.ts.html +0 -97
- package/coverage/lcov-report/src/data-structures/graph/map-graph.ts.html +0 -472
- package/coverage/lcov-report/src/data-structures/graph/undirected-graph.ts.html +0 -907
- package/coverage/lcov-report/src/data-structures/hash/coordinate-map.ts.html +0 -286
- package/coverage/lcov-report/src/data-structures/hash/coordinate-set.ts.html +0 -253
- package/coverage/lcov-report/src/data-structures/hash/hash-table.ts.html +0 -88
- package/coverage/lcov-report/src/data-structures/hash/index.html +0 -206
- package/coverage/lcov-report/src/data-structures/hash/index.ts.html +0 -103
- package/coverage/lcov-report/src/data-structures/hash/pair.ts.html +0 -88
- package/coverage/lcov-report/src/data-structures/hash/tree-map.ts.html +0 -88
- package/coverage/lcov-report/src/data-structures/hash/tree-set.ts.html +0 -88
- package/coverage/lcov-report/src/data-structures/heap/heap.ts.html +0 -721
- package/coverage/lcov-report/src/data-structures/heap/index.html +0 -161
- package/coverage/lcov-report/src/data-structures/heap/index.ts.html +0 -94
- package/coverage/lcov-report/src/data-structures/heap/max-heap.ts.html +0 -178
- package/coverage/lcov-report/src/data-structures/heap/min-heap.ts.html +0 -181
- package/coverage/lcov-report/src/data-structures/index.html +0 -116
- package/coverage/lcov-report/src/data-structures/index.ts.html +0 -118
- package/coverage/lcov-report/src/data-structures/linked-list/doubly-linked-list.ts.html +0 -1804
- package/coverage/lcov-report/src/data-structures/linked-list/index.html +0 -161
- package/coverage/lcov-report/src/data-structures/linked-list/index.ts.html +0 -94
- package/coverage/lcov-report/src/data-structures/linked-list/singly-linked-list.ts.html +0 -1588
- package/coverage/lcov-report/src/data-structures/linked-list/skip-linked-list.ts.html +0 -88
- package/coverage/lcov-report/src/data-structures/matrix/index.html +0 -176
- package/coverage/lcov-report/src/data-structures/matrix/index.ts.html +0 -97
- package/coverage/lcov-report/src/data-structures/matrix/matrix.ts.html +0 -166
- package/coverage/lcov-report/src/data-structures/matrix/matrix2d.ts.html +0 -721
- package/coverage/lcov-report/src/data-structures/matrix/navigator.ts.html +0 -448
- package/coverage/lcov-report/src/data-structures/matrix/vector2d.ts.html +0 -1033
- package/coverage/lcov-report/src/data-structures/priority-queue/index.html +0 -161
- package/coverage/lcov-report/src/data-structures/priority-queue/index.ts.html +0 -94
- package/coverage/lcov-report/src/data-structures/priority-queue/max-priority-queue.ts.html +0 -253
- package/coverage/lcov-report/src/data-structures/priority-queue/min-priority-queue.ts.html +0 -256
- package/coverage/lcov-report/src/data-structures/priority-queue/priority-queue.ts.html +0 -1162
- package/coverage/lcov-report/src/data-structures/queue/deque.ts.html +0 -976
- package/coverage/lcov-report/src/data-structures/queue/index.html +0 -146
- package/coverage/lcov-report/src/data-structures/queue/index.ts.html +0 -91
- package/coverage/lcov-report/src/data-structures/queue/queue.ts.html +0 -658
- package/coverage/lcov-report/src/data-structures/stack/index.html +0 -131
- package/coverage/lcov-report/src/data-structures/stack/index.ts.html +0 -88
- package/coverage/lcov-report/src/data-structures/stack/stack.ts.html +0 -379
- package/coverage/lcov-report/src/data-structures/tree/index.html +0 -131
- package/coverage/lcov-report/src/data-structures/tree/index.ts.html +0 -88
- package/coverage/lcov-report/src/data-structures/tree/tree.ts.html +0 -292
- package/coverage/lcov-report/src/data-structures/trie/index.html +0 -131
- package/coverage/lcov-report/src/data-structures/trie/index.ts.html +0 -88
- package/coverage/lcov-report/src/data-structures/trie/trie.ts.html +0 -760
- package/coverage/lcov-report/src/index.html +0 -116
- package/coverage/lcov-report/src/index.ts.html +0 -97
- package/coverage/lcov-report/src/interfaces/index.html +0 -116
- package/coverage/lcov-report/src/interfaces/index.ts.html +0 -130
- package/coverage/lcov-report/src/types/data-structures/abstract-binary-tree.ts.html +0 -235
- package/coverage/lcov-report/src/types/data-structures/bst.ts.html +0 -124
- package/coverage/lcov-report/src/types/data-structures/directed-graph.ts.html +0 -109
- package/coverage/lcov-report/src/types/data-structures/index.html +0 -176
- package/coverage/lcov-report/src/types/data-structures/index.ts.html +0 -130
- package/coverage/lcov-report/src/types/data-structures/rb-tree.ts.html +0 -106
- package/coverage/lcov-report/src/types/index.html +0 -116
- package/coverage/lcov-report/src/types/index.ts.html +0 -94
- package/coverage/lcov-report/src/types/utils/index.html +0 -116
- package/coverage/lcov-report/src/types/utils/index.ts.html +0 -91
- package/coverage/lcov-report/src/utils/index.html +0 -131
- package/coverage/lcov-report/src/utils/index.ts.html +0 -88
- package/coverage/lcov-report/src/utils/utils.ts.html +0 -322
- package/coverage/lcov-report/test/utils/index.html +0 -146
- package/coverage/lcov-report/test/utils/index.ts.html +0 -91
- package/coverage/lcov-report/test/utils/magnitude.ts.html +0 -148
- package/coverage/lcov-report/test/utils/number.ts.html +0 -94
- package/coverage/lcov.info +0 -6676
- package/docs/assets/highlight.css +0 -127
- package/docs/assets/main.js +0 -58
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1367
- package/docs/classes/AVLTree.html +0 -2182
- package/docs/classes/AVLTreeNode.html +0 -399
- package/docs/classes/AaTree.html +0 -202
- package/docs/classes/AbstractBinaryTree.html +0 -1836
- package/docs/classes/AbstractBinaryTreeNode.html +0 -441
- package/docs/classes/AbstractEdge.html +0 -345
- package/docs/classes/AbstractGraph.html +0 -1105
- package/docs/classes/AbstractVertex.html +0 -299
- package/docs/classes/ArrayDeque.html +0 -469
- package/docs/classes/BST.html +0 -2026
- package/docs/classes/BSTNode.html +0 -400
- package/docs/classes/BTree.html +0 -202
- package/docs/classes/BinaryIndexedTree.html +0 -371
- package/docs/classes/BinaryTree.html +0 -1867
- package/docs/classes/BinaryTreeNode.html +0 -399
- package/docs/classes/Character.html +0 -250
- package/docs/classes/CoordinateMap.html +0 -513
- package/docs/classes/CoordinateSet.html +0 -474
- package/docs/classes/Deque.html +0 -1005
- package/docs/classes/DirectedEdge.html +0 -404
- package/docs/classes/DirectedGraph.html +0 -1530
- package/docs/classes/DirectedVertex.html +0 -286
- package/docs/classes/DoublyLinkedList.html +0 -998
- package/docs/classes/DoublyLinkedListNode.html +0 -327
- package/docs/classes/HashTable.html +0 -202
- package/docs/classes/Heap.html +0 -647
- package/docs/classes/HeapItem.html +0 -296
- package/docs/classes/LinkedListQueue.html +0 -884
- package/docs/classes/MapEdge.html +0 -391
- package/docs/classes/MapGraph.html +0 -1583
- package/docs/classes/MapVertex.html +0 -356
- package/docs/classes/Matrix2D.html +0 -532
- package/docs/classes/MatrixNTI2D.html +0 -270
- package/docs/classes/MaxHeap.html +0 -671
- package/docs/classes/MaxPriorityQueue.html +0 -866
- package/docs/classes/MinHeap.html +0 -672
- package/docs/classes/MinPriorityQueue.html +0 -868
- package/docs/classes/Navigator.html +0 -343
- package/docs/classes/ObjectDeque.html +0 -527
- package/docs/classes/Pair.html +0 -202
- package/docs/classes/PriorityQueue.html +0 -790
- package/docs/classes/Queue.html +0 -521
- package/docs/classes/RBTree.html +0 -2024
- package/docs/classes/RBTreeNode.html +0 -431
- package/docs/classes/SegmentTree.html +0 -464
- package/docs/classes/SegmentTreeNode.html +0 -387
- package/docs/classes/SinglyLinkedList.html +0 -830
- package/docs/classes/SinglyLinkedListNode.html +0 -300
- package/docs/classes/SkipLinkedList.html +0 -202
- package/docs/classes/SplayTree.html +0 -202
- package/docs/classes/Stack.html +0 -398
- package/docs/classes/TreeMap.html +0 -202
- package/docs/classes/TreeMultiset.html +0 -2510
- package/docs/classes/TreeMultisetNode.html +0 -447
- package/docs/classes/TreeNode.html +0 -344
- package/docs/classes/TreeSet.html +0 -202
- package/docs/classes/Trie.html +0 -402
- package/docs/classes/TrieNode.html +0 -310
- package/docs/classes/TwoThreeTree.html +0 -202
- package/docs/classes/UndirectedEdge.html +0 -374
- package/docs/classes/UndirectedGraph.html +0 -1285
- package/docs/classes/UndirectedVertex.html +0 -284
- package/docs/classes/Vector2D.html +0 -835
- package/docs/enums/CP.html +0 -211
- package/docs/enums/FamilyPosition.html +0 -239
- package/docs/enums/LoopType.html +0 -212
- package/docs/enums/RBColor.html +0 -204
- package/docs/enums/TopologicalProperty.html +0 -211
- package/docs/functions/arrayRemove.html +0 -208
- package/docs/functions/isThunk.html +0 -186
- package/docs/functions/toThunk.html +0 -186
- package/docs/functions/trampoline.html +0 -186
- package/docs/functions/trampolineAsync.html +0 -186
- package/docs/functions/uuidV4.html +0 -181
- package/docs/interfaces/IAVLTree.html +0 -1245
- package/docs/interfaces/IAbstractBinaryTree.html +0 -1101
- package/docs/interfaces/IAbstractBinaryTreeNode.html +0 -335
- package/docs/interfaces/IAbstractGraph.html +0 -433
- package/docs/interfaces/IBST.html +0 -1245
- package/docs/interfaces/IDirectedGraph.html +0 -570
- package/docs/interfaces/IRBTree.html +0 -1247
- package/docs/interfaces/IUNDirectedGraph.html +0 -463
- package/docs/types/AVLTreeNodeNested.html +0 -182
- package/docs/types/AVLTreeOptions.html +0 -180
- package/docs/types/AbstractBinaryTreeNodeNested.html +0 -182
- package/docs/types/AbstractBinaryTreeNodeProperties.html +0 -182
- package/docs/types/AbstractBinaryTreeNodeProperty.html +0 -182
- package/docs/types/AbstractBinaryTreeOptions.html +0 -182
- package/docs/types/BSTComparator.html +0 -192
- package/docs/types/BSTNodeNested.html +0 -182
- package/docs/types/BSTOptions.html +0 -182
- package/docs/types/BinaryTreeDeletedResult.html +0 -189
- package/docs/types/BinaryTreeNodeId.html +0 -177
- package/docs/types/BinaryTreeNodeNested.html +0 -182
- package/docs/types/BinaryTreeNodePropertyName.html +0 -177
- package/docs/types/BinaryTreeOptions.html +0 -180
- package/docs/types/DFSOrderPattern.html +0 -177
- package/docs/types/DijkstraResult.html +0 -199
- package/docs/types/Direction.html +0 -177
- package/docs/types/DummyAny.html +0 -190
- package/docs/types/EdgeId.html +0 -177
- package/docs/types/HeapOptions.html +0 -198
- package/docs/types/IAVLTreeNode.html +0 -184
- package/docs/types/IBSTNode.html +0 -184
- package/docs/types/IBinaryTree.html +0 -182
- package/docs/types/IBinaryTreeNode.html +0 -184
- package/docs/types/IRBTreeNode.html +0 -184
- package/docs/types/ITreeMultiset.html +0 -182
- package/docs/types/ITreeMultisetNode.html +0 -184
- package/docs/types/KeyValueObject.html +0 -182
- package/docs/types/KeyValueObjectWithId.html +0 -184
- package/docs/types/MapGraphCoordinate.html +0 -177
- package/docs/types/NavigatorParams.html +0 -211
- package/docs/types/NodeOrPropertyName.html +0 -177
- package/docs/types/NonNumberNonObjectButDefined.html +0 -177
- package/docs/types/ObjectWithNonNumberId.html +0 -184
- package/docs/types/ObjectWithNumberId.html +0 -184
- package/docs/types/ObjectWithoutId.html +0 -177
- package/docs/types/PriorityQueueComparator.html +0 -197
- package/docs/types/PriorityQueueDFSOrderPattern.html +0 -177
- package/docs/types/PriorityQueueOptions.html +0 -191
- package/docs/types/RBTreeNodeNested.html +0 -182
- package/docs/types/RBTreeOptions.html +0 -180
- package/docs/types/RestrictValById.html +0 -177
- package/docs/types/SegmentTreeNodeVal.html +0 -177
- package/docs/types/SpecifyOptional.html +0 -184
- package/docs/types/Thunk.html +0 -185
- package/docs/types/ToThunkFn.html +0 -185
- package/docs/types/TopologicalStatus.html +0 -177
- package/docs/types/TreeMultisetNodeNested.html +0 -182
- package/docs/types/TreeMultisetOptions.html +0 -180
- package/docs/types/TrlAsyncFn.html +0 -190
- package/docs/types/TrlFn.html +0 -190
- package/docs/types/Turning.html +0 -177
- package/docs/types/VertexId.html +0 -177
- package/docs/variables/THUNK_SYMBOL.html +0 -177
- package/rename_clear_files.sh +0 -29
- package/src/data-structures/binary-tree/aa-tree.ts +0 -1
- package/src/data-structures/binary-tree/abstract-binary-tree.ts +0 -1631
- package/src/data-structures/binary-tree/avl-tree.ts +0 -310
- package/src/data-structures/binary-tree/b-tree.ts +0 -1
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -76
- package/src/data-structures/binary-tree/binary-tree.ts +0 -47
- package/src/data-structures/binary-tree/bst.ts +0 -537
- package/src/data-structures/binary-tree/index.ts +0 -12
- package/src/data-structures/binary-tree/rb-tree.ts +0 -101
- package/src/data-structures/binary-tree/segment-tree.ts +0 -242
- package/src/data-structures/binary-tree/splay-tree.ts +0 -1
- package/src/data-structures/binary-tree/tree-multiset.ts +0 -700
- package/src/data-structures/binary-tree/two-three-tree.ts +0 -1
- package/src/data-structures/diagrams/README.md +0 -5
- package/src/data-structures/graph/abstract-graph.ts +0 -1040
- package/src/data-structures/graph/directed-graph.ts +0 -470
- package/src/data-structures/graph/index.ts +0 -4
- package/src/data-structures/graph/map-graph.ts +0 -129
- package/src/data-structures/graph/undirected-graph.ts +0 -274
- package/src/data-structures/hash/coordinate-map.ts +0 -67
- package/src/data-structures/hash/coordinate-set.ts +0 -56
- package/src/data-structures/hash/hash-table.ts +0 -1
- package/src/data-structures/hash/index.ts +0 -6
- package/src/data-structures/hash/pair.ts +0 -1
- package/src/data-structures/hash/tree-map.ts +0 -1
- package/src/data-structures/hash/tree-set.ts +0 -1
- package/src/data-structures/heap/heap.ts +0 -212
- package/src/data-structures/heap/index.ts +0 -3
- package/src/data-structures/heap/max-heap.ts +0 -31
- package/src/data-structures/heap/min-heap.ts +0 -32
- package/src/data-structures/index.ts +0 -11
- package/src/data-structures/linked-list/doubly-linked-list.ts +0 -573
- package/src/data-structures/linked-list/index.ts +0 -3
- package/src/data-structures/linked-list/singly-linked-list.ts +0 -501
- 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 -27
- package/src/data-structures/matrix/matrix2d.ts +0 -212
- package/src/data-structures/matrix/navigator.ts +0 -121
- package/src/data-structures/matrix/vector2d.ts +0 -316
- package/src/data-structures/priority-queue/index.ts +0 -3
- package/src/data-structures/priority-queue/max-priority-queue.ts +0 -56
- package/src/data-structures/priority-queue/min-priority-queue.ts +0 -57
- package/src/data-structures/priority-queue/priority-queue.ts +0 -359
- package/src/data-structures/queue/deque.ts +0 -297
- package/src/data-structures/queue/index.ts +0 -2
- package/src/data-structures/queue/queue.ts +0 -191
- package/src/data-structures/stack/index.ts +0 -1
- package/src/data-structures/stack/stack.ts +0 -98
- package/src/data-structures/tree/index.ts +0 -1
- package/src/data-structures/tree/tree.ts +0 -69
- package/src/data-structures/trie/index.ts +0 -1
- package/src/data-structures/trie/trie.ts +0 -225
- package/src/index.ts +0 -4
- package/src/interfaces/abstract-binary-tree.ts +0 -191
- package/src/interfaces/abstract-graph.ts +0 -31
- package/src/interfaces/avl-tree.ts +0 -25
- package/src/interfaces/binary-tree.ts +0 -6
- package/src/interfaces/bst.ts +0 -31
- package/src/interfaces/directed-graph.ts +0 -20
- package/src/interfaces/doubly-linked-list.ts +0 -1
- package/src/interfaces/heap.ts +0 -1
- package/src/interfaces/index.ts +0 -15
- package/src/interfaces/navigator.ts +0 -1
- package/src/interfaces/priority-queue.ts +0 -1
- package/src/interfaces/rb-tree.ts +0 -9
- package/src/interfaces/segment-tree.ts +0 -1
- package/src/interfaces/singly-linked-list.ts +0 -1
- package/src/interfaces/tree-multiset.ts +0 -7
- package/src/interfaces/undirected-graph.ts +0 -6
- package/src/types/data-structures/abstract-binary-tree.ts +0 -50
- package/src/types/data-structures/abstract-graph.ts +0 -11
- package/src/types/data-structures/avl-tree.ts +0 -5
- package/src/types/data-structures/binary-tree.ts +0 -5
- package/src/types/data-structures/bst.ts +0 -13
- package/src/types/data-structures/directed-graph.ts +0 -8
- package/src/types/data-structures/doubly-linked-list.ts +0 -1
- package/src/types/data-structures/heap.ts +0 -5
- package/src/types/data-structures/index.ts +0 -15
- package/src/types/data-structures/map-graph.ts +0 -1
- package/src/types/data-structures/navigator.ts +0 -13
- package/src/types/data-structures/priority-queue.ts +0 -9
- package/src/types/data-structures/rb-tree.ts +0 -8
- package/src/types/data-structures/segment-tree.ts +0 -1
- package/src/types/data-structures/singly-linked-list.ts +0 -1
- package/src/types/data-structures/tree-multiset.ts +0 -6
- package/src/types/helpers.ts +0 -1
- package/src/types/index.ts +0 -3
- package/src/types/utils/index.ts +0 -2
- package/src/types/utils/utils.ts +0 -6
- package/src/types/utils/validate-type.ts +0 -35
- package/src/utils/index.ts +0 -1
- package/src/utils/utils.ts +0 -79
- package/tsconfig.build.json +0 -33
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# Data Structure Typed
|
|
2
|
+
|
|
1
3
|

|
|
2
4
|

|
|
3
5
|

|
|
@@ -5,36 +7,50 @@
|
|
|
5
7
|

|
|
6
8
|

|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
## Brief
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
Data Structures of Javascript & TypeScript.
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
## Built-in classic algorithms
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
DFS(Depth-First Search), DFSIterative, BFS(Breadth-First Search), morris, Bellman-Ford Algorithm, Dijkstra's Algorithm,
|
|
17
|
+
Floyd-Warshall Algorithm, Tarjan's Algorithm.
|
|
16
18
|
|
|
17
|
-
##
|
|
18
|
-
DFS(Depth-First Search), DFSIterative, BFS(Breadth-First Search),
|
|
19
|
-
morris, Bellman-Ford Algorithm, Dijkstra's Algorithm, Floyd-Warshall Algorithm,
|
|
20
|
-
Tarjan's Algorithm.
|
|
19
|
+
## Installation and Usage
|
|
21
20
|
|
|
22
|
-
## install
|
|
23
21
|
### npm
|
|
22
|
+
|
|
24
23
|
```bash
|
|
25
24
|
npm install data-structure-typed --save
|
|
26
25
|
```
|
|
26
|
+
|
|
27
27
|
### yarn
|
|
28
|
+
|
|
28
29
|
```bash
|
|
29
30
|
yarn add data-structure-typed
|
|
30
31
|
```
|
|
32
|
+
|
|
31
33
|
### CDN
|
|
34
|
+
|
|
32
35
|
```html
|
|
36
|
+
|
|
33
37
|
<script src="https://cdn.jsdelivr.net/npm/data-structure-typed/umd/bundle.min.js"></script>
|
|
34
38
|
```
|
|
35
|
-
|
|
39
|
+
|
|
40
|
+
```js
|
|
36
41
|
const {AVLTree} = dataStructureTyped;
|
|
37
|
-
const {
|
|
42
|
+
const {
|
|
43
|
+
Heap,
|
|
44
|
+
MinHeap,
|
|
45
|
+
SinglyLinkedList,
|
|
46
|
+
Stack,
|
|
47
|
+
AVLTreeNode,
|
|
48
|
+
BST,
|
|
49
|
+
Trie,
|
|
50
|
+
DirectedGraph,
|
|
51
|
+
DirectedVertex,
|
|
52
|
+
TreeMultiset
|
|
53
|
+
} = dataStructureTyped;
|
|
38
54
|
```
|
|
39
55
|
|
|
40
56
|

|
|
@@ -54,159 +70,168 @@ const {Heap, MinHeap, SinglyLinkedList, Stack, AVLTreeNode, BST, Trie, DirectedG
|
|
|
54
70
|
<a href="https://github.com/zrwusa/vivid-algorithm" target="_blank">Examples Repository</a>
|
|
55
71
|
|
|
56
72
|
## Code Snippet
|
|
73
|
+
|
|
57
74
|
### Binary Search Tree (BST) snippet
|
|
75
|
+
|
|
58
76
|
#### TS
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import {BST, BSTNode} from 'data-structure-typed';
|
|
80
|
+
|
|
81
|
+
const bst = new BST();
|
|
82
|
+
bst.add(11);
|
|
83
|
+
bst.add(3);
|
|
84
|
+
bst.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]);
|
|
85
|
+
bst.size === 16; // true
|
|
86
|
+
bst.has(6); // true
|
|
87
|
+
const node6 = bst.get(6); // BSTNode
|
|
88
|
+
bst.getHeight(6) === 2; // true
|
|
89
|
+
bst.getHeight() === 5; // true
|
|
90
|
+
bst.getDepth(6) === 3; // true
|
|
91
|
+
|
|
92
|
+
bst.getLeftMost()?.id === 1; // true
|
|
93
|
+
|
|
94
|
+
bst.remove(6);
|
|
95
|
+
bst.get(6); // null
|
|
96
|
+
bst.isAVLBalanced(); // true
|
|
97
|
+
bst.BFS()[0] === 11; // true
|
|
98
|
+
|
|
99
|
+
const objBST = new BST<BSTNode<{ id: number, keyA: number }>>();
|
|
100
|
+
objBST.add(11, {id: 11, keyA: 11});
|
|
101
|
+
objBST.add(3, {id: 3, keyA: 3});
|
|
102
|
+
|
|
103
|
+
objBST.addMany([{id: 15, keyA: 15}, {id: 1, keyA: 1}, {id: 8, keyA: 8},
|
|
104
|
+
{id: 13, keyA: 13}, {id: 16, keyA: 16}, {id: 2, keyA: 2},
|
|
105
|
+
{id: 6, keyA: 6}, {id: 9, keyA: 9}, {id: 12, keyA: 12},
|
|
106
|
+
{id: 14, keyA: 14}, {id: 4, keyA: 4}, {id: 7, keyA: 7},
|
|
107
|
+
{id: 10, keyA: 10}, {id: 5, keyA: 5}]);
|
|
108
|
+
|
|
109
|
+
objBST.remove(11);
|
|
92
110
|
```
|
|
111
|
+
|
|
93
112
|
#### JS
|
|
94
|
-
```javascript
|
|
95
|
-
const {BST, BSTNode} = require('data-structure-typed');
|
|
96
|
-
|
|
97
|
-
const bst = new BST();
|
|
98
|
-
bst.add(11);
|
|
99
|
-
bst.add(3);
|
|
100
|
-
bst.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]);
|
|
101
|
-
bst.size === 16; // true
|
|
102
|
-
bst.has(6); // true
|
|
103
|
-
const node6 = bst.get(6);
|
|
104
|
-
bst.getHeight(6) === 2; // true
|
|
105
|
-
bst.getHeight() === 5; // true
|
|
106
|
-
bst.getDepth(6) === 3; // true
|
|
107
|
-
const leftMost = bst.getLeftMost();
|
|
108
|
-
leftMost?.id === 1; // true
|
|
109
|
-
expect(leftMost?.id).toBe(1);
|
|
110
|
-
bst.remove(6);
|
|
111
|
-
bst.get(6); // null
|
|
112
|
-
bst.isAVLBalanced(); // true or false
|
|
113
|
-
const bfsIDs = bst.BFS();
|
|
114
|
-
bfsIDs[0] === 11; // true
|
|
115
|
-
expect(bfsIDs[0]).toBe(11);
|
|
116
|
-
|
|
117
|
-
const objBST = new BST();
|
|
118
|
-
objBST.add(11, {id: 11, keyA: 11});
|
|
119
|
-
objBST.add(3, {id: 3, keyA: 3});
|
|
120
|
-
|
|
121
|
-
objBST.addMany([{id: 15, keyA: 15}, {id: 1, keyA: 1}, {id: 8, keyA: 8},
|
|
122
|
-
{id: 13, keyA: 13}, {id: 16, keyA: 16}, {id: 2, keyA: 2},
|
|
123
|
-
{id: 6, keyA: 6}, {id: 9, keyA: 9}, {id: 12, keyA: 12},
|
|
124
|
-
{id: 14, keyA: 14}, {id: 4, keyA: 4}, {id: 7, keyA: 7},
|
|
125
|
-
{id: 10, keyA: 10}, {id: 5, keyA: 5}]);
|
|
126
|
-
|
|
127
|
-
objBST.remove(11);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const avlTree = new AVLTree();
|
|
131
|
-
avlTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5])
|
|
132
|
-
avlTree.isAVLBalanced(); // true
|
|
133
|
-
avlTree.remove(10);
|
|
134
|
-
avlTree.isAVLBalanced(); // true
|
|
135
113
|
|
|
114
|
+
```js
|
|
115
|
+
const {BST, BSTNode} = require('data-structure-typed');
|
|
116
|
+
|
|
117
|
+
const bst = new BST();
|
|
118
|
+
bst.add(11);
|
|
119
|
+
bst.add(3);
|
|
120
|
+
bst.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]);
|
|
121
|
+
bst.size === 16; // true
|
|
122
|
+
bst.has(6); // true
|
|
123
|
+
const node6 = bst.get(6);
|
|
124
|
+
bst.getHeight(6) === 2; // true
|
|
125
|
+
bst.getHeight() === 5; // true
|
|
126
|
+
bst.getDepth(6) === 3; // true
|
|
127
|
+
const leftMost = bst.getLeftMost();
|
|
128
|
+
leftMost?.id === 1; // true
|
|
129
|
+
expect(leftMost?.id).toBe(1);
|
|
130
|
+
bst.remove(6);
|
|
131
|
+
bst.get(6); // null
|
|
132
|
+
bst.isAVLBalanced(); // true or false
|
|
133
|
+
const bfsIDs = bst.BFS();
|
|
134
|
+
bfsIDs[0] === 11; // true
|
|
135
|
+
expect(bfsIDs[0]).toBe(11);
|
|
136
|
+
|
|
137
|
+
const objBST = new BST();
|
|
138
|
+
objBST.add(11, {id: 11, keyA: 11});
|
|
139
|
+
objBST.add(3, {id: 3, keyA: 3});
|
|
140
|
+
|
|
141
|
+
objBST.addMany([{id: 15, keyA: 15}, {id: 1, keyA: 1}, {id: 8, keyA: 8},
|
|
142
|
+
{id: 13, keyA: 13}, {id: 16, keyA: 16}, {id: 2, keyA: 2},
|
|
143
|
+
{id: 6, keyA: 6}, {id: 9, keyA: 9}, {id: 12, keyA: 12},
|
|
144
|
+
{id: 14, keyA: 14}, {id: 4, keyA: 4}, {id: 7, keyA: 7},
|
|
145
|
+
{id: 10, keyA: 10}, {id: 5, keyA: 5}]);
|
|
146
|
+
|
|
147
|
+
objBST.remove(11);
|
|
148
|
+
|
|
149
|
+
const avlTree = new AVLTree();
|
|
150
|
+
avlTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5])
|
|
151
|
+
avlTree.isAVLBalanced(); // true
|
|
152
|
+
avlTree.remove(10);
|
|
153
|
+
avlTree.isAVLBalanced(); // true
|
|
136
154
|
```
|
|
137
155
|
|
|
138
156
|
### AVLTree snippet
|
|
157
|
+
|
|
139
158
|
#### TS
|
|
140
|
-
```typescript
|
|
141
|
-
import {AVLTree} from 'data-structure-typed';
|
|
142
159
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
avlTree.isAVLBalanced(); // true
|
|
146
|
-
avlTree.remove(10);
|
|
147
|
-
avlTree.isAVLBalanced(); // true
|
|
160
|
+
```ts
|
|
161
|
+
import {AVLTree} from 'data-structure-typed';
|
|
148
162
|
|
|
163
|
+
const avlTree = new AVLTree();
|
|
164
|
+
avlTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5])
|
|
165
|
+
avlTree.isAVLBalanced(); // true
|
|
166
|
+
avlTree.remove(10);
|
|
167
|
+
avlTree.isAVLBalanced(); // true
|
|
149
168
|
```
|
|
169
|
+
|
|
150
170
|
#### JS
|
|
151
|
-
```javascript
|
|
152
|
-
const {AVLTree} = require('data-structure-typed');
|
|
153
171
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
avlTree.isAVLBalanced(); // true
|
|
157
|
-
avlTree.remove(10);
|
|
158
|
-
avlTree.isAVLBalanced(); // true
|
|
172
|
+
```js
|
|
173
|
+
const {AVLTree} = require('data-structure-typed');
|
|
159
174
|
|
|
175
|
+
const avlTree = new AVLTree();
|
|
176
|
+
avlTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5])
|
|
177
|
+
avlTree.isAVLBalanced(); // true
|
|
178
|
+
avlTree.remove(10);
|
|
179
|
+
avlTree.isAVLBalanced(); // true
|
|
160
180
|
```
|
|
161
181
|
|
|
162
182
|
### Directed Graph simple snippet
|
|
183
|
+
|
|
163
184
|
#### TS or JS
|
|
164
|
-
|
|
185
|
+
|
|
186
|
+
```ts
|
|
165
187
|
import {DirectedGraph} from 'data-structure-typed';
|
|
166
188
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
+
const graph = new DirectedGraph();
|
|
190
|
+
|
|
191
|
+
graph.addVertex('A');
|
|
192
|
+
graph.addVertex('B');
|
|
193
|
+
|
|
194
|
+
graph.hasVertex('A'); // true
|
|
195
|
+
graph.hasVertex('B'); // true
|
|
196
|
+
graph.hasVertex('C'); // false
|
|
197
|
+
|
|
198
|
+
graph.addEdge('A', 'B');
|
|
199
|
+
graph.hasEdge('A', 'B'); // true
|
|
200
|
+
graph.hasEdge('B', 'A'); // false
|
|
201
|
+
|
|
202
|
+
graph.removeEdgeSrcToDest('A', 'B');
|
|
203
|
+
graph.hasEdge('A', 'B'); // false
|
|
204
|
+
|
|
205
|
+
graph.addVertex('C');
|
|
206
|
+
|
|
207
|
+
graph.addEdge('A', 'B');
|
|
208
|
+
graph.addEdge('B', 'C');
|
|
209
|
+
|
|
210
|
+
const topologicalOrderIds = graph.topologicalSort(); // ['A', 'B', 'C']
|
|
189
211
|
```
|
|
190
212
|
|
|
191
213
|
### Undirected Graph snippet
|
|
214
|
+
|
|
192
215
|
#### TS or JS
|
|
193
|
-
|
|
216
|
+
|
|
217
|
+
```ts
|
|
194
218
|
import {UndirectedGraph} from 'data-structure-typed';
|
|
195
219
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
220
|
+
const graph = new UndirectedGraph();
|
|
221
|
+
graph.addVertex('A');
|
|
222
|
+
graph.addVertex('B');
|
|
223
|
+
graph.addVertex('C');
|
|
224
|
+
graph.addVertex('D');
|
|
225
|
+
graph.removeVertex('C');
|
|
226
|
+
graph.addEdge('A', 'B');
|
|
227
|
+
graph.addEdge('B', 'D');
|
|
228
|
+
|
|
229
|
+
const dijkstraResult = graph.dijkstra('A');
|
|
230
|
+
Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.id) // ['A', 'B', 'D']
|
|
207
231
|
```
|
|
208
232
|
|
|
209
233
|
## Data Structures
|
|
234
|
+
|
|
210
235
|
<table>
|
|
211
236
|
<thead>
|
|
212
237
|
<tr>
|
|
@@ -330,20 +355,6 @@ import {UndirectedGraph} from 'data-structure-typed';
|
|
|
330
355
|
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Stack.html"><span>Stack</span></a></td>
|
|
331
356
|
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
332
357
|
</tr>
|
|
333
|
-
|
|
334
|
-
[//]: # (<tr>)
|
|
335
|
-
|
|
336
|
-
[//]: # (<td>Hash</td>)
|
|
337
|
-
|
|
338
|
-
[//]: # (<td></td>)
|
|
339
|
-
|
|
340
|
-
[//]: # (<td></td>)
|
|
341
|
-
|
|
342
|
-
[//]: # (<td><a href="https://data-structure-typed-docs.vercel.app/classes/HashTable.html"><span>HashTable</span></a></td>)
|
|
343
|
-
|
|
344
|
-
[//]: # (<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>)
|
|
345
|
-
|
|
346
|
-
[//]: # (</tr>)
|
|
347
358
|
<tr>
|
|
348
359
|
<td>Coordinate Set</td>
|
|
349
360
|
<td></td>
|
|
@@ -396,113 +407,16 @@ import {UndirectedGraph} from 'data-structure-typed';
|
|
|
396
407
|
</tbody>
|
|
397
408
|
</table>
|
|
398
409
|
|
|
399
|
-
[//]: # (## API docs)
|
|
400
|
-
|
|
401
|
-
[//]: # (<ul>)
|
|
402
|
-
|
|
403
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTree.html" rel="nofollow"><span>AVLTree</span></a></li>)
|
|
404
|
-
|
|
405
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTreeNode.html" rel="nofollow"><span>AVLTreeNode</span></a></li>)
|
|
406
|
-
|
|
407
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractEdge.html" rel="nofollow"><span>AbstractEdge</span></a></li>)
|
|
408
|
-
|
|
409
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractGraph.html" rel="nofollow"><span>AbstractGraph</span></a></li>)
|
|
410
|
-
|
|
411
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractVertex.html" rel="nofollow"><span>AbstractVertex</span></a></li>)
|
|
412
|
-
|
|
413
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/ArrayDeque.html" rel="nofollow"><span>ArrayDeque</span></a></li>)
|
|
414
|
-
|
|
415
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/BST.html" rel="nofollow"><span>BST</span></a></li>)
|
|
416
|
-
|
|
417
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/BSTNode.html" rel="nofollow"><span>BSTNode</span></a></li>)
|
|
418
|
-
|
|
419
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryIndexedTree.html" rel="nofollow"><span>BinaryIndexedTree</span></a></li>)
|
|
420
|
-
|
|
421
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTree.html" rel="nofollow"><span>BinaryTree</span></a></li>)
|
|
422
|
-
|
|
423
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTreeNode.html" rel="nofollow"><span>BinaryTreeNode</span></a></li>)
|
|
424
|
-
|
|
425
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/Character.html" rel="nofollow"><span>Character</span></a></li>)
|
|
426
|
-
|
|
427
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/CoordinateMap.html" rel="nofollow"><span>CoordinateMap</span></a></li>)
|
|
428
|
-
|
|
429
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/CoordinateSet.html" rel="nofollow"><span>CoordinateSet</span></a></li>)
|
|
430
|
-
|
|
431
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/Deque.html" rel="nofollow"><span>Deque</span></a></li>)
|
|
432
|
-
|
|
433
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedEdge.html" rel="nofollow"><span>DirectedEdge</span></a></li>)
|
|
434
|
-
|
|
435
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedGraph.html" rel="nofollow"><span>DirectedGraph</span></a></li>)
|
|
436
|
-
|
|
437
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedVertex.html" rel="nofollow"><span>DirectedVertex</span></a></li>)
|
|
438
|
-
|
|
439
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedList.html" rel="nofollow"><span>DoublyLinkedList</span></a></li>)
|
|
440
|
-
|
|
441
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedListNode.html" rel="nofollow"><span>DoublyLinkedListNode</span></a></li>)
|
|
442
|
-
|
|
443
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/Heap.html" rel="nofollow"><span>Heap</span></a></li>)
|
|
444
|
-
|
|
445
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/Matrix2D.html" rel="nofollow"><span>Matrix2D</span></a></li>)
|
|
446
|
-
|
|
447
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/MatrixNTI2D.html" rel="nofollow"><span>MatrixNTI2D</span></a></li>)
|
|
448
|
-
|
|
449
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/MaxHeap.html" rel="nofollow"><span>MaxHeap</span></a></li>)
|
|
450
|
-
|
|
451
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/MaxPriorityQueue.html" rel="nofollow"><span>MaxPriorityQueue</span></a></li>)
|
|
452
|
-
|
|
453
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/MinHeap.html" rel="nofollow"><span>MinHeap</span></a></li>)
|
|
454
|
-
|
|
455
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/MinPriorityQueue.html" rel="nofollow"><span>MinPriorityQueue</span></a></li>)
|
|
456
|
-
|
|
457
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/Navigator.html" rel="nofollow"><span>Navigator</span></a></li>)
|
|
458
|
-
|
|
459
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/ObjectDeque.html" rel="nofollow"><span>ObjectDeque</span></a></li>)
|
|
460
|
-
|
|
461
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/PriorityQueue.html" rel="nofollow"><span>PriorityQueue</span></a></li>)
|
|
462
|
-
|
|
463
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/Queue.html" rel="nofollow"><span>Queue</span></a></li>)
|
|
464
|
-
|
|
465
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTree.html" rel="nofollow"><span>SegmentTree</span></a></li>)
|
|
466
|
-
|
|
467
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTreeNode.html" rel="nofollow"><span>SegmentTreeNode</span></a></li>)
|
|
468
|
-
|
|
469
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html" rel="nofollow"><span>SinglyLinkedList</span></a></li>)
|
|
470
|
-
|
|
471
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedListNode.html" rel="nofollow"><span>SinglyLinkedListNode</span></a></li>)
|
|
472
|
-
|
|
473
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/Stack.html" rel="nofollow"><span>Stack</span></a></li>)
|
|
474
|
-
|
|
475
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/TreeMultiSet.html" rel="nofollow"><span>TreeMultiSet</span></a></li>)
|
|
476
|
-
|
|
477
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/Trie.html" rel="nofollow"><span>Trie</span></a></li>)
|
|
478
|
-
|
|
479
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/TrieNode.html" rel="nofollow"><span>TrieNode</span></a></li>)
|
|
480
|
-
|
|
481
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedEdge.html" rel="nofollow"><span>UndirectedEdge</span></a></li>)
|
|
482
|
-
|
|
483
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedGraph.html" rel="nofollow"><span>UndirectedGraph</span></a></li>)
|
|
484
|
-
|
|
485
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedVertex.html" rel="nofollow"><span>UndirectedVertex</span></a></li>)
|
|
486
|
-
|
|
487
|
-
[//]: # (<li><a href="https://data-structure-typed-docs.vercel.app/classes/Vector2D.html" rel="nofollow"><span>Vector2D</span></a></li>)
|
|
488
|
-
|
|
489
|
-
[//]: # (</ul>)
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
[//]: # ()
|
|
493
|
-
|
|
494
|
-
[//]: # ()
|
|
495
|
-
|
|
496
|
-
[//]: # ()
|
|
497
|
-
|
|
498
|
-
[//]: # ()
|
|
499
|
-
|
|
500
410
|
## Code design
|
|
501
|
-
|
|
411
|
+
|
|
412
|
+
By strictly adhering to object-oriented design (BinaryTree -> BST -> AVLTree -> TreeMultiset), you can seamlessly
|
|
413
|
+
inherit the existing data structures to implement the customized ones you need. Object-oriented design stands as the
|
|
414
|
+
optimal approach to data structure design.
|
|
502
415
|
|
|
503
416
|
## Complexities
|
|
504
417
|
|
|
505
418
|
### performance of Big O
|
|
419
|
+
|
|
506
420
|
<table>
|
|
507
421
|
<thead>
|
|
508
422
|
<tr>
|
|
@@ -567,6 +481,7 @@ By strictly adhering to object-oriented design (BinaryTree -> BST -> AVLTree ->
|
|
|
567
481
|
</table>
|
|
568
482
|
|
|
569
483
|
### Data Structure Complexity
|
|
484
|
+
|
|
570
485
|
<table>
|
|
571
486
|
<thead>
|
|
572
487
|
<tr>
|
|
@@ -663,6 +578,7 @@ By strictly adhering to object-oriented design (BinaryTree -> BST -> AVLTree ->
|
|
|
663
578
|
</table>
|
|
664
579
|
|
|
665
580
|
### Sorting Complexity
|
|
581
|
+
|
|
666
582
|
<table>
|
|
667
583
|
<thead>
|
|
668
584
|
<tr>
|
|
@@ -760,8 +676,252 @@ By strictly adhering to object-oriented design (BinaryTree -> BST -> AVLTree ->
|
|
|
760
676
|
</tbody>
|
|
761
677
|
</table>
|
|
762
678
|
|
|
763
|
-
[//]: # ()
|
|
764
|
-
|
|
765
|
-

|
|
766
679
|
|
|
767
|
-
|
|
680
|
+
<table>
|
|
681
|
+
<tr>
|
|
682
|
+
<th>Data Structure</th>
|
|
683
|
+
<th>C++ STL</th>
|
|
684
|
+
<th>java.util</th>
|
|
685
|
+
<th>Python collections</th>
|
|
686
|
+
</tr>
|
|
687
|
+
<tr>
|
|
688
|
+
<td>Dynamic Array (ArrayList)</td>
|
|
689
|
+
<td>std::vector<T></td>
|
|
690
|
+
<td>ArrayList<E></td>
|
|
691
|
+
<td>list</td>
|
|
692
|
+
</tr>
|
|
693
|
+
<tr>
|
|
694
|
+
<td>Linked List</td>
|
|
695
|
+
<td>std::list<T></td>
|
|
696
|
+
<td>LinkedList<E></td>
|
|
697
|
+
<td>deque</td>
|
|
698
|
+
</tr>
|
|
699
|
+
<tr>
|
|
700
|
+
<td>Set</td>
|
|
701
|
+
<td>std::set<T></td>
|
|
702
|
+
<td>HashSet<E></td>
|
|
703
|
+
<td>set</td>
|
|
704
|
+
</tr>
|
|
705
|
+
<tr>
|
|
706
|
+
<td>Map</td>
|
|
707
|
+
<td>std::map<K, V></td>
|
|
708
|
+
<td>HashMap<K, V></td>
|
|
709
|
+
<td>dict</td>
|
|
710
|
+
</tr>
|
|
711
|
+
<tr>
|
|
712
|
+
<td>Stack</td>
|
|
713
|
+
<td>std::stack<T></td>
|
|
714
|
+
<td>Stack<E></td>
|
|
715
|
+
<td>N/A</td>
|
|
716
|
+
</tr>
|
|
717
|
+
<tr>
|
|
718
|
+
<td>Queue</td>
|
|
719
|
+
<td>std::queue<T></td>
|
|
720
|
+
<td>LinkedList<E></td>
|
|
721
|
+
<td>N/A</td>
|
|
722
|
+
</tr>
|
|
723
|
+
<tr>
|
|
724
|
+
<td>Priority Queue</td>
|
|
725
|
+
<td>std::priority_queue<T></td>
|
|
726
|
+
<td>PriorityQueue<E></td>
|
|
727
|
+
<td>N/A</td>
|
|
728
|
+
</tr>
|
|
729
|
+
<tr>
|
|
730
|
+
<td>Hash Table</td>
|
|
731
|
+
<td>N/A</td>
|
|
732
|
+
<td>N/A</td>
|
|
733
|
+
<td>defaultdict, Counter, etc.</td>
|
|
734
|
+
</tr>
|
|
735
|
+
<tr>
|
|
736
|
+
<td>Deque</td>
|
|
737
|
+
<td>std::deque<T></td>
|
|
738
|
+
<td>N/A</td>
|
|
739
|
+
<td>N/A</td>
|
|
740
|
+
</tr>
|
|
741
|
+
<tr>
|
|
742
|
+
<td>Multiset</td>
|
|
743
|
+
<td>std::multiset<T></td>
|
|
744
|
+
<td>N/A</td>
|
|
745
|
+
<td>N/A</td>
|
|
746
|
+
</tr>
|
|
747
|
+
<tr>
|
|
748
|
+
<td>Multimap</td>
|
|
749
|
+
<td>std::multimap<K, V></td>
|
|
750
|
+
<td>N/A</td>
|
|
751
|
+
<td>N/A</td>
|
|
752
|
+
</tr>
|
|
753
|
+
<tr>
|
|
754
|
+
<td>Unordered Set</td>
|
|
755
|
+
<td>std::unordered_set<T></td>
|
|
756
|
+
<td>HashSet<E></td>
|
|
757
|
+
<td>N/A</td>
|
|
758
|
+
</tr>
|
|
759
|
+
<tr>
|
|
760
|
+
<td>Unordered Map</td>
|
|
761
|
+
<td>std::unordered_map<K, V></td>
|
|
762
|
+
<td>HashMap<K, V></td>
|
|
763
|
+
<td>N/A</td>
|
|
764
|
+
</tr>
|
|
765
|
+
<tr>
|
|
766
|
+
<td>Bitset</td>
|
|
767
|
+
<td>std::bitset<N></td>
|
|
768
|
+
<td>N/A</td>
|
|
769
|
+
<td>N/A</td>
|
|
770
|
+
</tr>
|
|
771
|
+
<tr>
|
|
772
|
+
<td>Ordered Dictionary (OrderedDict)</td>
|
|
773
|
+
<td>N/A</td>
|
|
774
|
+
<td>N/A</td>
|
|
775
|
+
<td>OrderedDict</td>
|
|
776
|
+
</tr>
|
|
777
|
+
<tr>
|
|
778
|
+
<td>User-Defined Dictionary</td>
|
|
779
|
+
<td>N/A</td>
|
|
780
|
+
<td>N/A</td>
|
|
781
|
+
<td>UserDict</td>
|
|
782
|
+
</tr>
|
|
783
|
+
<tr>
|
|
784
|
+
<td>User-Defined List</td>
|
|
785
|
+
<td>N/A</td>
|
|
786
|
+
<td>N/A</td>
|
|
787
|
+
<td>UserList</td>
|
|
788
|
+
</tr>
|
|
789
|
+
<tr>
|
|
790
|
+
<td>User-Defined Set</td>
|
|
791
|
+
<td>N/A</td>
|
|
792
|
+
<td>N/A</td>
|
|
793
|
+
<td>UserSet</td>
|
|
794
|
+
</tr>
|
|
795
|
+
<tr>
|
|
796
|
+
<td>Double-Ended Queue (Deque)</td>
|
|
797
|
+
<td>std::deque<T></td>
|
|
798
|
+
<td>N/A</td>
|
|
799
|
+
<td>N/A</td>
|
|
800
|
+
</tr>
|
|
801
|
+
<tr>
|
|
802
|
+
<td>Skip List</td>
|
|
803
|
+
<td>N/A</td>
|
|
804
|
+
<td>N/A</td>
|
|
805
|
+
<td>N/A</td>
|
|
806
|
+
</tr>
|
|
807
|
+
<tr>
|
|
808
|
+
<td>Circular Queue</td>
|
|
809
|
+
<td>N/A</td>
|
|
810
|
+
<td>N/A</td>
|
|
811
|
+
<td>N/A</td>
|
|
812
|
+
</tr>
|
|
813
|
+
<tr>
|
|
814
|
+
<td>Bit Array</td>
|
|
815
|
+
<td>N/A</td>
|
|
816
|
+
<td>N/A</td>
|
|
817
|
+
<td>N/A</td>
|
|
818
|
+
</tr>
|
|
819
|
+
<tr>
|
|
820
|
+
<td>Bloom Filter</td>
|
|
821
|
+
<td>N/A</td>
|
|
822
|
+
<td>N/A</td>
|
|
823
|
+
<td>N/A</td>
|
|
824
|
+
</tr>
|
|
825
|
+
<tr>
|
|
826
|
+
<td>Linked Hash Set</td>
|
|
827
|
+
<td>N/A</td>
|
|
828
|
+
<td>LinkedHashSet<E></td>
|
|
829
|
+
<td>N/A</td>
|
|
830
|
+
</tr>
|
|
831
|
+
<tr>
|
|
832
|
+
<td>Linked Hash Map</td>
|
|
833
|
+
<td>N/A</td>
|
|
834
|
+
<td>LinkedHashMap<K, V></td>
|
|
835
|
+
<td>N/A</td>
|
|
836
|
+
</tr>
|
|
837
|
+
<tr>
|
|
838
|
+
<td>Sorted Set</td>
|
|
839
|
+
<td>N/A</td>
|
|
840
|
+
<td>TreeSet<E></td>
|
|
841
|
+
<td>N/A</td>
|
|
842
|
+
</tr>
|
|
843
|
+
<tr>
|
|
844
|
+
<td>Sorted Map</td>
|
|
845
|
+
<td>N/A</td>
|
|
846
|
+
<td>TreeMap<K, V></td>
|
|
847
|
+
<td>N/A</td>
|
|
848
|
+
</tr>
|
|
849
|
+
<tr>
|
|
850
|
+
<td>Tree Set</td>
|
|
851
|
+
<td>N/A</td>
|
|
852
|
+
<td>N/A</td>
|
|
853
|
+
<td>N/A</td>
|
|
854
|
+
</tr>
|
|
855
|
+
<tr>
|
|
856
|
+
<td>Tree Map</td>
|
|
857
|
+
<td>N/A</td>
|
|
858
|
+
<td>N/A</td>
|
|
859
|
+
<td>N/A</td>
|
|
860
|
+
</tr>
|
|
861
|
+
<tr>
|
|
862
|
+
<td>Persistent Collections</td>
|
|
863
|
+
<td>N/A</td>
|
|
864
|
+
<td>N/A</td>
|
|
865
|
+
<td>N/A</td>
|
|
866
|
+
</tr>
|
|
867
|
+
<tr>
|
|
868
|
+
<td>std::unordered_multiset</td>
|
|
869
|
+
<td>std::unordered_multiset<T></td>
|
|
870
|
+
<td>N/A</td>
|
|
871
|
+
<td>N/A</td>
|
|
872
|
+
</tr>
|
|
873
|
+
<tr>
|
|
874
|
+
<td>std::unordered_multimap</td>
|
|
875
|
+
<td>std::unordered_multimap<K, V></td>
|
|
876
|
+
<td>N/A</td>
|
|
877
|
+
<td>N/A</td>
|
|
878
|
+
</tr>
|
|
879
|
+
<tr>
|
|
880
|
+
<td>N/A</td>
|
|
881
|
+
<td>TreeSet<E></td>
|
|
882
|
+
<td>TreeSet<E></td>
|
|
883
|
+
<td>N/A</td>
|
|
884
|
+
</tr>
|
|
885
|
+
<tr>
|
|
886
|
+
<td>N/A</td>
|
|
887
|
+
<td>TreeMap<K, V></td>
|
|
888
|
+
<td>TreeMap<K, V></td>
|
|
889
|
+
<td>N/A</td>
|
|
890
|
+
</tr>
|
|
891
|
+
<tr>
|
|
892
|
+
<td>N/A</td>
|
|
893
|
+
<td>LinkedBlockingQueue<E></td>
|
|
894
|
+
<td>N/A</td>
|
|
895
|
+
<td>N/A</td>
|
|
896
|
+
</tr>
|
|
897
|
+
<tr>
|
|
898
|
+
<td>N/A</td>
|
|
899
|
+
<td>ConcurrentHashMap<K, V></td>
|
|
900
|
+
<td>N/A</td>
|
|
901
|
+
<td>N/A</td>
|
|
902
|
+
</tr>
|
|
903
|
+
<tr>
|
|
904
|
+
<td>N/A</td>
|
|
905
|
+
<td>N/A</td>
|
|
906
|
+
<td>namedtuple</td>
|
|
907
|
+
<td>N/A</td>
|
|
908
|
+
</tr>
|
|
909
|
+
<tr>
|
|
910
|
+
<td>N/A</td>
|
|
911
|
+
<td>N/A</td>
|
|
912
|
+
<td>ChainMap</td>
|
|
913
|
+
<td>N/A</td>
|
|
914
|
+
</tr>
|
|
915
|
+
<tr>
|
|
916
|
+
<td>N/A</td>
|
|
917
|
+
<td>N/A</td>
|
|
918
|
+
<td>defaultdict</td>
|
|
919
|
+
<td>N/A</td>
|
|
920
|
+
</tr>
|
|
921
|
+
<tr>
|
|
922
|
+
<td>N/A</td>
|
|
923
|
+
<td>N/A</td>
|
|
924
|
+
<td>Counter</td>
|
|
925
|
+
<td>N/A</td>
|
|
926
|
+
</tr>
|
|
927
|
+
</table>
|