data-structure-typed 1.18.7 → 1.18.8
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 +154 -366
- package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +29 -32
- package/dist/data-structures/binary-tree/abstract-binary-tree.js +179 -136
- package/dist/data-structures/binary-tree/avl-tree.d.ts +4 -4
- package/dist/data-structures/binary-tree/avl-tree.js +2 -2
- package/dist/data-structures/binary-tree/binary-tree.d.ts +3 -3
- package/dist/data-structures/binary-tree/binary-tree.js +4 -4
- package/dist/data-structures/binary-tree/bst.d.ts +13 -25
- package/dist/data-structures/binary-tree/bst.js +20 -74
- package/dist/data-structures/binary-tree/rb-tree.d.ts +6 -6
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +6 -6
- package/dist/data-structures/binary-tree/tree-multiset.js +7 -14
- package/dist/data-structures/graph/abstract-graph.d.ts +11 -9
- package/dist/data-structures/graph/abstract-graph.js +39 -22
- package/dist/data-structures/graph/directed-graph.d.ts +17 -15
- package/dist/data-structures/graph/directed-graph.js +47 -42
- package/dist/data-structures/graph/undirected-graph.d.ts +7 -7
- package/dist/data-structures/graph/undirected-graph.js +48 -48
- package/dist/data-structures/interfaces/abstract-binary-tree.d.ts +2 -3
- package/dist/data-structures/interfaces/abstract-graph.d.ts +2 -4
- package/dist/data-structures/interfaces/avl-tree.d.ts +1 -1
- package/dist/data-structures/interfaces/bst.d.ts +2 -2
- package/dist/data-structures/interfaces/rb-tree.d.ts +2 -2
- 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 +9 -5
- 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 +4 -4
- package/dist/utils/types/utils.d.ts +18 -0
- package/dist/utils/utils.d.ts +6 -1
- package/dist/utils/utils.js +21 -1
- package/package.json +2 -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,10 +5,10 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import type {
|
|
8
|
+
import type { AbstractBinaryTreeNodeNested, AbstractBinaryTreeNodeProperties, BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName, DFSOrderPattern, NodeOrPropertyName } from '../types';
|
|
9
9
|
import { AbstractBinaryTreeOptions, FamilyPosition, LoopType } from '../types';
|
|
10
10
|
import { IAbstractBinaryTree, IAbstractBinaryTreeNode } from '../interfaces';
|
|
11
|
-
export declare abstract class AbstractBinaryTreeNode<T =
|
|
11
|
+
export declare abstract class AbstractBinaryTreeNode<T = any, FAMILY extends AbstractBinaryTreeNode<T, FAMILY> = AbstractBinaryTreeNodeNested<T>> implements IAbstractBinaryTreeNode<T, FAMILY> {
|
|
12
12
|
/**
|
|
13
13
|
* The constructor function initializes a BinaryTreeNode object with an id, value, and count.
|
|
14
14
|
* @param {BinaryTreeNodeId} id - The `id` parameter is of type `BinaryTreeNodeId` and represents the unique identifier
|
|
@@ -34,22 +34,20 @@ export declare abstract class AbstractBinaryTreeNode<T = number, FAMILY extends
|
|
|
34
34
|
private _parent;
|
|
35
35
|
get parent(): FAMILY | null | undefined;
|
|
36
36
|
set parent(v: FAMILY | null | undefined);
|
|
37
|
-
private _familyPosition;
|
|
38
|
-
get familyPosition(): FamilyPosition;
|
|
39
|
-
set familyPosition(v: FamilyPosition);
|
|
40
37
|
private _count;
|
|
41
38
|
get count(): number;
|
|
42
39
|
set count(v: number);
|
|
43
40
|
private _height;
|
|
44
41
|
get height(): number;
|
|
45
42
|
set height(v: number);
|
|
43
|
+
get familyPosition(): FamilyPosition;
|
|
46
44
|
abstract createNode(id: BinaryTreeNodeId, val?: T, count?: number): FAMILY;
|
|
47
45
|
/**
|
|
48
46
|
* The function swaps the location of two nodes in a binary tree.
|
|
49
|
-
* @param {FAMILY}
|
|
47
|
+
* @param {FAMILY} destNode - The `swapNode` parameter is of type `FAMILY`, which represents a node in a family tree.
|
|
50
48
|
* @returns the `swapNode` object after swapping its properties with the properties of `this` object.
|
|
51
49
|
*/
|
|
52
|
-
swapLocation(
|
|
50
|
+
swapLocation(destNode: FAMILY): FAMILY;
|
|
53
51
|
/**
|
|
54
52
|
* The `clone` function returns a new instance of the `FAMILY` class with the same `id`, `val`, and `count` properties.
|
|
55
53
|
* @returns The `clone()` method is returning a new instance of the `FAMILY` class with the same `id`, `val`, and
|
|
@@ -57,7 +55,7 @@ export declare abstract class AbstractBinaryTreeNode<T = number, FAMILY extends
|
|
|
57
55
|
*/
|
|
58
56
|
clone(): FAMILY | null;
|
|
59
57
|
}
|
|
60
|
-
export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'], N> = AbstractBinaryTreeNode
|
|
58
|
+
export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'], N> = AbstractBinaryTreeNode> implements IAbstractBinaryTree<N> {
|
|
61
59
|
/**
|
|
62
60
|
* The protected constructor initializes the options for an abstract binary tree.
|
|
63
61
|
* @param {AbstractBinaryTreeOptions} [options] - An optional object that contains configuration options for the binary
|
|
@@ -80,15 +78,15 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
|
|
|
80
78
|
get autoIncrementId(): boolean;
|
|
81
79
|
private _maxId;
|
|
82
80
|
get maxId(): number;
|
|
83
|
-
private
|
|
84
|
-
get
|
|
81
|
+
private _isMergeDuplicatedVal;
|
|
82
|
+
get isMergeDuplicatedVal(): boolean;
|
|
85
83
|
private _root;
|
|
86
84
|
get root(): N | null;
|
|
87
85
|
private _size;
|
|
88
86
|
get size(): number;
|
|
89
87
|
private _count;
|
|
90
88
|
get count(): number;
|
|
91
|
-
abstract createNode(id: BinaryTreeNodeId, val
|
|
89
|
+
abstract createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N | null;
|
|
92
90
|
/**
|
|
93
91
|
* The clear function resets the state of an object by setting its properties to their initial values.
|
|
94
92
|
*/
|
|
@@ -137,24 +135,21 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
|
|
|
137
135
|
*/
|
|
138
136
|
fill(data: N[] | Array<N['val']>): boolean;
|
|
139
137
|
/**
|
|
140
|
-
* The function removes a node from a binary tree and returns
|
|
141
|
-
*
|
|
142
|
-
*
|
|
138
|
+
* The `remove` function removes a node from a binary search tree and returns the deleted node along with the parent
|
|
139
|
+
* node that needs to be balanced.
|
|
140
|
+
* @param {N | BinaryTreeNodeId | null} nodeOrId - The `nodeOrId` parameter can be one of the following:
|
|
143
141
|
* @param {boolean} [ignoreCount] - The `ignoreCount` parameter is an optional boolean parameter that determines
|
|
144
142
|
* whether to ignore the count of the node being removed. If `ignoreCount` is set to `true`, the count of the node will
|
|
145
|
-
* not be
|
|
146
|
-
* @returns
|
|
147
|
-
* "needBalanced". The "deleted" property contains the deleted node or undefined if no node was deleted. The
|
|
148
|
-
* "needBalanced" property is always null.
|
|
143
|
+
* not be taken into account when removing it. If `ignoreCount` is set to `false
|
|
144
|
+
* @returns The function `remove` returns an array of `BinaryTreeDeletedResult<N>` objects.
|
|
149
145
|
*/
|
|
150
|
-
remove(
|
|
146
|
+
remove(nodeOrId: N | BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
|
|
151
147
|
/**
|
|
152
|
-
* The function calculates the depth of a
|
|
153
|
-
* @param
|
|
154
|
-
*
|
|
155
|
-
* @returns The depth of the given binary tree node.
|
|
148
|
+
* The function calculates the depth of a node in a binary tree.
|
|
149
|
+
* @param {N | BinaryTreeNodeId | null} beginRoot - The `beginRoot` parameter can be one of the following:
|
|
150
|
+
* @returns the depth of the given node or binary tree.
|
|
156
151
|
*/
|
|
157
|
-
getDepth(
|
|
152
|
+
getDepth(beginRoot: N | BinaryTreeNodeId | null): number;
|
|
158
153
|
/**
|
|
159
154
|
* The `getHeight` function calculates the maximum height of a binary tree using either a recursive or iterative
|
|
160
155
|
* approach.
|
|
@@ -163,7 +158,7 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
|
|
|
163
158
|
* If no value is provided for `beginRoot`, the function will use the `root` property of the class instance as
|
|
164
159
|
* @returns the height of the binary tree.
|
|
165
160
|
*/
|
|
166
|
-
getHeight(beginRoot?: N | null): number;
|
|
161
|
+
getHeight(beginRoot?: N | BinaryTreeNodeId | null): number;
|
|
167
162
|
/**
|
|
168
163
|
* The `getMinHeight` function calculates the minimum height of a binary tree using either a recursive or iterative
|
|
169
164
|
* approach.
|
|
@@ -257,17 +252,19 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
|
|
|
257
252
|
* provided, it defaults to `'val'`.
|
|
258
253
|
* @returns a number, which is the sum of the values of the nodes in the subtree rooted at `subTreeRoot`.
|
|
259
254
|
*/
|
|
260
|
-
subTreeSum(subTreeRoot: N, propertyName?: BinaryTreeNodePropertyName): number;
|
|
255
|
+
subTreeSum(subTreeRoot: N | BinaryTreeNodeId | null, propertyName?: BinaryTreeNodePropertyName): number;
|
|
261
256
|
/**
|
|
262
|
-
* The function `subTreeAdd` adds a
|
|
263
|
-
* @param subTreeRoot - The `subTreeRoot` parameter
|
|
257
|
+
* The function `subTreeAdd` adds a delta value to a specified property of each node in a subtree.
|
|
258
|
+
* @param {N | BinaryTreeNodeId | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a binary
|
|
259
|
+
* tree or the ID of a binary tree node. It can also be `null` if there is no subtree root.
|
|
264
260
|
* @param {number} delta - The `delta` parameter is a number that represents the amount by which the property value of
|
|
265
|
-
* each node in the subtree should be
|
|
261
|
+
* each node in the subtree should be incremented or decremented.
|
|
266
262
|
* @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
|
|
267
|
-
* specifies the property of the
|
|
268
|
-
*
|
|
263
|
+
* specifies the property of the binary tree node that should be modified. It can be either 'id' or 'count'. If no
|
|
264
|
+
* value is provided for `propertyName`, it defaults to 'id'.
|
|
265
|
+
* @returns a boolean value.
|
|
269
266
|
*/
|
|
270
|
-
subTreeAdd(subTreeRoot: N, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
|
|
267
|
+
subTreeAdd(subTreeRoot: N | BinaryTreeNodeId | null, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
|
|
271
268
|
BFS(): BinaryTreeNodeId[];
|
|
272
269
|
BFS(nodeOrPropertyName: 'id'): BinaryTreeNodeId[];
|
|
273
270
|
BFS(nodeOrPropertyName: 'val'): N['val'][];
|