From 18fe0066528051b3acfefc9803a31b8bd168ccdc Mon Sep 17 00:00:00 2001 From: Revone Date: Mon, 21 Oct 2024 21:34:51 +1300 Subject: [PATCH] style: Remove unnecessary comments. --- .../base/iterable-element-base.ts | 40 ---- .../base/iterable-entry-base.ts | 59 ------ .../binary-tree/avl-tree-multi-map.ts | 40 ---- src/data-structures/binary-tree/avl-tree.ts | 57 ------ .../binary-tree/binary-tree.ts | 192 ------------------ src/data-structures/binary-tree/bst.ts | 50 ----- src/data-structures/binary-tree/rb-tree.ts | 60 ------ .../binary-tree/tree-multi-map.ts | 40 ---- src/data-structures/graph/abstract-graph.ts | 92 --------- src/data-structures/graph/directed-graph.ts | 122 ----------- src/data-structures/graph/undirected-graph.ts | 62 ------ src/data-structures/hash/hash-map.ts | 80 +------- src/data-structures/heap/heap.ts | 40 ---- .../linked-list/doubly-linked-list.ts | 117 +---------- .../linked-list/singly-linked-list.ts | 104 +--------- .../linked-list/skip-linked-list.ts | 45 +--- src/data-structures/queue/deque.ts | 124 +---------- src/data-structures/queue/queue.ts | 67 ------ src/data-structures/stack/stack.ts | 44 +--- src/data-structures/trie/trie.ts | 80 -------- 20 files changed, 10 insertions(+), 1505 deletions(-) diff --git a/src/data-structures/base/iterable-element-base.ts b/src/data-structures/base/iterable-element-base.ts index c98127e..fb1f9bf 100644 --- a/src/data-structures/base/iterable-element-base.ts +++ b/src/data-structures/base/iterable-element-base.ts @@ -29,10 +29,6 @@ export abstract class IterableElementBase { 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 { 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 { } } - /** - * Time Complexity: O(n) - * Space Complexity: O(1) - */ /** * Time Complexity: O(n) * Space Complexity: O(1) @@ -90,15 +78,6 @@ export abstract class IterableElementBase { 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 { 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 { } } - /** - * Time Complexity: O(n) - * Space Complexity: O(1) - */ - /** * Time Complexity: O(n) * Space Complexity: O(1) @@ -195,10 +164,6 @@ export abstract class IterableElementBase { 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 { return accumulator; } - /** - * Time Complexity: O(n) - * Space Complexity: O(n) - */ - /** * Time Complexity: O(n) * Space Complexity: O(n) diff --git a/src/data-structures/base/iterable-entry-base.ts b/src/data-structures/base/iterable-entry-base.ts index f2c84a3..96e4cd2 100644 --- a/src/data-structures/base/iterable-entry-base.ts +++ b/src/data-structures/base/iterable-entry-base.ts @@ -9,11 +9,6 @@ export abstract class IterableEntryBase { // } // } - /** - * Time Complexity: O(n) - * Space Complexity: O(1) - */ - abstract get size(): number; // protected _toEntryFn?: (rawElement: R) => BTNEntry; @@ -39,10 +34,6 @@ export abstract class IterableEntryBase { 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 { } } - /** - * Time Complexity: O(n) - * Space Complexity: O(n) - */ /** * Time Complexity: O(n) * Space Complexity: O(n) @@ -72,10 +59,6 @@ export abstract class IterableEntryBase { } } - /** - * Time Complexity: O(n) - * Space Complexity: O(n) - */ /** * Time Complexity: O(n) * Space Complexity: O(n) @@ -88,10 +71,6 @@ export abstract class IterableEntryBase { } } - /** - * Time Complexity: O(n) - * Space Complexity: O(1) - */ /** * Time Complexity: O(n) * Space Complexity: O(1) @@ -116,10 +95,6 @@ export abstract class IterableEntryBase { 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 { 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 { } } - /** - * Time Complexity: O(n) - * Space Complexity: O(1) - */ - /** * Time Complexity: O(n) * Space Complexity: O(1) @@ -206,11 +167,6 @@ export abstract class IterableEntryBase { 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 { 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 { 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 { return accumulator; } - /** - * Time Complexity: O(n) - * Space Complexity: O(n) - */ - /** * Time Complexity: O(n) * Space Complexity: O(n) diff --git a/src/data-structures/binary-tree/avl-tree-multi-map.ts b/src/data-structures/binary-tree/avl-tree-multi-map.ts index aeb2b54..b1a7304 100644 --- a/src/data-structures/binary-tree/avl-tree-multi-map.ts +++ b/src/data-structures/binary-tree/avl-tree-multi-map.ts @@ -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) diff --git a/src/data-structures/binary-tree/avl-tree.ts b/src/data-structures/binary-tree/avl-tree.ts index e906d7d..1c77312 100644 --- a/src/data-structures/binary-tree/avl-tree.ts +++ b/src/data-structures/binary-tree/avl-tree.ts @@ -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) diff --git a/src/data-structures/binary-tree/binary-tree.ts b/src/data-structures/binary-tree/binary-tree.ts index 2166e8a..a1660c9 100644 --- a/src/data-structures/binary-tree/binary-tree.ts +++ b/src/data-structures/binary-tree/binary-tree.ts @@ -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>(identifier: ReturnType, callback: C): BinaryTreeDeleteResult[]; - /** - * 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; - /** - * 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[]; - /** - * 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[]; - /** - * 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[][]; - /** - * 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[]; - /** - * 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.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) diff --git a/src/data-structures/binary-tree/bst.ts b/src/data-structures/binary-tree/bst.ts index 6adaa0e..74f7a02 100644 --- a/src/data-structures/binary-tree/bst.ts +++ b/src/data-structures/binary-tree/bst.ts @@ -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 = 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. diff --git a/src/data-structures/binary-tree/rb-tree.ts b/src/data-structures/binary-tree/rb-tree.ts index 8dd2ad9..f3bf084 100644 --- a/src/data-structures/binary-tree/rb-tree.ts +++ b/src/data-structures/binary-tree/rb-tree.ts @@ -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) diff --git a/src/data-structures/binary-tree/tree-multi-map.ts b/src/data-structures/binary-tree/tree-multi-map.ts index ea84c0d..9abf70e 100644 --- a/src/data-structures/binary-tree/tree-multi-map.ts +++ b/src/data-structures/binary-tree/tree-multi-map.ts @@ -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) diff --git a/src/data-structures/graph/abstract-graph.ts b/src/data-structures/graph/abstract-graph.ts index 813a286..63925fd 100644 --- a/src/data-structures/graph/abstract-graph.ts +++ b/src/data-structures/graph/abstract-graph.ts @@ -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) diff --git a/src/data-structures/graph/directed-graph.ts b/src/data-structures/graph/directed-graph.ts index 0afe9fd..358b568 100644 --- a/src/data-structures/graph/directed-graph.ts +++ b/src/data-structures/graph/directed-graph.ts @@ -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) diff --git a/src/data-structures/graph/undirected-graph.ts b/src/data-structures/graph/undirected-graph.ts index ddac0db..8223150 100644 --- a/src/data-structures/graph/undirected-graph.ts +++ b/src/data-structures/graph/undirected-graph.ts @@ -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. diff --git a/src/data-structures/hash/hash-map.ts b/src/data-structures/hash/hash-map.ts index 5f8534a..f89d79c 100644 --- a/src/data-structures/hash/hash-map.ts +++ b/src/data-structures/hash/hash-map.ts @@ -234,9 +234,7 @@ export class HashMap extends IterableEntryBase extends IterableEntryBase(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 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 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 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 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 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 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 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 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 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 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 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 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 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 extends IterableEntryBa } } - /** - * Time Complexity: O(1) - * Space Complexity: O(1) - */ - /** * Time Complexity: O(1) * Space Complexity: O(1) diff --git a/src/data-structures/heap/heap.ts b/src/data-structures/heap/heap.ts index 4dc5748..8573a81 100644 --- a/src/data-structures/heap/heap.ts +++ b/src/data-structures/heap/heap.ts @@ -560,11 +560,6 @@ export class FibonacciHeap { 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 { } } - /** - * 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 { 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 { 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 { 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 { } } - /** - * Time Complexity: O(1) - * Space Complexity: O(1) - */ - /** * Time Complexity: O(1) * Space Complexity: O(1) @@ -774,11 +744,6 @@ export class FibonacciHeap { 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 { y.parent = x; } - /** - * Time Complexity: O(n log n) - * Space Complexity: O(n) - */ - /** * Time Complexity: O(n log n) * Space Complexity: O(n) diff --git a/src/data-structures/linked-list/doubly-linked-list.ts b/src/data-structures/linked-list/doubly-linked-list.ts index 01cfdd2..18fd125 100644 --- a/src/data-structures/linked-list/doubly-linked-list.ts +++ b/src/data-structures/linked-list/doubly-linked-list.ts @@ -133,12 +133,6 @@ export class DoublyLinkedList extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase(this); } - /** - * Time Complexity: O(n) - * Space Complexity: O(n) - */ - /** * Time Complexity: O(n) * Space Complexity: O(n) @@ -766,9 +661,7 @@ export class DoublyLinkedList extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase(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 extends IterableElementBase { 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 { 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 { 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 { } } - /** - * 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 { /** * 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 { 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 { 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 { 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 { 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) diff --git a/src/data-structures/queue/deque.ts b/src/data-structures/queue/deque.ts index 617b37a..939ed15 100644 --- a/src/data-structures/queue/deque.ts +++ b/src/data-structures/queue/deque.ts @@ -176,11 +176,6 @@ export class Deque extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase(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 extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase 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 extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase( callback: ElementCallback>, toElementFn?: (rawElement: RM) => EM, @@ -337,11 +280,6 @@ export class Queue extends IterableElementBase extends IterableElementBase extends SinglyLinkedList { - /** - * Time Complexity: O(n) - * Space Complexity: O(n) - */ - /** * Time Complexity: O(n) * Space Complexity: O(n) diff --git a/src/data-structures/stack/stack.ts b/src/data-structures/stack/stack.ts index 508e575..2ecbfb0 100644 --- a/src/data-structures/stack/stack.ts +++ b/src/data-structures/stack/stack.ts @@ -74,11 +74,6 @@ export class Stack extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase extends IterableElementBase(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 extends IterableElementBase extends IterableElementBase extends IterableElementBase> { 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 extends IterableElementBase> { 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 extends IterableElementBase> { 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 extends IterableElementBase> { 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 extends IterableElementBase> { 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 extends IterableElementBase> { 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 extends IterableElementBase> { 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 extends IterableElementBase> { 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 extends IterableElementBase> { 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 extends IterableElementBase> { 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 extends IterableElementBase> { 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 extends IterableElementBase> { 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 extends IterableElementBase> { return new Trie(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 extends IterableElementBase> { 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 extends IterableElementBase> { 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 extends IterableElementBase> { 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.