red-black-tree-typed 1.53.7 → 1.54.2

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.
Files changed (119) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +52 -0
  3. package/dist/common/index.js +5 -0
  4. package/dist/data-structures/base/iterable-entry-base.js +4 -4
  5. package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +213 -0
  6. package/dist/data-structures/binary-tree/avl-tree-counter.js +407 -0
  7. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +71 -170
  8. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +133 -328
  9. package/dist/data-structures/binary-tree/avl-tree.d.ts +103 -69
  10. package/dist/data-structures/binary-tree/avl-tree.js +130 -70
  11. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -0
  12. package/dist/data-structures/binary-tree/binary-indexed-tree.js +3 -0
  13. package/dist/data-structures/binary-tree/binary-tree.d.ts +268 -202
  14. package/dist/data-structures/binary-tree/binary-tree.js +311 -263
  15. package/dist/data-structures/binary-tree/bst.d.ts +193 -139
  16. package/dist/data-structures/binary-tree/bst.js +248 -164
  17. package/dist/data-structures/binary-tree/index.d.ts +3 -1
  18. package/dist/data-structures/binary-tree/index.js +3 -1
  19. package/dist/data-structures/binary-tree/red-black-tree.d.ts +286 -0
  20. package/dist/data-structures/binary-tree/{rb-tree.js → red-black-tree.js} +176 -107
  21. package/dist/data-structures/binary-tree/tree-counter.d.ts +212 -0
  22. package/dist/data-structures/binary-tree/tree-counter.js +444 -0
  23. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +78 -170
  24. package/dist/data-structures/binary-tree/tree-multi-map.js +145 -367
  25. package/dist/data-structures/graph/abstract-graph.js +2 -2
  26. package/dist/data-structures/graph/directed-graph.d.ts +3 -0
  27. package/dist/data-structures/graph/directed-graph.js +3 -0
  28. package/dist/data-structures/graph/map-graph.d.ts +3 -0
  29. package/dist/data-structures/graph/map-graph.js +3 -0
  30. package/dist/data-structures/graph/undirected-graph.d.ts +3 -0
  31. package/dist/data-structures/graph/undirected-graph.js +3 -0
  32. package/dist/data-structures/hash/hash-map.d.ts +31 -1
  33. package/dist/data-structures/hash/hash-map.js +35 -5
  34. package/dist/data-structures/heap/heap.d.ts +20 -3
  35. package/dist/data-structures/heap/heap.js +31 -11
  36. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +46 -11
  37. package/dist/data-structures/linked-list/doubly-linked-list.js +68 -21
  38. package/dist/data-structures/linked-list/singly-linked-list.d.ts +47 -11
  39. package/dist/data-structures/linked-list/singly-linked-list.js +73 -26
  40. package/dist/data-structures/linked-list/skip-linked-list.d.ts +3 -0
  41. package/dist/data-structures/linked-list/skip-linked-list.js +3 -0
  42. package/dist/data-structures/matrix/matrix.d.ts +3 -0
  43. package/dist/data-structures/matrix/matrix.js +3 -0
  44. package/dist/data-structures/matrix/navigator.d.ts +3 -0
  45. package/dist/data-structures/matrix/navigator.js +3 -0
  46. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +3 -0
  47. package/dist/data-structures/priority-queue/max-priority-queue.js +3 -0
  48. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +3 -0
  49. package/dist/data-structures/priority-queue/min-priority-queue.js +3 -0
  50. package/dist/data-structures/queue/deque.d.ts +37 -8
  51. package/dist/data-structures/queue/deque.js +73 -29
  52. package/dist/data-structures/queue/queue.d.ts +41 -1
  53. package/dist/data-structures/queue/queue.js +51 -9
  54. package/dist/data-structures/stack/stack.d.ts +27 -10
  55. package/dist/data-structures/stack/stack.js +39 -20
  56. package/dist/data-structures/trie/trie.d.ts +8 -7
  57. package/dist/data-structures/trie/trie.js +8 -7
  58. package/dist/index.d.ts +4 -4
  59. package/dist/index.js +4 -4
  60. package/dist/interfaces/binary-tree.d.ts +8 -8
  61. package/dist/types/data-structures/base/base.d.ts +1 -1
  62. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  63. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -4
  64. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +0 -3
  65. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +0 -3
  66. package/dist/types/data-structures/binary-tree/bst.d.ts +4 -4
  67. package/dist/types/data-structures/binary-tree/index.d.ts +3 -1
  68. package/dist/types/data-structures/binary-tree/index.js +3 -1
  69. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
  70. package/dist/types/data-structures/binary-tree/red-black-tree.js +2 -0
  71. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  72. package/dist/types/data-structures/binary-tree/tree-counter.js +2 -0
  73. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -5
  74. package/package.json +3 -3
  75. package/src/common/index.ts +7 -1
  76. package/src/data-structures/base/iterable-entry-base.ts +4 -4
  77. package/src/data-structures/binary-tree/avl-tree-counter.ts +463 -0
  78. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +151 -370
  79. package/src/data-structures/binary-tree/avl-tree.ts +162 -105
  80. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -0
  81. package/src/data-structures/binary-tree/binary-tree.ts +488 -416
  82. package/src/data-structures/binary-tree/bst.ts +326 -251
  83. package/src/data-structures/binary-tree/index.ts +3 -1
  84. package/src/data-structures/binary-tree/{rb-tree.ts → red-black-tree.ts} +219 -145
  85. package/src/data-structures/binary-tree/tree-counter.ts +504 -0
  86. package/src/data-structures/binary-tree/tree-multi-map.ts +159 -401
  87. package/src/data-structures/graph/abstract-graph.ts +2 -2
  88. package/src/data-structures/graph/directed-graph.ts +3 -0
  89. package/src/data-structures/graph/map-graph.ts +3 -0
  90. package/src/data-structures/graph/undirected-graph.ts +3 -0
  91. package/src/data-structures/hash/hash-map.ts +37 -7
  92. package/src/data-structures/heap/heap.ts +33 -10
  93. package/src/data-structures/linked-list/doubly-linked-list.ts +75 -21
  94. package/src/data-structures/linked-list/singly-linked-list.ts +80 -27
  95. package/src/data-structures/linked-list/skip-linked-list.ts +3 -0
  96. package/src/data-structures/matrix/matrix.ts +3 -0
  97. package/src/data-structures/matrix/navigator.ts +3 -0
  98. package/src/data-structures/priority-queue/max-priority-queue.ts +3 -0
  99. package/src/data-structures/priority-queue/min-priority-queue.ts +3 -0
  100. package/src/data-structures/queue/deque.ts +72 -28
  101. package/src/data-structures/queue/queue.ts +50 -7
  102. package/src/data-structures/stack/stack.ts +39 -20
  103. package/src/data-structures/trie/trie.ts +8 -7
  104. package/src/index.ts +4 -4
  105. package/src/interfaces/binary-tree.ts +10 -21
  106. package/src/types/data-structures/base/base.ts +1 -1
  107. package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
  108. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -6
  109. package/src/types/data-structures/binary-tree/avl-tree.ts +0 -5
  110. package/src/types/data-structures/binary-tree/binary-tree.ts +0 -5
  111. package/src/types/data-structures/binary-tree/bst.ts +6 -6
  112. package/src/types/data-structures/binary-tree/index.ts +3 -1
  113. package/src/types/data-structures/binary-tree/red-black-tree.ts +5 -0
  114. package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
  115. package/src/types/data-structures/binary-tree/tree-multi-map.ts +2 -7
  116. package/dist/data-structures/binary-tree/rb-tree.d.ts +0 -209
  117. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +0 -6
  118. package/src/types/data-structures/binary-tree/rb-tree.ts +0 -10
  119. /package/dist/types/data-structures/binary-tree/{rb-tree.js → avl-tree-counter.js} +0 -0
