data-structure-typed 1.18.7 → 1.19.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/README.md +208 -419
- package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +198 -167
- package/dist/data-structures/binary-tree/abstract-binary-tree.js +413 -398
- package/dist/data-structures/binary-tree/avl-tree.d.ts +24 -16
- package/dist/data-structures/binary-tree/avl-tree.js +23 -17
- package/dist/data-structures/binary-tree/binary-tree.d.ts +12 -26
- package/dist/data-structures/binary-tree/binary-tree.js +12 -27
- package/dist/data-structures/binary-tree/bst.d.ts +66 -90
- package/dist/data-structures/binary-tree/bst.js +85 -163
- package/dist/data-structures/binary-tree/rb-tree.d.ts +6 -17
- package/dist/data-structures/binary-tree/rb-tree.js +5 -17
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +187 -18
- package/dist/data-structures/binary-tree/tree-multiset.js +716 -39
- package/dist/data-structures/graph/abstract-graph.d.ts +112 -52
- package/dist/data-structures/graph/abstract-graph.js +138 -72
- package/dist/data-structures/graph/directed-graph.d.ts +104 -101
- package/dist/data-structures/graph/directed-graph.js +134 -129
- package/dist/data-structures/graph/undirected-graph.d.ts +66 -65
- package/dist/data-structures/graph/undirected-graph.js +107 -106
- package/dist/data-structures/interfaces/abstract-binary-tree.d.ts +12 -18
- package/dist/data-structures/interfaces/abstract-graph.d.ts +2 -4
- package/dist/data-structures/interfaces/avl-tree.d.ts +2 -2
- package/dist/data-structures/interfaces/binary-tree.d.ts +1 -1
- package/dist/data-structures/interfaces/bst.d.ts +4 -5
- package/dist/data-structures/interfaces/rb-tree.d.ts +2 -3
- package/dist/data-structures/interfaces/tree-multiset.d.ts +7 -1
- package/dist/data-structures/tree/tree.d.ts +1 -4
- package/dist/data-structures/tree/tree.js +1 -12
- package/dist/data-structures/types/abstract-binary-tree.d.ts +10 -6
- package/dist/data-structures/types/abstract-binary-tree.js +9 -5
- package/dist/data-structures/types/avl-tree.d.ts +1 -1
- package/dist/data-structures/types/binary-tree.d.ts +1 -1
- package/dist/data-structures/types/bst.d.ts +1 -1
- package/dist/data-structures/types/bst.js +1 -1
- package/dist/data-structures/types/directed-graph.js +1 -1
- package/dist/data-structures/types/helpers.d.ts +1 -8
- package/dist/data-structures/types/rb-tree.d.ts +2 -0
- package/dist/data-structures/types/rb-tree.js +1 -1
- package/dist/data-structures/types/tree-multiset.d.ts +5 -5
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/types/index.d.ts +1 -0
- package/dist/utils/types/index.js +1 -0
- package/dist/utils/types/validate-type.d.ts +19 -0
- package/dist/utils/types/validate-type.js +2 -0
- package/dist/utils/utils.d.ts +2 -2
- package/dist/utils/utils.js +0 -62
- package/dist/utils/validate-type.d.ts +45 -0
- package/dist/utils/validate-type.js +58 -0
- package/package.json +5 -2
- package/backup/recursive-type/src/assets/complexities-diff.jpg +0 -0
- package/backup/recursive-type/src/assets/data-structure-complexities.jpg +0 -0
- package/backup/recursive-type/src/assets/logo.png +0 -0
- package/backup/recursive-type/src/assets/overview-diagram-of-data-structures.png +0 -0
- package/backup/recursive-type/src/data-structures/binary-tree/aa-tree.ts +0 -3
- package/backup/recursive-type/src/data-structures/binary-tree/avl-tree.ts +0 -288
- package/backup/recursive-type/src/data-structures/binary-tree/b-tree.ts +0 -3
- package/backup/recursive-type/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -78
- package/backup/recursive-type/src/data-structures/binary-tree/binary-tree.ts +0 -1502
- package/backup/recursive-type/src/data-structures/binary-tree/bst.ts +0 -503
- package/backup/recursive-type/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
- package/backup/recursive-type/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
- package/backup/recursive-type/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
- package/backup/recursive-type/src/data-structures/binary-tree/index.ts +0 -11
- package/backup/recursive-type/src/data-structures/binary-tree/rb-tree.ts +0 -110
- package/backup/recursive-type/src/data-structures/binary-tree/segment-tree.ts +0 -243
- package/backup/recursive-type/src/data-structures/binary-tree/splay-tree.ts +0 -3
- package/backup/recursive-type/src/data-structures/binary-tree/tree-multiset.ts +0 -55
- package/backup/recursive-type/src/data-structures/binary-tree/two-three-tree.ts +0 -3
- package/backup/recursive-type/src/data-structures/diagrams/README.md +0 -5
- package/backup/recursive-type/src/data-structures/graph/abstract-graph.ts +0 -985
- package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-list.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-matrix.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/dfs-can-do.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/edge-list-pros-cons.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/edge-list.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/max-flow.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/mst.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan.webp +0 -0
- package/backup/recursive-type/src/data-structures/graph/directed-graph.ts +0 -478
- package/backup/recursive-type/src/data-structures/graph/index.ts +0 -3
- package/backup/recursive-type/src/data-structures/graph/undirected-graph.ts +0 -293
- package/backup/recursive-type/src/data-structures/hash/coordinate-map.ts +0 -67
- package/backup/recursive-type/src/data-structures/hash/coordinate-set.ts +0 -56
- package/backup/recursive-type/src/data-structures/hash/hash-table.ts +0 -3
- package/backup/recursive-type/src/data-structures/hash/index.ts +0 -6
- package/backup/recursive-type/src/data-structures/hash/pair.ts +0 -3
- package/backup/recursive-type/src/data-structures/hash/tree-map.ts +0 -3
- package/backup/recursive-type/src/data-structures/hash/tree-set.ts +0 -3
- package/backup/recursive-type/src/data-structures/heap/heap.ts +0 -176
- package/backup/recursive-type/src/data-structures/heap/index.ts +0 -3
- package/backup/recursive-type/src/data-structures/heap/max-heap.ts +0 -31
- package/backup/recursive-type/src/data-structures/heap/min-heap.ts +0 -34
- package/backup/recursive-type/src/data-structures/index.ts +0 -15
- package/backup/recursive-type/src/data-structures/interfaces/abstract-graph.ts +0 -42
- package/backup/recursive-type/src/data-structures/interfaces/avl-tree.ts +0 -1
- package/backup/recursive-type/src/data-structures/interfaces/binary-tree.ts +0 -56
- package/backup/recursive-type/src/data-structures/interfaces/bst.ts +0 -1
- package/backup/recursive-type/src/data-structures/interfaces/directed-graph.ts +0 -15
- package/backup/recursive-type/src/data-structures/interfaces/doubly-linked-list.ts +0 -1
- package/backup/recursive-type/src/data-structures/interfaces/heap.ts +0 -1
- package/backup/recursive-type/src/data-structures/interfaces/index.ts +0 -13
- package/backup/recursive-type/src/data-structures/interfaces/navigator.ts +0 -1
- package/backup/recursive-type/src/data-structures/interfaces/priority-queue.ts +0 -1
- package/backup/recursive-type/src/data-structures/interfaces/segment-tree.ts +0 -1
- package/backup/recursive-type/src/data-structures/interfaces/singly-linked-list.ts +0 -1
- package/backup/recursive-type/src/data-structures/interfaces/tree-multiset.ts +0 -1
- package/backup/recursive-type/src/data-structures/interfaces/undirected-graph.ts +0 -3
- package/backup/recursive-type/src/data-structures/linked-list/doubly-linked-list.ts +0 -573
- package/backup/recursive-type/src/data-structures/linked-list/index.ts +0 -3
- package/backup/recursive-type/src/data-structures/linked-list/singly-linked-list.ts +0 -490
- package/backup/recursive-type/src/data-structures/linked-list/skip-linked-list.ts +0 -3
- package/backup/recursive-type/src/data-structures/matrix/index.ts +0 -4
- package/backup/recursive-type/src/data-structures/matrix/matrix.ts +0 -27
- package/backup/recursive-type/src/data-structures/matrix/matrix2d.ts +0 -208
- package/backup/recursive-type/src/data-structures/matrix/navigator.ts +0 -122
- package/backup/recursive-type/src/data-structures/matrix/vector2d.ts +0 -316
- package/backup/recursive-type/src/data-structures/priority-queue/index.ts +0 -3
- package/backup/recursive-type/src/data-structures/priority-queue/max-priority-queue.ts +0 -49
- package/backup/recursive-type/src/data-structures/priority-queue/min-priority-queue.ts +0 -50
- package/backup/recursive-type/src/data-structures/priority-queue/priority-queue.ts +0 -354
- package/backup/recursive-type/src/data-structures/queue/deque.ts +0 -251
- package/backup/recursive-type/src/data-structures/queue/index.ts +0 -2
- package/backup/recursive-type/src/data-structures/queue/queue.ts +0 -120
- package/backup/recursive-type/src/data-structures/stack/index.ts +0 -1
- package/backup/recursive-type/src/data-structures/stack/stack.ts +0 -98
- package/backup/recursive-type/src/data-structures/tree/index.ts +0 -1
- package/backup/recursive-type/src/data-structures/tree/tree.ts +0 -80
- package/backup/recursive-type/src/data-structures/trie/index.ts +0 -1
- package/backup/recursive-type/src/data-structures/trie/trie.ts +0 -227
- package/backup/recursive-type/src/data-structures/types/abstract-graph.ts +0 -5
- package/backup/recursive-type/src/data-structures/types/avl-tree.ts +0 -8
- package/backup/recursive-type/src/data-structures/types/binary-tree.ts +0 -10
- package/backup/recursive-type/src/data-structures/types/bst.ts +0 -6
- package/backup/recursive-type/src/data-structures/types/directed-graph.ts +0 -8
- package/backup/recursive-type/src/data-structures/types/doubly-linked-list.ts +0 -1
- package/backup/recursive-type/src/data-structures/types/heap.ts +0 -5
- package/backup/recursive-type/src/data-structures/types/index.ts +0 -12
- package/backup/recursive-type/src/data-structures/types/navigator.ts +0 -13
- package/backup/recursive-type/src/data-structures/types/priority-queue.ts +0 -9
- package/backup/recursive-type/src/data-structures/types/segment-tree.ts +0 -1
- package/backup/recursive-type/src/data-structures/types/singly-linked-list.ts +0 -1
- package/backup/recursive-type/src/data-structures/types/tree-multiset.ts +0 -1
- package/backup/recursive-type/src/index.ts +0 -1
- package/backup/recursive-type/src/utils/index.ts +0 -2
- package/backup/recursive-type/src/utils/types/index.ts +0 -1
- package/backup/recursive-type/src/utils/types/utils.ts +0 -6
- package/backup/recursive-type/src/utils/utils.ts +0 -78
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -92
- 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 -2451
- package/docs/classes/AVLTreeNode.html +0 -499
- package/docs/classes/AaTree.html +0 -172
- package/docs/classes/AbstractBinaryTree.html +0 -2118
- package/docs/classes/AbstractBinaryTreeNode.html +0 -524
- package/docs/classes/AbstractEdge.html +0 -295
- package/docs/classes/AbstractGraph.html +0 -1043
- package/docs/classes/AbstractVertex.html +0 -258
- package/docs/classes/ArrayDeque.html +0 -439
- package/docs/classes/BST.html +0 -2297
- package/docs/classes/BSTNode.html +0 -503
- package/docs/classes/BTree.html +0 -172
- package/docs/classes/BinaryIndexedTree.html +0 -341
- package/docs/classes/BinaryTree.html +0 -2133
- package/docs/classes/BinaryTreeNode.html +0 -501
- package/docs/classes/Character.html +0 -220
- package/docs/classes/CoordinateMap.html +0 -483
- package/docs/classes/CoordinateSet.html +0 -444
- package/docs/classes/Deque.html +0 -975
- package/docs/classes/DirectedEdge.html +0 -366
- package/docs/classes/DirectedGraph.html +0 -1443
- package/docs/classes/DirectedVertex.html +0 -254
- package/docs/classes/DoublyLinkedList.html +0 -968
- package/docs/classes/DoublyLinkedListNode.html +0 -297
- package/docs/classes/HashTable.html +0 -172
- package/docs/classes/Heap.html +0 -423
- package/docs/classes/HeapItem.html +0 -255
- package/docs/classes/Matrix2D.html +0 -502
- package/docs/classes/MatrixNTI2D.html +0 -240
- package/docs/classes/MaxHeap.html +0 -436
- package/docs/classes/MaxPriorityQueue.html +0 -836
- package/docs/classes/MinHeap.html +0 -437
- package/docs/classes/MinPriorityQueue.html +0 -838
- package/docs/classes/Navigator.html +0 -313
- package/docs/classes/ObjectDeque.html +0 -455
- package/docs/classes/Pair.html +0 -172
- package/docs/classes/PriorityQueue.html +0 -760
- package/docs/classes/Queue.html +0 -392
- package/docs/classes/RBTree.html +0 -2388
- package/docs/classes/RBTreeNode.html +0 -516
- package/docs/classes/SegmentTree.html +0 -434
- package/docs/classes/SegmentTreeNode.html +0 -357
- package/docs/classes/SinglyLinkedList.html +0 -788
- package/docs/classes/SinglyLinkedListNode.html +0 -270
- package/docs/classes/SkipLinkedList.html +0 -172
- package/docs/classes/SplayTree.html +0 -172
- package/docs/classes/Stack.html +0 -368
- package/docs/classes/TreeMap.html +0 -172
- package/docs/classes/TreeMultiSet.html +0 -2297
- package/docs/classes/TreeMultiSetNode.html +0 -499
- package/docs/classes/TreeNode.html +0 -343
- package/docs/classes/TreeSet.html +0 -172
- package/docs/classes/Trie.html +0 -372
- package/docs/classes/TrieNode.html +0 -280
- package/docs/classes/TwoThreeTree.html +0 -172
- package/docs/classes/UndirectedEdge.html +0 -337
- package/docs/classes/UndirectedGraph.html +0 -1210
- package/docs/classes/UndirectedVertex.html +0 -254
- package/docs/classes/Vector2D.html +0 -805
- package/docs/enums/CP.html +0 -181
- package/docs/enums/FamilyPosition.html +0 -181
- package/docs/enums/LoopType.html +0 -182
- package/docs/enums/RBColor.html +0 -174
- package/docs/enums/TopologicalProperty.html +0 -181
- package/docs/index.html +0 -645
- package/docs/interfaces/IAVLTree.html +0 -1378
- package/docs/interfaces/IAVLTreeNode.html +0 -405
- package/docs/interfaces/IAbstractBinaryTree.html +0 -1124
- package/docs/interfaces/IAbstractBinaryTreeNode.html +0 -384
- package/docs/interfaces/IAbstractGraph.html +0 -433
- package/docs/interfaces/IBST.html +0 -1271
- package/docs/interfaces/IBSTNode.html +0 -408
- package/docs/interfaces/IDirectedGraph.html +0 -572
- package/docs/interfaces/IUNDirectedGraph.html +0 -465
- package/docs/modules.html +0 -262
- package/docs/types/AVLTreeOptions.html +0 -150
- package/docs/types/AbstractBinaryTreeNodeProperties.html +0 -152
- package/docs/types/AbstractBinaryTreeNodeProperty.html +0 -152
- package/docs/types/AbstractBinaryTreeOptions.html +0 -156
- package/docs/types/AbstractRecursiveBinaryTreeNode.html +0 -152
- package/docs/types/BSTComparator.html +0 -162
- package/docs/types/BSTOptions.html +0 -152
- package/docs/types/BinaryTreeDeletedResult.html +0 -159
- package/docs/types/BinaryTreeNodeId.html +0 -147
- package/docs/types/BinaryTreeNodePropertyName.html +0 -147
- package/docs/types/BinaryTreeOptions.html +0 -150
- package/docs/types/DFSOrderPattern.html +0 -147
- package/docs/types/DijkstraResult.html +0 -167
- package/docs/types/Direction.html +0 -147
- package/docs/types/EdgeId.html +0 -147
- package/docs/types/HeapOptions.html +0 -168
- package/docs/types/IdObject.html +0 -157
- package/docs/types/KeyValObject.html +0 -152
- package/docs/types/NavigatorParams.html +0 -181
- package/docs/types/NodeOrPropertyName.html +0 -147
- package/docs/types/PriorityQueueComparator.html +0 -167
- package/docs/types/PriorityQueueDFSOrderPattern.html +0 -147
- package/docs/types/PriorityQueueOptions.html +0 -161
- package/docs/types/RBTreeOptions.html +0 -150
- package/docs/types/RecursiveAVLTreeNode.html +0 -152
- package/docs/types/RecursiveBSTNode.html +0 -152
- package/docs/types/RecursiveBinaryTreeNode.html +0 -152
- package/docs/types/RecursiveTreeMultiSetNode.html +0 -152
- package/docs/types/SegmentTreeNodeVal.html +0 -147
- package/docs/types/TopologicalStatus.html +0 -147
- package/docs/types/TreeMultiSetOptions.html +0 -152
- package/docs/types/Turning.html +0 -147
- package/docs/types/VertexId.html +0 -147
- package/notes/bst.test.ts +0 -181
- package/notes/note.md +0 -34
|
@@ -5,27 +5,39 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
import type { BinaryTreeNodeId, TreeMultisetNodeNested, TreeMultisetOptions } from '../types';
|
|
9
|
+
import { BinaryTreeDeletedResult, DFSOrderPattern, NodeOrPropertyName } from '../types';
|
|
10
|
+
import { ITreeMultiset, ITreeMultisetNode } from '../interfaces';
|
|
11
|
+
import { AVLTree, AVLTreeNode } from './avl-tree';
|
|
12
|
+
export declare class TreeMultisetNode<T = any, NEIGHBOR extends TreeMultisetNode<T, NEIGHBOR> = TreeMultisetNodeNested<T>> extends AVLTreeNode<T, NEIGHBOR> implements ITreeMultisetNode<T, NEIGHBOR> {
|
|
13
|
+
/**
|
|
14
|
+
* The constructor function initializes a BinaryTreeNode object with an id, value, and count.
|
|
15
|
+
* @param {BinaryTreeNodeId} id - The `id` parameter is of type `BinaryTreeNodeId` and represents the unique identifier
|
|
16
|
+
* of the binary tree node.
|
|
17
|
+
* @param {T} [val] - The `val` parameter is an optional parameter of type `T`. It represents the value of the binary
|
|
18
|
+
* tree node. If no value is provided, it will be `undefined`.
|
|
19
|
+
* @param {number} [count=1] - The `count` parameter is a number that represents the number of times a particular value
|
|
20
|
+
* occurs in a binary tree node. It has a default value of 1, which means that if no value is provided for the `count`
|
|
21
|
+
* parameter when creating a new instance of the `BinaryTreeNode` class,
|
|
22
|
+
*/
|
|
23
|
+
constructor(id: BinaryTreeNodeId, val?: T, count?: number);
|
|
24
|
+
private _count;
|
|
25
|
+
get count(): number;
|
|
26
|
+
set count(v: number);
|
|
23
27
|
}
|
|
24
28
|
/**
|
|
25
|
-
* The only distinction between a
|
|
29
|
+
* The only distinction between a TreeMultiset and a AVLTree lies in the ability of the former to store duplicate nodes through the utilization of counters.
|
|
26
30
|
*/
|
|
27
|
-
export declare class
|
|
28
|
-
|
|
31
|
+
export declare class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultisetNode> extends AVLTree<N> implements ITreeMultiset<N> {
|
|
32
|
+
/**
|
|
33
|
+
* The constructor function for a TreeMultiset class in TypeScript, which extends another class and sets an option to
|
|
34
|
+
* merge duplicated values.
|
|
35
|
+
* @param {TreeMultisetOptions} [options] - An optional object that contains additional configuration options for the
|
|
36
|
+
* TreeMultiset.
|
|
37
|
+
*/
|
|
38
|
+
constructor(options?: TreeMultisetOptions);
|
|
39
|
+
private _count;
|
|
40
|
+
get count(): number;
|
|
29
41
|
/**
|
|
30
42
|
* The function creates a new BSTNode with the given id, value, and count.
|
|
31
43
|
* @param {BinaryTreeNodeId} id - The id parameter is the unique identifier for the binary tree node. It is used to
|
|
@@ -36,4 +48,161 @@ export declare class TreeMultiSet<N extends BSTNode<N['val'], N> = BSTNode<numbe
|
|
|
36
48
|
* @returns A new instance of the BSTNode class with the specified id, value, and count (if provided).
|
|
37
49
|
*/
|
|
38
50
|
createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N;
|
|
51
|
+
/**
|
|
52
|
+
* The function swaps the location of two nodes in a tree data structure.
|
|
53
|
+
* @param {N} srcNode - The source node that we want to swap with the destination node.
|
|
54
|
+
* @param {N} destNode - The `destNode` parameter represents the destination node where the values from `srcNode` will
|
|
55
|
+
* be swapped with.
|
|
56
|
+
* @returns the `destNode` after swapping its values with the `srcNode`.
|
|
57
|
+
*/
|
|
58
|
+
swapLocation(srcNode: N, destNode: N): N;
|
|
59
|
+
/**
|
|
60
|
+
* The `add` function adds a new node to a binary tree, updating the size and count properties accordingly, and
|
|
61
|
+
* balancing the tree if necessary.
|
|
62
|
+
* @param {BinaryTreeNodeId} id - The id parameter represents the identifier of the binary tree node that we want to
|
|
63
|
+
* add. It is of type BinaryTreeNodeId.
|
|
64
|
+
* @param [val] - The `val` parameter is an optional value that can be assigned to the node being added. If no value is
|
|
65
|
+
* provided, it will default to `undefined`.
|
|
66
|
+
* @param {number} [count] - The `count` parameter is an optional parameter that specifies the number of times the node
|
|
67
|
+
* with the given `id` should be added to the binary tree. If the `count` parameter is not provided, it defaults to 1.
|
|
68
|
+
* @returns The `add` method returns the inserted node (`N`), `null`, or `undefined`.
|
|
69
|
+
*/
|
|
70
|
+
add(id: BinaryTreeNodeId, val?: N['val'], count?: number): N | null | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* The function adds a new node to a binary tree as the left or right child of a given parent node.
|
|
73
|
+
* @param {N | null} newNode - The `newNode` parameter represents the node that you want to add to the tree. It can be
|
|
74
|
+
* either a node object (`N`) or `null`.
|
|
75
|
+
* @param {N} parent - The `parent` parameter represents the parent node to which the new node will be added as a
|
|
76
|
+
* child.
|
|
77
|
+
* @returns either the left or right child node that was added to the parent node. It can also return `null` or
|
|
78
|
+
* `undefined` in certain cases.
|
|
79
|
+
*/
|
|
80
|
+
addTo(newNode: N | null, parent: N): N | null | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* The `addMany` function inserts multiple items into a binary tree and returns an array of the inserted nodes or
|
|
83
|
+
* null/undefined values.
|
|
84
|
+
* @param {N[] | N[]} data - The `data` parameter can be either an array of elements of type `N` or an
|
|
85
|
+
* array of `N` objects.
|
|
86
|
+
* @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
|
|
87
|
+
*/
|
|
88
|
+
addMany(data: N[] | Array<N['val']>): (N | null | undefined)[];
|
|
89
|
+
/**
|
|
90
|
+
* The `remove` function removes a node from a binary search tree and returns the deleted node along with the parent
|
|
91
|
+
* node that needs to be balanced.
|
|
92
|
+
* @param {N | BinaryTreeNodeId | null} nodeOrId - The `nodeOrId` parameter can be one of the following:
|
|
93
|
+
* @param {boolean} [ignoreCount] - The `ignoreCount` parameter is an optional boolean parameter that determines
|
|
94
|
+
* whether to ignore the count of the node being removed. If `ignoreCount` is set to `true`, the count of the node will
|
|
95
|
+
* not be taken into account when removing it. If `ignoreCount` is set to `false
|
|
96
|
+
* @returns The function `remove` returns an array of `BinaryTreeDeletedResult<N>` objects.
|
|
97
|
+
*/
|
|
98
|
+
remove(nodeOrId: N | BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
|
|
99
|
+
/**
|
|
100
|
+
* The function `getSubTreeCount` calculates the number of nodes and the sum of their counts in a subtree, using either
|
|
101
|
+
* recursive or iterative traversal.
|
|
102
|
+
* @param {N | null | undefined} subTreeRoot - The `subTreeRoot` parameter represents the root node of a subtree in a
|
|
103
|
+
* binary tree.
|
|
104
|
+
* @returns The function `getSubTreeCount` returns an array `[number, number]`.
|
|
105
|
+
*/
|
|
106
|
+
getSubTreeCount(subTreeRoot: N | null | undefined): [number, number];
|
|
107
|
+
/**
|
|
108
|
+
* The function `subTreeSumCount` calculates the sum of the `count` property of each node in a subtree, either
|
|
109
|
+
* recursively or iteratively.
|
|
110
|
+
* @param {N | BinaryTreeNodeId | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a subtree
|
|
111
|
+
* in a binary tree. It can be either a `BinaryTreeNodeId` (a unique identifier for a node in the binary tree) or
|
|
112
|
+
* `null` if the subtree is empty.
|
|
113
|
+
* @returns the sum of the count values of all nodes in the subtree rooted at `subTreeRoot`.
|
|
114
|
+
*/
|
|
115
|
+
subTreeSumCount(subTreeRoot: N | BinaryTreeNodeId | null): number;
|
|
116
|
+
/**
|
|
117
|
+
* The function `subTreeAddCount` recursively or iteratively traverses a binary tree and adds a given delta value to
|
|
118
|
+
* the `count` property of each node.
|
|
119
|
+
* @param {N | BinaryTreeNodeId | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a subtree
|
|
120
|
+
* in a binary tree. It can be either a `BinaryTreeNodeId` (a unique identifier for a node in the binary tree), a
|
|
121
|
+
* `BinaryTreeNode` object, or `null` if the subtree is empty.
|
|
122
|
+
* @param {number} delta - The delta parameter is a number that represents the amount by which the count of each node
|
|
123
|
+
* in the subtree should be increased or decreased.
|
|
124
|
+
* @returns a boolean value.
|
|
125
|
+
*/
|
|
126
|
+
subTreeAddCount(subTreeRoot: N | BinaryTreeNodeId | null, delta: number): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* The function `getNodesByCount` returns an array of nodes that have a specific count property, either recursively or
|
|
129
|
+
* using a queue.
|
|
130
|
+
* @param {BinaryTreeNodeId | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or a
|
|
131
|
+
* `N`. It represents the property of the nodes that you want to search for.
|
|
132
|
+
* @param {boolean} [onlyOne] - The `onlyOne` parameter is an optional boolean parameter that determines whether to
|
|
133
|
+
* return only one node that matches the `nodeProperty` or all nodes that match the `nodeProperty`. If `onlyOne` is set
|
|
134
|
+
* to `true`, the function will return only one node. If `onlyOne`
|
|
135
|
+
* @returns an array of nodes that match the given nodeProperty.
|
|
136
|
+
*/
|
|
137
|
+
getNodesByCount(nodeProperty: BinaryTreeNodeId | N, onlyOne?: boolean): N[];
|
|
138
|
+
/**
|
|
139
|
+
* The BFSCount function returns an array of counts from a breadth-first search of nodes.
|
|
140
|
+
* @returns The BFSCount() function returns an array of numbers, specifically the count property of each node in the
|
|
141
|
+
* BFS traversal.
|
|
142
|
+
*/
|
|
143
|
+
BFSCount(): number[];
|
|
144
|
+
/**
|
|
145
|
+
* The function "listLevelsCount" takes a node and returns an array of arrays, where each inner array contains the
|
|
146
|
+
* count property of each node at that level.
|
|
147
|
+
* @param {N | null} node - The parameter `node` is of type `N | null`. This means that it can either be an instance of
|
|
148
|
+
* the class `N` or `null`.
|
|
149
|
+
* @returns a 2D array of numbers. Each inner array represents a level in the binary tree, and each number in the inner
|
|
150
|
+
* array represents the count property of a node in that level.
|
|
151
|
+
*/
|
|
152
|
+
listLevelsCount(node: N | null): number[][];
|
|
153
|
+
/**
|
|
154
|
+
* The `morrisCount` function returns an array of counts for each node in a binary tree, based on a specified traversal
|
|
155
|
+
* pattern.
|
|
156
|
+
* @param {'in' | 'pre' | 'post'} [pattern] - The `pattern` parameter is an optional parameter that specifies the
|
|
157
|
+
* traversal pattern for the Morris traversal algorithm. It can have one of three values: 'in', 'pre', or 'post'.
|
|
158
|
+
* @returns The function `morrisCount` returns an array of numbers.
|
|
159
|
+
*/
|
|
160
|
+
morrisCount(pattern?: 'in' | 'pre' | 'post'): number[];
|
|
161
|
+
/**
|
|
162
|
+
* The function DFSIterativeCount performs a depth-first search iteratively and returns an array of count values for
|
|
163
|
+
* each node.
|
|
164
|
+
* @param {'in' | 'pre' | 'post'} [pattern] - The "pattern" parameter is a string that specifies the traversal order
|
|
165
|
+
* for the Depth-First Search (DFS) algorithm. It can have one of three values: 'in', 'pre', or 'post'.
|
|
166
|
+
* @param {NodeOrPropertyName} [nodeOrPropertyName] - The `nodeOrPropertyName` parameter is an optional parameter that
|
|
167
|
+
* specifies whether to return the nodes or the property names during the depth-first search traversal. If it is set to
|
|
168
|
+
* `'node'`, the function will return the nodes. If it is set to `'property'`, the function will return the property
|
|
169
|
+
* @returns The DFSIterativeCount method returns an array of numbers.
|
|
170
|
+
*/
|
|
171
|
+
DFSIterativeCount(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): number[];
|
|
172
|
+
/**
|
|
173
|
+
* The DFSCount function returns an array of counts for each node in a depth-first search traversal.
|
|
174
|
+
* @param {DFSOrderPattern} [pattern] - The `pattern` parameter is an optional parameter that specifies the order in
|
|
175
|
+
* which the Depth-First Search (DFS) algorithm should traverse the nodes. It can have one of the following values:
|
|
176
|
+
* @param [nodeOrPropertyName] - The parameter `nodeOrPropertyName` is used to specify whether you want to retrieve the
|
|
177
|
+
* nodes themselves or a specific property of the nodes. If you pass `'count'` as the value for `nodeOrPropertyName`,
|
|
178
|
+
* the function will return an array of the `count` property of each node.
|
|
179
|
+
* @returns The DFSCount method returns an array of numbers representing the count property of each node in the DFS
|
|
180
|
+
* traversal.
|
|
181
|
+
*/
|
|
182
|
+
DFSCount(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
|
|
183
|
+
/**
|
|
184
|
+
* The `lesserSumCount` function calculates the sum of the counts of all nodes in a binary tree that have a lesser
|
|
185
|
+
* value than a given node.
|
|
186
|
+
* @param {N | BinaryTreeNodeId | null} beginNode - The `beginNode` parameter can be one of the following:
|
|
187
|
+
* @returns the sum of the counts of nodes in the binary tree that have a lesser value than the given beginNode.
|
|
188
|
+
*/
|
|
189
|
+
lesserSumCount(beginNode: N | BinaryTreeNodeId | null): number;
|
|
190
|
+
/**
|
|
191
|
+
* The function `allGreaterNodesAddCount` updates the count property of all nodes in a binary tree that have an ID
|
|
192
|
+
* greater than a given ID by a specified delta value.
|
|
193
|
+
* @param {N | BinaryTreeNodeId | null} node - The `node` parameter can be one of the following:
|
|
194
|
+
* @param {number} delta - The `delta` parameter is a number that represents the amount by which the `count` property
|
|
195
|
+
* of each node should be increased.
|
|
196
|
+
* @returns a boolean value.
|
|
197
|
+
*/
|
|
198
|
+
allGreaterNodesAddCount(node: N | BinaryTreeNodeId | null, delta: number): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* The clear() function clears the data and sets the count to 0.
|
|
201
|
+
*/
|
|
202
|
+
clear(): void;
|
|
203
|
+
/**
|
|
204
|
+
* The function "_setCount" is used to set the value of the "_count" property.
|
|
205
|
+
* @param {number} v - number
|
|
206
|
+
*/
|
|
207
|
+
protected _setCount(v: number): void;
|
|
39
208
|
}
|