mirror of
https://github.com/zrwusa/data-structure-typed.git
synced 2024-11-23 04:44:04 +00:00
style: Remove unnecessary comments.
This commit is contained in:
parent
5a492c1801
commit
18fe006652
|
@ -29,10 +29,6 @@ export abstract class IterableElementBase<E, R, C> {
|
|||
return this._toElementFn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -46,10 +42,6 @@ export abstract class IterableElementBase<E, R, C> {
|
|||
yield* this._getIterator(...args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -62,10 +54,6 @@ export abstract class IterableElementBase<E, R, C> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -90,15 +78,6 @@ export abstract class IterableElementBase<E, R, C> {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -123,11 +102,6 @@ export abstract class IterableElementBase<E, R, C> {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -148,11 +122,6 @@ export abstract class IterableElementBase<E, R, C> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -195,10 +164,6 @@ export abstract class IterableElementBase<E, R, C> {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -221,11 +186,6 @@ export abstract class IterableElementBase<E, R, C> {
|
|||
return accumulator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
|
|
@ -9,11 +9,6 @@ export abstract class IterableEntryBase<K = any, V = any> {
|
|||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
abstract get size(): number;
|
||||
|
||||
// protected _toEntryFn?: (rawElement: R) => BTNEntry<K, V>;
|
||||
|
@ -39,10 +34,6 @@ export abstract class IterableEntryBase<K = any, V = any> {
|
|||
yield* this._getIterator(...args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -56,10 +47,6 @@ export abstract class IterableEntryBase<K = any, V = any> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -72,10 +59,6 @@ export abstract class IterableEntryBase<K = any, V = any> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -88,10 +71,6 @@ export abstract class IterableEntryBase<K = any, V = any> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -116,10 +95,6 @@ export abstract class IterableEntryBase<K = any, V = any> {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -145,15 +120,6 @@ export abstract class IterableEntryBase<K = any, V = any> {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -175,11 +141,6 @@ export abstract class IterableEntryBase<K = any, V = any> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -206,11 +167,6 @@ export abstract class IterableEntryBase<K = any, V = any> {
|
|||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -229,11 +185,6 @@ export abstract class IterableEntryBase<K = any, V = any> {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -250,11 +201,6 @@ export abstract class IterableEntryBase<K = any, V = any> {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -299,11 +245,6 @@ export abstract class IterableEntryBase<K = any, V = any> {
|
|||
return accumulator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
|
|
@ -105,11 +105,6 @@ export class AVLTreeMultiMap<
|
|||
return this._count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -203,11 +198,6 @@ export class AVLTreeMultiMap<
|
|||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -237,11 +227,6 @@ export class AVLTreeMultiMap<
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -322,11 +307,6 @@ export class AVLTreeMultiMap<
|
|||
return deletedResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -339,11 +319,6 @@ export class AVLTreeMultiMap<
|
|||
this._count = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n log n)
|
||||
* Space Complexity: O(log n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n log n)
|
||||
* Space Complexity: O(log n)
|
||||
|
@ -394,11 +369,6 @@ export class AVLTreeMultiMap<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
|
@ -412,11 +382,6 @@ export class AVLTreeMultiMap<
|
|||
return cloned;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -458,11 +423,6 @@ export class AVLTreeMultiMap<
|
|||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
|
|
@ -135,12 +135,6 @@ export class AVLTree<
|
|||
return keyOrNodeOrEntryOrRawElement instanceof AVLTreeNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
* logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity. constant space, as it doesn't use additional data structures that scale with input size.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -161,11 +155,6 @@ export class AVLTree<
|
|||
return inserted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -192,11 +181,6 @@ export class AVLTree<
|
|||
return deletedResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -238,11 +222,6 @@ export class AVLTree<
|
|||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -263,11 +242,6 @@ export class AVLTree<
|
|||
else return node.right.height - node.left.height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -285,11 +259,6 @@ export class AVLTree<
|
|||
else node.height = 1 + Math.max(node.right.height, node.left.height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -323,11 +292,6 @@ export class AVLTree<
|
|||
if (B) this._updateHeight(B);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -379,11 +343,6 @@ export class AVLTree<
|
|||
C && this._updateHeight(C);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -422,11 +381,6 @@ export class AVLTree<
|
|||
B && this._updateHeight(B);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -477,12 +431,6 @@ export class AVLTree<
|
|||
C && this._updateHeight(C);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
* logarithmic time, where "n" is the number of nodes in the tree. The method traverses the path from the inserted node to the root. constant space, as it doesn't use additional data structures that scale with input size.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -532,11 +480,6 @@ export class AVLTree<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
|
|
@ -268,11 +268,6 @@ export class BinaryTree<
|
|||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(log n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(log n)
|
||||
|
@ -411,11 +406,6 @@ export class BinaryTree<
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity O(n)
|
||||
* Space Complexity O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity O(n)
|
||||
* Space Complexity O(1)
|
||||
|
@ -485,12 +475,6 @@ export class BinaryTree<
|
|||
return false; // If the insertion position cannot be found, return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(k * n)
|
||||
* Space Complexity: O(1)
|
||||
* Comments: The time complexity for adding a node depends on the depth of the tree. In the best case (when the tree is empty), it's O(1). In the worst case (when the tree is a degenerate tree), it's O(n). The space complexity is constant.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(k * n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -533,12 +517,6 @@ export class BinaryTree<
|
|||
return inserted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(k * n)
|
||||
* Space Complexity: O(1)
|
||||
* "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(k * n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -567,11 +545,6 @@ export class BinaryTree<
|
|||
|
||||
delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback: C): BinaryTreeDeleteResult<NODE>[];
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -659,11 +632,6 @@ export class BinaryTree<
|
|||
iterationType?: IterationType
|
||||
): NODE[];
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(k + log n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(k + log n)
|
||||
|
@ -752,11 +720,6 @@ export class BinaryTree<
|
|||
iterationType?: IterationType
|
||||
): OptBTNOrNull<NODE>;
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(log n).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(log n).
|
||||
|
@ -784,11 +747,6 @@ export class BinaryTree<
|
|||
return this.getNodes(identifier, callback, true, beginRoot, iterationType)[0] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(log n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(log n)
|
||||
|
@ -826,11 +784,6 @@ export class BinaryTree<
|
|||
iterationType?: IterationType
|
||||
): V | undefined;
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(log n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(log n)
|
||||
|
@ -882,11 +835,6 @@ export class BinaryTree<
|
|||
iterationType?: IterationType
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(log n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(log n)
|
||||
|
@ -918,11 +866,6 @@ export class BinaryTree<
|
|||
return this.getNodes(identifier, callback, true, beginRoot, iterationType).length > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -934,11 +877,6 @@ export class BinaryTree<
|
|||
this._size = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -950,11 +888,6 @@ export class BinaryTree<
|
|||
return this.size === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(log n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(log n)
|
||||
|
@ -971,11 +904,6 @@ export class BinaryTree<
|
|||
return this.getMinHeight(beginRoot) + 1 >= this.getHeight(beginRoot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -1034,11 +962,6 @@ export class BinaryTree<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -1070,11 +993,6 @@ export class BinaryTree<
|
|||
return depth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -1121,11 +1039,6 @@ export class BinaryTree<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(log n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(log n)
|
||||
|
@ -1188,11 +1101,6 @@ export class BinaryTree<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(log n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(log n)
|
||||
|
@ -1221,11 +1129,6 @@ export class BinaryTree<
|
|||
return isReverse ? result.reverse() : result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -1266,11 +1169,6 @@ export class BinaryTree<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -1312,11 +1210,6 @@ export class BinaryTree<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -1340,11 +1233,6 @@ export class BinaryTree<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -1385,11 +1273,6 @@ export class BinaryTree<
|
|||
includeNull?: boolean
|
||||
): ReturnType<C>[];
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
|
@ -1439,11 +1322,6 @@ export class BinaryTree<
|
|||
includeNull?: true
|
||||
): ReturnType<C>[];
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
|
@ -1520,11 +1398,6 @@ export class BinaryTree<
|
|||
return ans;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
|
@ -1596,11 +1469,6 @@ export class BinaryTree<
|
|||
includeNull?: true
|
||||
): ReturnType<C>[][];
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
|
@ -1669,11 +1537,6 @@ export class BinaryTree<
|
|||
return levelsNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
|
@ -1779,11 +1642,6 @@ export class BinaryTree<
|
|||
return ans;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
|
@ -1805,11 +1663,6 @@ export class BinaryTree<
|
|||
return cloned;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -1836,11 +1689,6 @@ export class BinaryTree<
|
|||
return newTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -1875,11 +1723,6 @@ export class BinaryTree<
|
|||
// // }
|
||||
//
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -1936,11 +1779,6 @@ export class BinaryTree<
|
|||
includeNull?: boolean
|
||||
): ReturnType<C>[];
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
|
@ -2077,11 +1915,6 @@ export class BinaryTree<
|
|||
return ans;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -2123,11 +1956,6 @@ export class BinaryTree<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -2215,11 +2043,6 @@ export class BinaryTree<
|
|||
|
||||
protected _DEFAULT_CALLBACK = (node: OptBTNOrNull<NODE>) => (node ? node.key : undefined);
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -2257,11 +2080,6 @@ export class BinaryTree<
|
|||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -2292,11 +2110,6 @@ export class BinaryTree<
|
|||
return newNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -2313,11 +2126,6 @@ export class BinaryTree<
|
|||
this._root = v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
|
|
@ -259,11 +259,6 @@ export class BST<
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(log n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(k log n)
|
||||
* Space Complexity: O(k + log n)
|
||||
|
@ -469,11 +464,6 @@ export class BST<
|
|||
return ans;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -504,11 +494,6 @@ export class BST<
|
|||
return this.getNodes(identifier, callback, true, beginRoot, iterationType)[0] ?? undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(k log n)
|
||||
* Space Complexity: O(k + log n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -526,11 +511,6 @@ export class BST<
|
|||
return this.getNode(key, this._DEFAULT_CALLBACK, this.root, iterationType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(k + log n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
|
@ -560,11 +540,6 @@ export class BST<
|
|||
return super.dfs(callback, pattern, beginRoot, iterationType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
|
@ -590,11 +565,6 @@ export class BST<
|
|||
return super.bfs(callback, beginRoot, iterationType, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
|
@ -621,11 +591,6 @@ export class BST<
|
|||
return super.listLevels(callback, beginRoot, iterationType, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
|
@ -687,11 +652,6 @@ export class BST<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
|
@ -741,11 +701,6 @@ export class BST<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(log n)
|
||||
|
@ -815,11 +770,6 @@ export class BST<
|
|||
|
||||
protected _comparator: Comparator<K> = this._DEFAULT_COMPARATOR;
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(log n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* The function returns the value of the _comparator property.
|
||||
* @returns The `_comparator` property is being returned.
|
||||
|
|
|
@ -126,11 +126,6 @@ export class RedBlackTree<
|
|||
}) as TREE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -183,11 +178,6 @@ export class RedBlackTree<
|
|||
// return ;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -200,11 +190,6 @@ export class RedBlackTree<
|
|||
this._root = this.NIL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -238,11 +223,6 @@ export class RedBlackTree<
|
|||
} else return insertStatus === 'UPDATED';
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -319,11 +299,6 @@ export class RedBlackTree<
|
|||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -339,11 +314,6 @@ export class RedBlackTree<
|
|||
this._root = v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -362,11 +332,6 @@ export class RedBlackTree<
|
|||
return super._replaceNode(oldNode, newNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -414,11 +379,6 @@ export class RedBlackTree<
|
|||
return 'CREATED';
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -442,11 +402,6 @@ export class RedBlackTree<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -513,11 +468,6 @@ export class RedBlackTree<
|
|||
if (this.isRealNode(this._root)) this._root.color = 'BLACK';
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -601,11 +551,6 @@ export class RedBlackTree<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -641,11 +586,6 @@ export class RedBlackTree<
|
|||
x.parent = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
|
|
@ -100,11 +100,6 @@ export class TreeMultiMap<
|
|||
return this._count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -202,11 +197,6 @@ export class TreeMultiMap<
|
|||
return keyOrNodeOrEntryOrRawElement instanceof TreeMultiMapNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -236,11 +226,6 @@ export class TreeMultiMap<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -352,11 +337,6 @@ export class TreeMultiMap<
|
|||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -369,11 +349,6 @@ export class TreeMultiMap<
|
|||
this._count = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n log n)
|
||||
* Space Complexity: O(log n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n log n)
|
||||
* Space Complexity: O(log n)
|
||||
|
@ -425,11 +400,6 @@ export class TreeMultiMap<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time complexity: O(n)
|
||||
* Space complexity: O(n)
|
||||
|
@ -443,11 +413,6 @@ export class TreeMultiMap<
|
|||
return cloned;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -490,11 +455,6 @@ export class TreeMultiMap<
|
|||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
|
|
@ -119,11 +119,6 @@ export abstract class AbstractGraph<
|
|||
|
||||
abstract getEndsOfEdge(edge: EO): [VO, VO] | undefined;
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) - Constant time for Map lookup.
|
||||
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) - Constant time for Map lookup.
|
||||
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
||||
|
@ -138,11 +133,6 @@ export abstract class AbstractGraph<
|
|||
return this._vertexMap.get(vertexKey) || undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) - Constant time for Map lookup.
|
||||
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) - Constant time for Map lookup.
|
||||
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
||||
|
@ -186,11 +176,6 @@ export abstract class AbstractGraph<
|
|||
|
||||
abstract deleteVertex(vertexOrKey: VO | VertexKey): boolean;
|
||||
|
||||
/**
|
||||
* Time Complexity: O(K), where K is the number of vertexMap to be removed.
|
||||
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(K), where K is the number of vertexMap to be removed.
|
||||
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
||||
|
@ -209,11 +194,6 @@ export abstract class AbstractGraph<
|
|||
return removed.length > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) - Depends on the implementation in the concrete class.
|
||||
* Space Complexity: O(1) - Depends on the implementation in the concrete class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) - Depends on the implementation in the concrete class.
|
||||
* Space Complexity: O(1) - Depends on the implementation in the concrete class.
|
||||
|
@ -255,11 +235,6 @@ export abstract class AbstractGraph<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) - Constant time for Map and Edge operations.
|
||||
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) - Constant time for Map and Edge operations.
|
||||
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
||||
|
@ -284,11 +259,6 @@ export abstract class AbstractGraph<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(P), where P is the number of paths found (in the worst case, exploring all paths).
|
||||
* Space Complexity: O(P) - Linear space, where P is the number of paths found.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(P), where P is the number of paths found (in the worst case, exploring all paths).
|
||||
* Space Complexity: O(P) - Linear space, where P is the number of paths found.
|
||||
|
@ -331,11 +301,6 @@ export abstract class AbstractGraph<
|
|||
return paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(L), where L is the length of the path.
|
||||
* Space Complexity: O(1) - Constant space.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(L), where L is the length of the path.
|
||||
* Space Complexity: O(1) - Constant space.
|
||||
|
@ -352,11 +317,6 @@ export abstract class AbstractGraph<
|
|||
return sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
|
||||
* Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
|
||||
* Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
|
||||
|
@ -419,11 +379,6 @@ export abstract class AbstractGraph<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm or DFS).
|
||||
* Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm or DFS).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm or DFS).
|
||||
* Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm or DFS).
|
||||
|
@ -495,15 +450,6 @@ export abstract class AbstractGraph<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dijkstra algorithm time: O(VE) space: O(VO + EO)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(V^2 + E) - Quadratic time in the worst case (no heap optimization).
|
||||
* Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(V^2 + E) - Quadratic time in the worst case (no heap optimization).
|
||||
* Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
|
||||
|
@ -633,20 +579,6 @@ export abstract class AbstractGraph<
|
|||
return { distMap, preMap, seen, paths, minDist, minPath };
|
||||
}
|
||||
|
||||
/**
|
||||
* Dijkstra algorithm time: O(logVE) space: O(VO + EO)
|
||||
*
|
||||
* Dijkstra's algorithm only solves the single-source shortest path problem, while the Bellman-Ford algorithm and Floyd-Warshall algorithm can address shortest paths between all pairs of nodes.
|
||||
* Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edgeMap.
|
||||
* The time complexity of Dijkstra's algorithm and the Bellman-Ford algorithm depends on the size of the graph, while the time complexity of the Floyd-Warshall algorithm is O(VO^3), where VO is the number of nodes. For dense graphs, Floyd-Warshall might become slower.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O((V + E) * log(V)) - Depends on the implementation (using a binary heap).
|
||||
* Space Complexity: O(V + E) - Depends on the implementation (using a binary heap).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O((V + E) * log(V)) - Depends on the implementation (using a binary heap).
|
||||
* Space Complexity: O(V + E) - Depends on the implementation (using a binary heap).
|
||||
|
@ -774,12 +706,6 @@ export abstract class AbstractGraph<
|
|||
return { distMap, preMap, seen, paths, minDist, minPath };
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(V * E) - Quadratic time in the worst case (Bellman-Ford algorithm).
|
||||
* Space Complexity: O(V + E) - Depends on the implementation (Bellman-Ford algorithm).
|
||||
* one to rest pairs
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(V * E) - Quadratic time in the worst case (Bellman-Ford algorithm).
|
||||
* Space Complexity: O(V + E) - Depends on the implementation (Bellman-Ford algorithm).
|
||||
|
@ -902,14 +828,6 @@ export abstract class AbstractGraph<
|
|||
* The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(V^3) - Cubic time (Floyd-Warshall algorithm).
|
||||
* Space Complexity: O(V^2) - Quadratic space (Floyd-Warshall algorithm).
|
||||
* Not support graph with negative weight cycle
|
||||
* all pairs
|
||||
* The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edgeMap, and it can simultaneously compute shortest paths between any two nodes.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(V^3) - Cubic time (Floyd-Warshall algorithm).
|
||||
* Space Complexity: O(V^2) - Quadratic space (Floyd-Warshall algorithm).
|
||||
|
@ -1009,11 +927,6 @@ export abstract class AbstractGraph<
|
|||
return [...uniqueCycles].map(cycleString => cycleString[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -1042,11 +955,6 @@ export abstract class AbstractGraph<
|
|||
return filtered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
|
|
@ -81,11 +81,6 @@ export class DirectedGraph<
|
|||
this._inEdgeMap = v;
|
||||
}
|
||||
|
||||
/**
|
||||
* In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
|
||||
* This means that using abstract methods in the parent class cannot constrain the grandchild classes. Defining methods within an interface also cannot constrain the descendant classes. When inheriting from this class, developers need to be aware that this method needs to be overridden.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The function creates a new vertex with an optional value and returns it.
|
||||
* @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
|
||||
|
@ -99,11 +94,6 @@ export class DirectedGraph<
|
|||
return new DirectedVertex(key, value) as VO;
|
||||
}
|
||||
|
||||
/**
|
||||
* In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
|
||||
* This means that using abstract methods in the parent class cannot constrain the grandchild classes. Defining methods within an interface also cannot constrain the descendant classes. When inheriting from this class, developers need to be aware that this method needs to be overridden.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The function creates a directed edge between two vertexMap with an optional weight and value.
|
||||
* @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.
|
||||
|
@ -118,11 +108,6 @@ export class DirectedGraph<
|
|||
return new DirectedEdge(src, dest, weight ?? 1, value) as EO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|V|) where |V| is the number of vertexMap
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|V|) where |V| is the number of vertexMap
|
||||
* Space Complexity: O(1)
|
||||
|
@ -152,11 +137,6 @@ export class DirectedGraph<
|
|||
return edgeMap[0] || undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
||||
* Space Complexity: O(1)
|
||||
|
@ -186,11 +166,6 @@ export class DirectedGraph<
|
|||
return removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(E) where E is the number of edgeMap
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(E) where E is the number of edgeMap
|
||||
* Space Complexity: O(1)
|
||||
|
@ -234,11 +209,6 @@ export class DirectedGraph<
|
|||
return removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) - Constant time for Map operations.
|
||||
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) - Constant time for Map operations.
|
||||
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
||||
|
@ -272,11 +242,6 @@ export class DirectedGraph<
|
|||
return this._vertexMap.delete(vertexKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
||||
* Space Complexity: O(1)
|
||||
|
@ -302,11 +267,6 @@ export class DirectedGraph<
|
|||
return removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -324,11 +284,6 @@ export class DirectedGraph<
|
|||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -346,11 +301,6 @@ export class DirectedGraph<
|
|||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -363,11 +313,6 @@ export class DirectedGraph<
|
|||
return this.outDegreeOf(vertexOrKey) + this.inDegreeOf(vertexOrKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -380,11 +325,6 @@ export class DirectedGraph<
|
|||
return this.incomingEdgesOf(vertexOrKey).length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -397,11 +337,6 @@ export class DirectedGraph<
|
|||
return this.outgoingEdgesOf(vertexOrKey).length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -414,11 +349,6 @@ export class DirectedGraph<
|
|||
return [...this.outgoingEdgesOf(vertexOrKey), ...this.incomingEdgesOf(vertexOrKey)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -431,11 +361,6 @@ export class DirectedGraph<
|
|||
return this._getVertex(e.src);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -448,11 +373,6 @@ export class DirectedGraph<
|
|||
return this._getVertex(e.dest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
||||
* Space Complexity: O(1)
|
||||
|
@ -477,11 +397,6 @@ export class DirectedGraph<
|
|||
return destinations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
|
||||
* Space Complexity: O(|V|)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
|
||||
* Space Complexity: O(|V|)
|
||||
|
@ -531,11 +446,6 @@ export class DirectedGraph<
|
|||
return sorted.reverse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
||||
* Space Complexity: O(|E|)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
||||
* Space Complexity: O(|E|)
|
||||
|
@ -551,11 +461,6 @@ export class DirectedGraph<
|
|||
return edgeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
||||
* Space Complexity: O(1)
|
||||
|
@ -581,11 +486,6 @@ export class DirectedGraph<
|
|||
return neighbors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -618,11 +518,6 @@ export class DirectedGraph<
|
|||
return this.vertexMap.size === 0 && this.inEdgeMap.size === 0 && this.outEdgeMap.size === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -648,13 +543,6 @@ export class DirectedGraph<
|
|||
return cloned;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(V + E)
|
||||
* Space Complexity: O(V)
|
||||
* Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
|
||||
* Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(V + E)
|
||||
* Space Complexity: O(V)
|
||||
|
@ -717,11 +605,6 @@ export class DirectedGraph<
|
|||
return { dfnMap, lowMap, SCCs };
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(V + E) - Depends on the implementation (Tarjan's algorithm).
|
||||
* Space Complexity: O(V) - Depends on the implementation (Tarjan's algorithm).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(V + E) - Depends on the implementation (Tarjan's algorithm).
|
||||
* Space Complexity: O(V) - Depends on the implementation (Tarjan's algorithm).
|
||||
|
@ -753,11 +636,6 @@ export class DirectedGraph<
|
|||
return this.tarjan().SCCs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
|
|
@ -96,11 +96,6 @@ export class UndirectedGraph<
|
|||
return new UndirectedEdge(v1, v2, weight ?? 1, value) as EO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
|
||||
* Space Complexity: O(1)
|
||||
|
@ -127,11 +122,6 @@ export class UndirectedGraph<
|
|||
return edgeMap ? edgeMap[0] || undefined : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
|
||||
* Space Complexity: O(1)
|
||||
|
@ -162,11 +152,6 @@ export class UndirectedGraph<
|
|||
return removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
|
||||
* Space Complexity: O(1)
|
||||
|
@ -201,11 +186,6 @@ export class UndirectedGraph<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) - Constant time for Map operations.
|
||||
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) - Constant time for Map operations.
|
||||
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
||||
|
@ -244,11 +224,6 @@ export class UndirectedGraph<
|
|||
return this._vertexMap.delete(vertexKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -268,11 +243,6 @@ export class UndirectedGraph<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -291,11 +261,6 @@ export class UndirectedGraph<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
|
||||
* Space Complexity: O(|E|)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
|
||||
* Space Complexity: O(|E|)
|
||||
|
@ -313,11 +278,6 @@ export class UndirectedGraph<
|
|||
return [...edgeSet];
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
|
||||
* Space Complexity: O(|E|)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
|
||||
* Space Complexity: O(|E|)
|
||||
|
@ -342,11 +302,6 @@ export class UndirectedGraph<
|
|||
return neighbors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -378,11 +333,6 @@ export class UndirectedGraph<
|
|||
return this.vertexMap.size === 0 && this.edgeMap.size === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -410,11 +360,6 @@ export class UndirectedGraph<
|
|||
return cloned;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(V + E)
|
||||
* Space Complexity: O(V)
|
||||
|
@ -484,13 +429,6 @@ export class UndirectedGraph<
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(V + E)
|
||||
* Space Complexity: O(V)
|
||||
* Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
|
||||
* 1. Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time
|
||||
*/
|
||||
|
||||
/**
|
||||
* The function "getBridges" returns an array of bridges in a graph using the Tarjan's algorithm.
|
||||
* @returns The function `getBridges()` is returning the bridges found using the Tarjan's algorithm.
|
||||
|
|
|
@ -234,9 +234,7 @@ export class HashMap<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* The clone function creates a new HashMap with the same key-value pairs as
|
||||
* this one. The clone function is useful for creating a copy of an existing
|
||||
* HashMap, and then modifying that copy without affecting the original.
|
||||
|
@ -247,11 +245,6 @@ export class HashMap<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|||
return new HashMap<K, V, R>(this, { hashFn: this._hashFn, toEntryFn: this._toEntryFn });
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -479,11 +472,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|||
return this._size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -497,11 +485,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|||
return <[K, V]>[this.head.key, this.head.value];
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -538,11 +521,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -642,11 +620,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -672,11 +645,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -697,11 +665,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|||
return node.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -744,11 +707,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -767,11 +725,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|||
return this._deleteNode(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -794,11 +747,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|||
return Array.isArray(rawElement) && rawElement.length === 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -811,11 +759,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|||
this._head = this._tail = this._sentinel.prev = this._sentinel.next = this._sentinel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -834,11 +777,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|||
return cloned;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -866,11 +804,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|||
return filteredMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -899,12 +832,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|||
return mappedMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
* where n is the number of entries in the LinkedHashMap.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -920,11 +847,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
|
|
@ -560,11 +560,6 @@ export class FibonacciHeap<E> {
|
|||
return this.min ? this.min.element : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
||||
* Space Complexity: O(1)
|
||||
|
@ -612,11 +607,6 @@ export class FibonacciHeap<E> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -628,11 +618,6 @@ export class FibonacciHeap<E> {
|
|||
return this.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -667,11 +652,6 @@ export class FibonacciHeap<E> {
|
|||
return z.element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -732,11 +712,6 @@ export class FibonacciHeap<E> {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -755,11 +730,6 @@ export class FibonacciHeap<E> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -774,11 +744,6 @@ export class FibonacciHeap<E> {
|
|||
if (node.right) node.right.left = node.left;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -797,11 +762,6 @@ export class FibonacciHeap<E> {
|
|||
y.parent = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n log n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n log n)
|
||||
* Space Complexity: O(n)
|
||||
|
|
|
@ -133,12 +133,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return this._size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
* where n is the number of elements in the linked list.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -150,11 +144,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return this.head?.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -166,11 +155,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return this.tail?.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -187,9 +171,7 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* The push function adds a new element to the end of a doubly linked list.
|
||||
* @param {E} element - The "element" parameter represents the value that you want to add to the
|
||||
* doubly linked list.
|
||||
|
@ -212,9 +194,7 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* The `pop()` function removes and returns the value of the last element in a linked list.
|
||||
* @returns The method is returning the value of the removed node.
|
||||
*/
|
||||
|
@ -235,9 +215,7 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* The `shift()` function removes and returns the value of the first element in a doubly linked list.
|
||||
* @returns The value of the removed node.
|
||||
*/
|
||||
|
@ -258,9 +236,7 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* The unshift function adds a new element to the beginning of a doubly linked list.
|
||||
* @param {E} element - The "element" parameter represents the value of the element that you want to
|
||||
* add to the beginning of the doubly linked list.
|
||||
|
@ -280,11 +256,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -304,11 +275,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return current!.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -329,11 +295,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -357,11 +318,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -396,12 +352,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) or O(n)
|
||||
* Space Complexity: O(1)
|
||||
* where n is the number of elements in the linked list.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) or O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -442,11 +392,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) or O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) or O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -516,11 +461,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) or O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1) or O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -557,11 +497,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -573,11 +508,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return this.size === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -590,11 +520,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
this._size = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -618,11 +543,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -645,11 +565,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -667,11 +582,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -689,11 +599,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -711,11 +616,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -729,11 +629,6 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return new DoublyLinkedList<E, R>(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -766,9 +661,7 @@ export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* The `map` function takes a callback function and returns a new DoublyLinkedList with the results
|
||||
* of applying the callback to each element in the original list.
|
||||
* @param callback - The callback parameter is a function that will be called for each element in the
|
||||
|
|
|
@ -121,13 +121,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return this._size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
* Linear time, where n is the length of the input array, as it performs a loop to push each element into the linked list.
|
||||
* Linear space, as it creates a new node for each element in the array.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -145,11 +138,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return singlyLinkedList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -172,12 +160,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
* Linear time in the worst case, as it may need to traverse the list to find the last element.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -207,11 +189,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -227,11 +204,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return removedNode.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -254,11 +226,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -278,11 +245,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return current!.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -301,11 +263,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -334,11 +291,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -383,11 +335,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -437,13 +384,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
this._size = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
* Linear time, where n is the length of the list, as it needs to traverse the entire list to convert it to an array.
|
||||
* Linear space, as it creates an array with the same length as the list.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -461,11 +401,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -491,11 +426,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -520,11 +450,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -548,11 +473,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -593,11 +513,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -632,11 +547,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -659,11 +569,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -677,11 +582,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
return new SinglyLinkedList<E, R>(this, { toElementFn: this.toElementFn });
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -714,9 +614,7 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
|
|||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* The `map` function takes a callback function and returns a new SinglyLinkedList with the results
|
||||
* of applying the callback to each element in the original list.
|
||||
* @param callback - The `callback` parameter is a function that will be called for each element in
|
||||
|
|
|
@ -80,11 +80,6 @@ export class SkipList<K, V> {
|
|||
return this._probability;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -97,11 +92,6 @@ export class SkipList<K, V> {
|
|||
return firstNode ? firstNode.value : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -119,11 +109,6 @@ export class SkipList<K, V> {
|
|||
return current.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -155,11 +140,6 @@ export class SkipList<K, V> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -189,9 +169,7 @@ export class SkipList<K, V> {
|
|||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* The function checks if a key exists in a data structure.
|
||||
* @param {K} key - The parameter "key" is of type K, which represents the type of the key being
|
||||
* checked.
|
||||
|
@ -201,11 +179,6 @@ export class SkipList<K, V> {
|
|||
return this.get(key) !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -244,11 +217,6 @@ export class SkipList<K, V> {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -268,11 +236,6 @@ export class SkipList<K, V> {
|
|||
return nextNode ? nextNode.value : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(log n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -297,12 +260,6 @@ export class SkipList<K, V> {
|
|||
return lastLess ? lastLess.value : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(maxLevel)
|
||||
* Space Complexity: O(1)
|
||||
* where maxLevel is the maximum level of the SkipList, as it may iterate up to maxLevel times in the worst case.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(maxLevel)
|
||||
* Space Complexity: O(1)
|
||||
|
|
|
@ -176,11 +176,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return this._buckets[this._bucketLast][this._lastInBucket];
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity - Amortized O(1) (possible reallocation)
|
||||
* Space Complexity - O(n) (due to potential resizing).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity - Amortized O(1) (possible reallocation),
|
||||
* Space Complexity - O(n) (due to potential resizing).
|
||||
|
@ -209,11 +204,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -240,11 +230,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: Amortized O(1)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: Amortized O(1)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -274,11 +259,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -306,11 +286,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -322,11 +297,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return this.size === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -364,11 +334,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -385,11 +350,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return this._buckets[bucketIndex][indexInBucket]!;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -407,11 +367,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -446,11 +401,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -484,11 +434,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1) or O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1) or O(n)
|
||||
|
@ -525,11 +470,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1) or O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1) or O(n)
|
||||
|
@ -559,11 +499,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -591,11 +526,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -617,11 +547,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -647,11 +572,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n log n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n log n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -674,11 +594,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -709,11 +624,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
this._buckets = newBuckets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -734,11 +644,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -750,11 +655,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return [...this];
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -768,11 +668,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return new Deque<E, R>(this, { bucketSize: this.bucketSize, toElementFn: this.toElementFn });
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -804,9 +699,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* The `map` function takes a callback function and applies it to each element in the deque,
|
||||
* returning a new deque with the results.
|
||||
* @param callback - The callback parameter is a function that will be called for each element in the
|
||||
|
@ -835,11 +728,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
return newDeque;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -853,11 +741,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -889,11 +772,6 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|||
this._bucketCount = newBuckets.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
|
|
@ -61,11 +61,6 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
|
|||
return this.elements.length - this.offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -78,11 +73,6 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
|
|||
return this.size > 0 ? this.elements[this.offset] : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -114,11 +104,6 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
|
|||
this._autoCompactRatio = v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -133,11 +118,6 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
|
|||
return new Queue(elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -151,11 +131,6 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -194,11 +169,6 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
|
|||
return spliced.length === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -209,11 +179,6 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
|
|||
return this.elements[index + this._offset];
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -225,11 +190,6 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
|
|||
return this.size === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -241,11 +201,6 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
|
|||
return this.elements.slice(this.offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -268,12 +223,6 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
* where n is the number of elements in the queue. It creates a shallow copy of the internal array. the space required is proportional to the number of elements in the queue.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -285,11 +234,6 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
|
|||
return new Queue(this.elements.slice(this.offset), { toElementFn: this.toElementFn });
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -322,7 +266,6 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
|
|||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
map<EM, RM>(
|
||||
callback: ElementCallback<E, R, EM, Queue<E, R>>,
|
||||
toElementFn?: (rawElement: RM) => EM,
|
||||
|
@ -337,11 +280,6 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
|
|||
return newDeque;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -362,11 +300,6 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
|
|||
* 4. Frequent Enqueuing and Dequeuing Operations: If your application involves frequent enqueuing and dequeuing operations and is less concerned with random access, then LinkedListQueue is a good choice.
|
||||
*/
|
||||
export class LinkedListQueue<E = any, R = any> extends SinglyLinkedList<E, R> {
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
|
|
@ -74,11 +74,6 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E,
|
|||
return this.elements.length === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -92,11 +87,6 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E,
|
|||
return this.elements[this.elements.length - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -110,11 +100,6 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E,
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -149,11 +134,6 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E,
|
|||
return spliced.length === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -165,11 +145,6 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E,
|
|||
return this.elements.slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -180,11 +155,6 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E,
|
|||
this._elements = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -196,11 +166,6 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E,
|
|||
return new Stack<E, R>(this, { toElementFn: this.toElementFn });
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -232,9 +197,7 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E,
|
|||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* The `map` function takes a callback function and applies it to each element in the stack,
|
||||
* returning a new stack with the results.
|
||||
* @param callback - The callback parameter is a function that will be called for each element in the
|
||||
|
@ -262,11 +225,6 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E,
|
|||
return newStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
|
|
@ -147,11 +147,6 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|||
return this._root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(l), where l is the length of the word being added.
|
||||
* Space Complexity: O(l) - Each character in the word adds a TrieNode.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(l), where l is the length of the word being added.
|
||||
* Space Complexity: O(l) - Each character in the word adds a TrieNode.
|
||||
|
@ -180,11 +175,6 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|||
return isNewWord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(l), where l is the length of the input word.
|
||||
* Space Complexity: O(1) - Constant space.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(l), where l is the length of the input word.
|
||||
* Space Complexity: O(1) - Constant space.
|
||||
|
@ -204,11 +194,6 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|||
return cur.isEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -220,11 +205,6 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|||
return this.size === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(1)
|
||||
* Space Complexity: O(1)
|
||||
|
@ -236,11 +216,6 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|||
this._root = new TrieNode('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(l), where l is the length of the word being deleted.
|
||||
* Space Complexity: O(n) - Due to the recursive DFS approach.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(l), where l is the length of the word being deleted.
|
||||
* Space Complexity: O(n) - Due to the recursive DFS approach.
|
||||
|
@ -285,11 +260,6 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|||
return isDeleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
||||
* Space Complexity: O(1) - Constant space.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
||||
* Space Complexity: O(1) - Constant space.
|
||||
|
@ -315,11 +285,6 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|||
return maxDepth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(l), where l is the length of the input prefix.
|
||||
* Space Complexity: O(1) - Constant space.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(l), where l is the length of the input prefix.
|
||||
* Space Complexity: O(1) - Constant space.
|
||||
|
@ -339,11 +304,6 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|||
return !cur.isEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(l), where l is the length of the input prefix.
|
||||
* Space Complexity: O(1) - Constant space.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(l), where l is the length of the input prefix.
|
||||
* Space Complexity: O(1) - Constant space.
|
||||
|
@ -363,11 +323,6 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
||||
* Space Complexity: O(l), where l is the length of the input prefix.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
||||
* Space Complexity: O(l), where l is the length of the input prefix.
|
||||
|
@ -390,11 +345,6 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|||
return commonPre === input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
||||
* Space Complexity: O(l), where l is the length of the longest common prefix.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
||||
* Space Complexity: O(l), where l is the length of the longest common prefix.
|
||||
|
@ -414,11 +364,6 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|||
return commonPre;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
|
||||
* Space Complexity: O(w * l) - The space required for the output array.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
|
||||
* Space Complexity: O(w * l) - The space required for the output array.
|
||||
|
@ -468,11 +413,6 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|||
return words;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -485,11 +425,6 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|||
return new Trie<R>(this, { caseSensitive: this.caseSensitive, toElementFn: this.toElementFn });
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -516,11 +451,6 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -553,11 +483,6 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|||
return newTrie;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(n)
|
||||
* Space Complexity: O(n)
|
||||
|
@ -578,11 +503,6 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|||
yield* _dfs(this.root, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Time Complexity: O(l), where l is the length of the input string.
|
||||
* Space Complexity: O(1) - Constant space.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time Complexity: O(l), where l is the length of the input string.
|
||||
* Space Complexity: O(1) - Constant space.
|
||||
|
|
Loading…
Reference in a new issue