@@ -6,30 +6,26 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import { BST, BSTNode } from './bst';
9
- import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep } from '../../types';
9
+ import type { AVLTreeOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback, OptNodeOrNull } from '../../types';
10
10
  import { IBinaryTree } from '../../interfaces';
11
- export declare class AVLTreeNode<K = any, V = any, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
11
+ export declare class AVLTreeNode<K = any, V = any> extends BSTNode<K, V> {
12
12
  /**
13
- * The constructor function initializes a new instance of a class with a key and an optional value,
14
- * and sets the height property to 0.
15
- * @param {K} key - The "key" parameter is of type K, which represents the type of the key for the
16
- * constructor. It is used to initialize the key property of the object being created.
17
- * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
18
- * value associated with the key in the constructor.
13
+ * This TypeScript constructor function initializes an instance with a key and an optional value.
14
+ * @param {K} key - The `key` parameter is typically used to uniquely identify an object or element
15
+ * within a data structure. It serves as a reference or identifier for accessing or manipulating the
16
+ * associated value or data.
17
+ * @param {V} [value] - The `value` parameter in the constructor is optional, meaning it does not
18
+ * have to be provided when creating an instance of the class. If a value is not provided, it will
19
+ * default to `undefined`.
19
20
  */
20
21
  constructor(key: K, value?: V);
21
- protected _height: number;
22
- /**
23
- * The function returns the value of the height property.
24
- * @returns The height of the object.
25
- */
26
- get height(): number;
27
- /**
28
- * The above function sets the value of the height property.
29
- * @param {number} value - The value parameter is a number that represents the new height value to be
30
- * set.
31
- */
32
- set height(value: number);
22
+ parent?: AVLTreeNode<K, V>;
23
+ _left?: OptNodeOrNull<AVLTreeNode<K, V>>;
24
+ get left(): OptNodeOrNull<AVLTreeNode<K, V>>;
25
+ set left(v: OptNodeOrNull<AVLTreeNode<K, V>>);
26
+ _right?: OptNodeOrNull<AVLTreeNode<K, V>>;
27
+ get right(): OptNodeOrNull<AVLTreeNode<K, V>>;
28
+ set right(v: OptNodeOrNull<AVLTreeNode<K, V>>);
33
29
  }
