min-heap-typed 1.42.8 → 1.43.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/dist/data-structures/binary-tree/avl-tree.d.ts +88 -23
- package/dist/data-structures/binary-tree/avl-tree.js +88 -23
- package/dist/data-structures/binary-tree/binary-tree.d.ts +180 -74
- package/dist/data-structures/binary-tree/binary-tree.js +415 -236
- package/dist/data-structures/binary-tree/bst.d.ts +121 -66
- package/dist/data-structures/binary-tree/bst.js +121 -67
- package/dist/data-structures/binary-tree/rb-tree.d.ts +72 -5
- package/dist/data-structures/binary-tree/rb-tree.js +95 -18
- package/dist/data-structures/binary-tree/tree-multimap.d.ts +82 -43
- package/dist/data-structures/binary-tree/tree-multimap.js +82 -43
- package/dist/data-structures/graph/abstract-graph.d.ts +139 -36
- package/dist/data-structures/graph/abstract-graph.js +147 -36
- package/dist/data-structures/graph/directed-graph.d.ts +126 -0
- package/dist/data-structures/graph/directed-graph.js +126 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +63 -0
- package/dist/data-structures/graph/undirected-graph.js +63 -0
- package/dist/data-structures/heap/heap.d.ts +175 -12
- package/dist/data-structures/heap/heap.js +175 -12
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +203 -0
- package/dist/data-structures/linked-list/doubly-linked-list.js +203 -0
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +182 -0
- package/dist/data-structures/linked-list/singly-linked-list.js +182 -0
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +64 -0
- package/dist/data-structures/linked-list/skip-linked-list.js +64 -0
- package/dist/data-structures/queue/deque.d.ts +113 -3
- package/dist/data-structures/queue/deque.js +113 -3
- package/dist/data-structures/queue/queue.d.ts +87 -0
- package/dist/data-structures/queue/queue.js +87 -0
- package/dist/data-structures/stack/stack.d.ts +42 -0
- package/dist/data-structures/stack/stack.js +42 -0
- package/dist/data-structures/trie/trie.d.ts +76 -0
- package/dist/data-structures/trie/trie.js +76 -1
- package/package.json +2 -2
- package/src/data-structures/binary-tree/avl-tree.ts +97 -23
- package/src/data-structures/binary-tree/binary-tree.ts +465 -256
- package/src/data-structures/binary-tree/bst.ts +130 -68
- package/src/data-structures/binary-tree/rb-tree.ts +106 -19
- package/src/data-structures/binary-tree/tree-multimap.ts +88 -44
- package/src/data-structures/graph/abstract-graph.ts +133 -7
- package/src/data-structures/graph/directed-graph.ts +145 -1
- package/src/data-structures/graph/undirected-graph.ts +72 -0
- package/src/data-structures/heap/heap.ts +201 -12
- package/src/data-structures/linked-list/doubly-linked-list.ts +232 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +208 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +74 -0
- package/src/data-structures/queue/deque.ts +127 -3
- package/src/data-structures/queue/queue.ts +99 -0
- package/src/data-structures/stack/stack.ts +48 -0
- package/src/data-structures/trie/trie.ts +87 -4
|
@@ -32,38 +32,61 @@ export declare class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<
|
|
|
32
32
|
*/
|
|
33
33
|
createNode(key: BTNKey, value?: V): N;
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
35
|
+
* Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity.
|
|
36
|
+
* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity.
|
|
40
|
+
* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
|
|
41
|
+
*
|
|
42
|
+
* The function overrides the add method of a class, adds a key-value pair to a data structure, and
|
|
43
|
+
* balances the structure if necessary.
|
|
44
|
+
* @param {BTNKey | N | null | undefined} keyOrNode - The `keyOrNode` parameter can be of type
|
|
45
|
+
* `BTNKey`, `N`, `null`, or `undefined`.
|
|
46
|
+
* @param {V} [value] - The `value` parameter is the value associated with the key that is being
|
|
47
|
+
* added to the binary search tree.
|
|
48
|
+
* @returns The method is returning either a node (N) or undefined.
|
|
42
49
|
*/
|
|
43
50
|
add(keyOrNode: BTNKey | N | null | undefined, value?: V): N | undefined;
|
|
44
51
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* @
|
|
52
|
+
* Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The delete method of the superclass (BST) has logarithmic time complexity.
|
|
53
|
+
* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
|
|
54
|
+
*/
|
|
55
|
+
/**
|
|
56
|
+
* Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The delete method of the superclass (BST) has logarithmic time complexity.
|
|
57
|
+
* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
|
|
58
|
+
*
|
|
59
|
+
* The function overrides the delete method of a binary tree, performs the deletion, and then
|
|
60
|
+
* balances the tree if necessary.
|
|
61
|
+
* @param identifier - The `identifier` parameter is the value or condition used to identify the
|
|
62
|
+
* node(s) to be deleted from the binary tree. It can be of any type and is the return type of the
|
|
63
|
+
* `callback` function.
|
|
64
|
+
* @param {C} callback - The `callback` parameter is a function that will be called for each node
|
|
65
|
+
* that is deleted from the binary tree. It is an optional parameter and if not provided, it will
|
|
66
|
+
* default to the `_defaultOneParamCallback` function. The `callback` function should have a single
|
|
67
|
+
* parameter of type `N
|
|
68
|
+
* @returns The method is returning an array of `BiTreeDeleteResult<N>`.
|
|
55
69
|
*/
|
|
56
70
|
delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C): BiTreeDeleteResult<N>[];
|
|
57
71
|
/**
|
|
58
|
-
* The function swaps the key, value, and height properties between two nodes in a binary
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
72
|
+
* The `_swap` function swaps the key, value, and height properties between two nodes in a binary
|
|
73
|
+
* tree.
|
|
74
|
+
* @param {BTNKey | N | undefined} srcNode - The `srcNode` parameter represents the source node that
|
|
75
|
+
* needs to be swapped with the destination node. It can be of type `BTNKey`, `N`, or `undefined`.
|
|
76
|
+
* @param {BTNKey | N | undefined} destNode - The `destNode` parameter represents the destination
|
|
77
|
+
* node where the values from the source node will be swapped to.
|
|
78
|
+
* @returns either the `destNode` object if both `srcNode` and `destNode` are defined, or `undefined`
|
|
79
|
+
* if either `srcNode` or `destNode` is undefined.
|
|
64
80
|
*/
|
|
65
81
|
protected _swap(srcNode: BTNKey | N | undefined, destNode: BTNKey | N | undefined): N | undefined;
|
|
66
82
|
/**
|
|
83
|
+
* Time Complexity: O(1) - constant time, as it performs a fixed number of operations.
|
|
84
|
+
* Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
|
|
85
|
+
*/
|
|
86
|
+
/**
|
|
87
|
+
* Time Complexity: O(1) - constant time, as it performs a fixed number of operations.
|
|
88
|
+
* Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
|
|
89
|
+
*
|
|
67
90
|
* The function calculates the balance factor of a node in a binary tree.
|
|
68
91
|
* @param {N} node - The parameter "node" represents a node in a binary tree data structure.
|
|
69
92
|
* @returns the balance factor of a given node. The balance factor is calculated by subtracting the
|
|
@@ -71,12 +94,26 @@ export declare class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<
|
|
|
71
94
|
*/
|
|
72
95
|
protected _balanceFactor(node: N): number;
|
|
73
96
|
/**
|
|
97
|
+
* Time Complexity: O(1) - constant time, as it performs a fixed number of operations.
|
|
98
|
+
* Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
|
|
99
|
+
*/
|
|
100
|
+
/**
|
|
101
|
+
* Time Complexity: O(1) - constant time, as it performs a fixed number of operations.
|
|
102
|
+
* Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
|
|
103
|
+
*
|
|
74
104
|
* The function updates the height of a node in a binary tree based on the heights of its left and
|
|
75
105
|
* right children.
|
|
76
106
|
* @param {N} node - The parameter "node" represents a node in a binary tree data structure.
|
|
77
107
|
*/
|
|
78
108
|
protected _updateHeight(node: N): void;
|
|
79
109
|
/**
|
|
110
|
+
* Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The method traverses the path from the inserted node to the root.
|
|
111
|
+
* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
|
|
112
|
+
*/
|
|
113
|
+
/**
|
|
114
|
+
* Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The method traverses the path from the inserted node to the root.
|
|
115
|
+
* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
|
|
116
|
+
*
|
|
80
117
|
* The `_balancePath` function is used to update the heights of nodes and perform rotation operations
|
|
81
118
|
* to restore balance in an AVL tree after inserting a node.
|
|
82
119
|
* @param {N} node - The `node` parameter in the `_balancePath` function represents the node in the
|
|
@@ -84,21 +121,49 @@ export declare class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<
|
|
|
84
121
|
*/
|
|
85
122
|
protected _balancePath(node: N): void;
|
|
86
123
|
/**
|
|
124
|
+
* Time Complexity: O(1) - constant time, as these methods perform a fixed number of operations.
|
|
125
|
+
* Space Complexity: O(1) - constant space, as they only use a constant amount of memory.
|
|
126
|
+
*/
|
|
127
|
+
/**
|
|
128
|
+
* Time Complexity: O(1) - constant time, as these methods perform a fixed number of operations.
|
|
129
|
+
* Space Complexity: O(1) - constant space, as they only use a constant amount of memory.
|
|
130
|
+
*
|
|
87
131
|
* The function `_balanceLL` performs a left-left rotation to balance a binary tree.
|
|
88
132
|
* @param {N} A - A is a node in a binary tree.
|
|
89
133
|
*/
|
|
90
134
|
protected _balanceLL(A: N): void;
|
|
91
135
|
/**
|
|
136
|
+
* Time Complexity: O(1) - constant time, as these methods perform a fixed number of operations.
|
|
137
|
+
* Space Complexity: O(1) - constant space, as they only use a constant amount of memory.
|
|
138
|
+
*/
|
|
139
|
+
/**
|
|
140
|
+
* Time Complexity: O(1) - constant time, as these methods perform a fixed number of operations.
|
|
141
|
+
* Space Complexity: O(1) - constant space, as they only use a constant amount of memory.
|
|
142
|
+
*
|
|
92
143
|
* The `_balanceLR` function performs a left-right rotation to balance a binary tree.
|
|
93
144
|
* @param {N} A - A is a node in a binary tree.
|
|
94
145
|
*/
|
|
95
146
|
protected _balanceLR(A: N): void;
|
|
96
147
|
/**
|
|
148
|
+
* Time Complexity: O(1) - constant time, as these methods perform a fixed number of operations.
|
|
149
|
+
* Space Complexity: O(1) - constant space, as they only use a constant amount of memory.
|
|
150
|
+
*/
|
|
151
|
+
/**
|
|
152
|
+
* Time Complexity: O(1) - constant time, as these methods perform a fixed number of operations.
|
|
153
|
+
* Space Complexity: O(1) - constant space, as they only use a constant amount of memory.
|
|
154
|
+
*
|
|
97
155
|
* The function `_balanceRR` performs a right-right rotation to balance a binary tree.
|
|
98
156
|
* @param {N} A - A is a node in a binary tree.
|
|
99
157
|
*/
|
|
100
158
|
protected _balanceRR(A: N): void;
|
|
101
159
|
/**
|
|
160
|
+
* Time Complexity: O(1) - constant time, as these methods perform a fixed number of operations.
|
|
161
|
+
* Space Complexity: O(1) - constant space, as they only use a constant amount of memory.
|
|
162
|
+
*/
|
|
163
|
+
/**
|
|
164
|
+
* Time Complexity: O(1) - constant time, as these methods perform a fixed number of operations.
|
|
165
|
+
* Space Complexity: O(1) - constant space, as they only use a constant amount of memory.
|
|
166
|
+
*
|
|
102
167
|
* The function `_balanceRL` performs a right-left rotation to balance a binary tree.
|
|
103
168
|
* @param {N} A - A is a node in a binary tree.
|
|
104
169
|
*/
|
|
@@ -39,13 +39,20 @@ class AVLTree extends bst_1.BST {
|
|
|
39
39
|
return new AVLTreeNode(key, value);
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
42
|
+
* Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity.
|
|
43
|
+
* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity.
|
|
47
|
+
* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
|
|
48
|
+
*
|
|
49
|
+
* The function overrides the add method of a class, adds a key-value pair to a data structure, and
|
|
50
|
+
* balances the structure if necessary.
|
|
51
|
+
* @param {BTNKey | N | null | undefined} keyOrNode - The `keyOrNode` parameter can be of type
|
|
52
|
+
* `BTNKey`, `N`, `null`, or `undefined`.
|
|
53
|
+
* @param {V} [value] - The `value` parameter is the value associated with the key that is being
|
|
54
|
+
* added to the binary search tree.
|
|
55
|
+
* @returns The method is returning either a node (N) or undefined.
|
|
49
56
|
*/
|
|
50
57
|
add(keyOrNode, value) {
|
|
51
58
|
if (keyOrNode === null)
|
|
@@ -56,16 +63,23 @@ class AVLTree extends bst_1.BST {
|
|
|
56
63
|
return inserted;
|
|
57
64
|
}
|
|
58
65
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @
|
|
66
|
+
* Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The delete method of the superclass (BST) has logarithmic time complexity.
|
|
67
|
+
* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
|
|
68
|
+
*/
|
|
69
|
+
/**
|
|
70
|
+
* Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The delete method of the superclass (BST) has logarithmic time complexity.
|
|
71
|
+
* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
|
|
72
|
+
*
|
|
73
|
+
* The function overrides the delete method of a binary tree, performs the deletion, and then
|
|
74
|
+
* balances the tree if necessary.
|
|
75
|
+
* @param identifier - The `identifier` parameter is the value or condition used to identify the
|
|
76
|
+
* node(s) to be deleted from the binary tree. It can be of any type and is the return type of the
|
|
77
|
+
* `callback` function.
|
|
78
|
+
* @param {C} callback - The `callback` parameter is a function that will be called for each node
|
|
79
|
+
* that is deleted from the binary tree. It is an optional parameter and if not provided, it will
|
|
80
|
+
* default to the `_defaultOneParamCallback` function. The `callback` function should have a single
|
|
81
|
+
* parameter of type `N
|
|
82
|
+
* @returns The method is returning an array of `BiTreeDeleteResult<N>`.
|
|
69
83
|
*/
|
|
70
84
|
delete(identifier, callback = this._defaultOneParamCallback) {
|
|
71
85
|
if (identifier instanceof AVLTreeNode)
|
|
@@ -79,12 +93,14 @@ class AVLTree extends bst_1.BST {
|
|
|
79
93
|
return deletedResults;
|
|
80
94
|
}
|
|
81
95
|
/**
|
|
82
|
-
* The function swaps the key, value, and height properties between two nodes in a binary
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
96
|
+
* The `_swap` function swaps the key, value, and height properties between two nodes in a binary
|
|
97
|
+
* tree.
|
|
98
|
+
* @param {BTNKey | N | undefined} srcNode - The `srcNode` parameter represents the source node that
|
|
99
|
+
* needs to be swapped with the destination node. It can be of type `BTNKey`, `N`, or `undefined`.
|
|
100
|
+
* @param {BTNKey | N | undefined} destNode - The `destNode` parameter represents the destination
|
|
101
|
+
* node where the values from the source node will be swapped to.
|
|
102
|
+
* @returns either the `destNode` object if both `srcNode` and `destNode` are defined, or `undefined`
|
|
103
|
+
* if either `srcNode` or `destNode` is undefined.
|
|
88
104
|
*/
|
|
89
105
|
_swap(srcNode, destNode) {
|
|
90
106
|
srcNode = this.ensureNotKey(srcNode);
|
|
@@ -106,6 +122,13 @@ class AVLTree extends bst_1.BST {
|
|
|
106
122
|
return undefined;
|
|
107
123
|
}
|
|
108
124
|
/**
|
|
125
|
+
* Time Complexity: O(1) - constant time, as it performs a fixed number of operations.
|
|
126
|
+
* Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
|
|
127
|
+
*/
|
|
128
|
+
/**
|
|
129
|
+
* Time Complexity: O(1) - constant time, as it performs a fixed number of operations.
|
|
130
|
+
* Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
|
|
131
|
+
*
|
|
109
132
|
* The function calculates the balance factor of a node in a binary tree.
|
|
110
133
|
* @param {N} node - The parameter "node" represents a node in a binary tree data structure.
|
|
111
134
|
* @returns the balance factor of a given node. The balance factor is calculated by subtracting the
|
|
@@ -122,6 +145,13 @@ class AVLTree extends bst_1.BST {
|
|
|
122
145
|
return node.right.height - node.left.height;
|
|
123
146
|
}
|
|
124
147
|
/**
|
|
148
|
+
* Time Complexity: O(1) - constant time, as it performs a fixed number of operations.
|
|
149
|
+
* Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
|
|
150
|
+
*/
|
|
151
|
+
/**
|
|
152
|
+
* Time Complexity: O(1) - constant time, as it performs a fixed number of operations.
|
|
153
|
+
* Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
|
|
154
|
+
*
|
|
125
155
|
* The function updates the height of a node in a binary tree based on the heights of its left and
|
|
126
156
|
* right children.
|
|
127
157
|
* @param {N} node - The parameter "node" represents a node in a binary tree data structure.
|
|
@@ -139,6 +169,13 @@ class AVLTree extends bst_1.BST {
|
|
|
139
169
|
node.height = 1 + Math.max(node.right.height, node.left.height);
|
|
140
170
|
}
|
|
141
171
|
/**
|
|
172
|
+
* Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The method traverses the path from the inserted node to the root.
|
|
173
|
+
* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
|
|
174
|
+
*/
|
|
175
|
+
/**
|
|
176
|
+
* Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The method traverses the path from the inserted node to the root.
|
|
177
|
+
* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
|
|
178
|
+
*
|
|
142
179
|
* The `_balancePath` function is used to update the heights of nodes and perform rotation operations
|
|
143
180
|
* to restore balance in an AVL tree after inserting a node.
|
|
144
181
|
* @param {N} node - The `node` parameter in the `_balancePath` function represents the node in the
|
|
@@ -184,6 +221,13 @@ class AVLTree extends bst_1.BST {
|
|
|
184
221
|
}
|
|
185
222
|
}
|
|
186
223
|
/**
|
|
224
|
+
* Time Complexity: O(1) - constant time, as these methods perform a fixed number of operations.
|
|
225
|
+
* Space Complexity: O(1) - constant space, as they only use a constant amount of memory.
|
|
226
|
+
*/
|
|
227
|
+
/**
|
|
228
|
+
* Time Complexity: O(1) - constant time, as these methods perform a fixed number of operations.
|
|
229
|
+
* Space Complexity: O(1) - constant space, as they only use a constant amount of memory.
|
|
230
|
+
*
|
|
187
231
|
* The function `_balanceLL` performs a left-left rotation to balance a binary tree.
|
|
188
232
|
* @param {N} A - A is a node in a binary tree.
|
|
189
233
|
*/
|
|
@@ -218,6 +262,13 @@ class AVLTree extends bst_1.BST {
|
|
|
218
262
|
this._updateHeight(B);
|
|
219
263
|
}
|
|
220
264
|
/**
|
|
265
|
+
* Time Complexity: O(1) - constant time, as these methods perform a fixed number of operations.
|
|
266
|
+
* Space Complexity: O(1) - constant space, as they only use a constant amount of memory.
|
|
267
|
+
*/
|
|
268
|
+
/**
|
|
269
|
+
* Time Complexity: O(1) - constant time, as these methods perform a fixed number of operations.
|
|
270
|
+
* Space Complexity: O(1) - constant space, as they only use a constant amount of memory.
|
|
271
|
+
*
|
|
221
272
|
* The `_balanceLR` function performs a left-right rotation to balance a binary tree.
|
|
222
273
|
* @param {N} A - A is a node in a binary tree.
|
|
223
274
|
*/
|
|
@@ -267,6 +318,13 @@ class AVLTree extends bst_1.BST {
|
|
|
267
318
|
C && this._updateHeight(C);
|
|
268
319
|
}
|
|
269
320
|
/**
|
|
321
|
+
* Time Complexity: O(1) - constant time, as these methods perform a fixed number of operations.
|
|
322
|
+
* Space Complexity: O(1) - constant space, as they only use a constant amount of memory.
|
|
323
|
+
*/
|
|
324
|
+
/**
|
|
325
|
+
* Time Complexity: O(1) - constant time, as these methods perform a fixed number of operations.
|
|
326
|
+
* Space Complexity: O(1) - constant space, as they only use a constant amount of memory.
|
|
327
|
+
*
|
|
270
328
|
* The function `_balanceRR` performs a right-right rotation to balance a binary tree.
|
|
271
329
|
* @param {N} A - A is a node in a binary tree.
|
|
272
330
|
*/
|
|
@@ -302,6 +360,13 @@ class AVLTree extends bst_1.BST {
|
|
|
302
360
|
B && this._updateHeight(B);
|
|
303
361
|
}
|
|
304
362
|
/**
|
|
363
|
+
* Time Complexity: O(1) - constant time, as these methods perform a fixed number of operations.
|
|
364
|
+
* Space Complexity: O(1) - constant space, as they only use a constant amount of memory.
|
|
365
|
+
*/
|
|
366
|
+
/**
|
|
367
|
+
* Time Complexity: O(1) - constant time, as these methods perform a fixed number of operations.
|
|
368
|
+
* Space Complexity: O(1) - constant space, as they only use a constant amount of memory.
|
|
369
|
+
*
|
|
305
370
|
* The function `_balanceRL` performs a right-left rotation to balance a binary tree.
|
|
306
371
|
* @param {N} A - A is a node in a binary tree.
|
|
307
372
|
*/
|