34
30
  /**
35
31
  * 1. Height-Balanced: Each node's left and right subtrees differ in height by no more than one.
@@ -40,161 +36,199 @@ export declare class AVLTreeNode<K = any, V = any, NODE extends AVLTreeNode<K, V
40
36
  * 6. Complex Insertions and Deletions: Due to rebalancing, these operations are more complex than in a regular BST.
41
37
  * 7. Path Length: The path length from the root to any leaf is longer compared to an unbalanced BST, but shorter than a linear chain of nodes.
42
38
  */
43
- export declare class AVLTree<K = any, V = any, R = object, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>, TREE extends AVLTree<K, V, R, NODE, TREE> = AVLTree<K, V, R, NODE, AVLTreeNested<K, V, R, NODE>>> extends BST<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
39
+ export declare class AVLTree<K = any, V = any, R = object, MK = any, MV = any, MR = object> extends BST<K, V, R, MK, MV, MR> implements IBinaryTree<K, V, R, MK, MV, MR> {
44
40
  /**
45
- * This is a constructor function for an AVLTree class that initializes the tree with keys, nodes,
46
- * entries, or raw elements.
47
- * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter is an
48
- * iterable object that can contain either keys, nodes, entries, or raw elements. These elements will
49
- * be used to initialize the AVLTree.
50
- * @param [options] - The `options` parameter is an optional object that can be used to customize the
51
- * behavior of the AVLTree. It can include properties such as `compareFn` (a function used to compare
52
- * keys), `allowDuplicates` (a boolean indicating whether duplicate keys are allowed), and
53
- * `nodeBuilder` (
41
+ * This TypeScript constructor initializes an AVLTree with keys, nodes, entries, or raw data provided
42
+ * in an iterable format.
43
+ * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
44
+ * iterable that can contain either `BTNRep<K, V, AVLTreeNode<K, V>>` objects or `R` objects. It is
45
+ * used to initialize the AVLTree with key-value pairs or raw data entries. If provided
46
+ * @param [options] - The `options` parameter in the constructor is of type `AVLTreeOptions<K, V,
47
+ * R>`. It is an optional parameter that allows you to specify additional options for configuring the
48
+ * AVL tree. These options could include things like custom comparators, initial capacity, or any
49
+ * other configuration settings specific
54
50
  */
55
- constructor(keysNodesEntriesOrRaws?: Iterable<R | BTNRep<K, V, NODE>>, options?: AVLTreeOptions<K, V, R>);
51
+ constructor(keysNodesEntriesOrRaws?: Iterable<BTNRep<K, V, AVLTreeNode<K, V>> | R>, options?: AVLTreeOptions<K, V, R>);
56
52
  /**
53
+ * Time Complexity: O(1)
54
+ * Space Complexity: O(1)
55
+ *
57
56
  * The function creates a new AVL tree node with the given key and value.
58
57
  * @param {K} key - The key parameter is of type K, which represents the key of the node being
59
58
  * created.
60
59
  * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
61
60
  * value associated with the key in the node being created.
62
61
  * @returns The method is returning a new instance of the AVLTreeNode class, casted as the generic
63
- * type NODE.
62
+ * type AVLTreeNode<K, V>.
64
63
  */
65
- createNode(key: K, value?: V): NODE;
64
+ createNode(key: K, value?: V): AVLTreeNode<K, V>;
66
65
  /**
66
+ * Time Complexity: O(1)
67
+ * Space Complexity: O(1)
68
+ *
67
69
  * The function creates a new AVL tree with the specified options and returns it.
68
70
  * @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be
69
71
  * passed to the `createTree` function. It is used to customize the behavior of the AVL tree that is
70
72
  * being created.
71
73
  * @returns a new AVLTree object.
72
74
  */
73
- createTree(options?: AVLTreeOptions<K, V, R>): TREE;
75
+ createTree(options?: AVLTreeOptions<K, V, R>): AVLTree<K, V, R, MK, MV, MR>;
74
76
  /**
77
+ * Time Complexity: O(1)
78
+ * Space Complexity: O(1)
79
+ *
75
80
  * The function checks if the input is an instance of AVLTreeNode.
76
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
77
- * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
78
- * @returns a boolean value indicating whether the input parameter `keyNodeEntryOrRaw` is
81
+ * @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The parameter
82
+ * `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, AVLTreeNode<K, V>>`.
83
+ * @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
79
84
  * an instance of the `AVLTreeNode` class.
80
85
  */
81
- isNode(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R): keyNodeEntryOrRaw is NODE;
86
+ isNode(keyNodeOrEntry: BTNRep<K, V, AVLTreeNode<K, V>>): keyNodeOrEntry is AVLTreeNode<K, V>;
82
87
  /**
83
88
  * Time Complexity: O(log n)
84
- * Space Complexity: O(1)
89
+ * Space Complexity: O(log n)
85
90
  *
86
91
  * The function overrides the add method of a class and inserts a key-value pair into a data
87
92
  * structure, then balances the path.
88
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
89
- * `keyNodeEntryOrRaw` can accept values of type `R`, `BTNRep<K, V, NODE>`, or
90
- * `RawElement`.
93
+ * @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The parameter
94
+ * `keyNodeOrEntry` can accept values of type `R`, `BTNRep<K, V, AVLTreeNode<K, V>>`
91
95
  * @param {V} [value] - The `value` parameter is an optional value that you want to associate with
92
96
  * the key or node being added to the data structure.
93
97
  * @returns The method is returning a boolean value.
94
98
  */
95
- add(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V): boolean;
99
+ add(keyNodeOrEntry: BTNRep<K, V, AVLTreeNode<K, V>>, value?: V): boolean;
96
100
  /**
97
101
  * Time Complexity: O(log n)
98
- * Space Complexity: O(1)
102
+ * Space Complexity: O(log n)
99
103
  *
100
104
  * The function overrides the delete method in a TypeScript class, performs deletion, and then
101
105
  * balances the tree if necessary.
102
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The `keyNodeEntryOrRaw`
106
+ * @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The `keyNodeOrEntry`
103
107
  * parameter in the `override delete` method can be one of the following types:
104
108
  * @returns The `delete` method is being overridden in this code snippet. It first calls the `delete`
105
109
  * method from the superclass (presumably a parent class) with the provided `predicate`, which could
106
110
  * be a key, node, entry, or a custom predicate. The result of this deletion operation is stored in
107
111
  * `deletedResults`, which is an array of `BinaryTreeDeleteResult` objects.
108
112
  */
109
- delete(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R): BinaryTreeDeleteResult<NODE>[];
113
+ delete(keyNodeOrEntry: BTNRep<K, V, AVLTreeNode<K, V>>): BinaryTreeDeleteResult<AVLTreeNode<K, V>>[];
114
+ /**
115
+ * Time Complexity: O(n)
116
+ * Space Complexity: O(n)
117
+ *
118
+ * The `map` function in TypeScript overrides the default map behavior of an AVLTree data structure
119
+ * by applying a callback function to each entry and creating a new AVLTree with the results.
120
+ * @param callback - A function that will be called for each entry in the AVLTree. It takes four
121
+ * arguments: the key, the value (which can be undefined), the index of the entry, and a reference to
122
+ * the AVLTree itself.
123
+ * @param [options] - The `options` parameter in the `override map` function is of type
124
+ * `AVLTreeOptions<MK, MV, MR>`. It is an optional parameter that allows you to specify additional
125
+ * options for the AVL tree being created during the mapping process. These options could include
126
+ * custom comparators, initial
127
+ * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
128
+ * the value of `this` when executing the `callback` function. It allows you to set the context
129
+ * (value of `this`) within the callback function. This can be useful when you want to access
130
+ * properties or
131
+ * @returns The `map` method is returning a new AVLTree instance (`newTree`) with the entries
132
+ * modified by the provided callback function.
133
+ */
134
+ map(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: AVLTreeOptions<MK, MV, MR>, thisArg?: any): AVLTree<MK, MV, MR>;
135
+ /**
136
+ * Time Complexity: O(n)
137
+ * Space Complexity: O(n)
138
+ *
139
+ * The function `clone` overrides the default cloning behavior to create a deep copy of a tree
140
+ * structure.
141
+ * @returns A cloned tree object is being returned.
142
+ */
143
+ clone(): AVLTree<K, V, R, MK, MV, MR>;
110
144
  /**
111
145
  * Time Complexity: O(1)
112
146
  * Space Complexity: O(1)
113
147
  *
114
148
  * The `_swapProperties` function swaps the key, value, and height properties between two nodes in a
115
149
  * binary search tree.
116
- * @param {R | BSTNOptKeyOrNode<K, NODE>} srcNode - The `srcNode` parameter represents either a node
117
- * object (`NODE`) or a key-value pair (`R`) that is being swapped with another node.
118
- * @param {R | BSTNOptKeyOrNode<K, NODE>} destNode - The `destNode` parameter is either an instance of
119
- * `R` or an instance of `BSTNOptKeyOrNode<K, NODE>`.
150
+ * @param {BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>} srcNode - The `srcNode` parameter represents either a node
151
+ * object (`AVLTreeNode<K, V>`) or a key-value pair (`R`) that is being swapped with another node.
152
+ * @param {BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>} destNode - The `destNode` parameter is either an instance of
153
+ * `R` or an instance of `BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>`.
120
154
  * @returns The method is returning the `destNodeEnsured` object if both `srcNodeEnsured` and
121
155
  * `destNodeEnsured` are truthy. Otherwise, it returns `undefined`.
122
156
  */
123
- protected _swapProperties(srcNode: R | BSTNOptKeyOrNode<K, NODE>, destNode: R | BSTNOptKeyOrNode<K, NODE>): NODE | undefined;
157
+ protected _swapProperties(srcNode: BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>, destNode: BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>): AVLTreeNode<K, V> | undefined;
124
158
  /**
125
159
  * Time Complexity: O(1)
126
160
  * Space Complexity: O(1)
127
161
  *
128
162
  * The function calculates the balance factor of a node in a binary tree.
129
- * @param {NODE} node - The parameter "node" is of type "NODE", which likely represents a node in a
163
+ * @param {AVLTreeNode<K, V>} node - The parameter "node" is of type "AVLTreeNode<K, V>", which likely represents a node in a
130
164
  * binary tree data structure.
131
165
  * @returns the balance factor of a given node. The balance factor is calculated by subtracting the
132
166
  * height of the left subtree from the height of the right subtree.
133
167
  */
134
- protected _balanceFactor(node: NODE): number;
168
+ protected _balanceFactor(node: AVLTreeNode<K, V>): number;
135
169
  /**
136
170
  * Time Complexity: O(1)
137
171
  * Space Complexity: O(1)
138
172
  *
139
173
  * The function updates the height of a node in a binary tree based on the heights of its left and
140
174
  * right children.
141
- * @param {NODE} node - The parameter "node" represents a node in a binary tree data structure.
175
+ * @param {AVLTreeNode<K, V>} node - The parameter "node" represents a node in a binary tree data structure.
142
176
  */
143
- protected _updateHeight(node: NODE): void;
177
+ protected _updateHeight(node: AVLTreeNode<K, V>): void;
144
178
  /**
145
179
  * Time Complexity: O(1)
146
180
  * Space Complexity: O(1)
147
181
  *
148
182
  * The `_balanceLL` function performs a left-left rotation to balance a binary search tree.
149
- * @param {NODE} A - A is a node in a binary tree.
183
+ * @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
150
184
  */
151
- protected _balanceLL(A: NODE): void;
185
+ protected _balanceLL(A: AVLTreeNode<K, V>): void;
152
186
  /**
153
187
  * Time Complexity: O(1)
154
188
  * Space Complexity: O(1)
155
189
  *
156
190
  * The `_balanceLR` function performs a left-right rotation to balance a binary tree.
157
- * @param {NODE} A - A is a node in a binary tree.
191
+ * @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
158
192
  */
159
- protected _balanceLR(A: NODE): void;
193
+ protected _balanceLR(A: AVLTreeNode<K, V>): void;
160
194
  /**
161
195
  * Time Complexity: O(1)
162
196
  * Space Complexity: O(1)
163
197
  *
164
198
  * The function `_balanceRR` performs a right-right rotation to balance a binary tree.
165
- * @param {NODE} A - A is a node in a binary tree.
199
+ * @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
166
200
  */
167
- protected _balanceRR(A: NODE): void;
201
+ protected _balanceRR(A: AVLTreeNode<K, V>): void;
168
202
  /**
169
203
  * Time Complexity: O(1)
170
204
  * Space Complexity: O(1)
171
205
  *
172
206
  * The function `_balanceRL` performs a right-left rotation to balance a binary tree.
173
- * @param {NODE} A - A is a node in a binary tree.
207
+ * @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
174
208
  */
175
- protected _balanceRL(A: NODE): void;
209
+ protected _balanceRL(A: AVLTreeNode<K, V>): void;
176
210
  /**
177
211
  * Time Complexity: O(log n)
178
212
  * Space Complexity: O(1)
179
213
  *
180
214
  * The `_balancePath` function is used to update the heights of nodes and perform rotation operations
181
215
  * to restore balance in an AVL tree after inserting a node.
182
- * @param {BTNRep<K, V, NODE> | R} node - The `node` parameter can be of type `R` or
183
- * `BTNRep<K, V, NODE>`.
216
+ * @param {BTNRep<K, V, AVLTreeNode<K, V>>} node - The `node` parameter can be of type `R` or
217
+ * `BTNRep<K, V, AVLTreeNode<K, V>>`.
184
218
  */
185
- protected _balancePath(node: BTNRep<K, V, NODE> | R): void;
219
+ protected _balancePath(node: BTNRep<K, V, AVLTreeNode<K, V>>): void;
186
220
  /**
187
221
  * Time Complexity: O(1)
188
222
  * Space Complexity: O(1)
189
223
  *
190
224
  * The function replaces an old node with a new node and sets the height of the new node to be the
191
225
  * same as the old node.
192
- * @param {NODE} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
226
+ * @param {AVLTreeNode<K, V>} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
193
227
  * the data structure.
194
- * @param {NODE} newNode - The `newNode` parameter is the new node that will replace the `oldNode` in
228
+ * @param {AVLTreeNode<K, V>} newNode - The `newNode` parameter is the new node that will replace the `oldNode` in
195
229
  * the data structure.
196
230
  * @returns The method is returning the result of calling the `_replaceNode` method from the
197
231
  * superclass, with the `oldNode` and `newNode` as arguments.
198
232
  */
199
- protected _replaceNode(oldNode: NODE, newNode: NODE): NODE;
233
+ protected _replaceNode(oldNode: AVLTreeNode<K, V>, newNode: AVLTreeNode<K, V>): AVLTreeNode<K, V>;
200
234
  }