
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
dst-typescript-collection
Advanced tools
๐ Complete TypeScript Data Structures Library: Linked List, Hash Map, Stack, Queue, Set, Tree, BST, AVL Tree, Red-Black Tree, Graph, Heap, Trie with 100% test coverage, loop detection, and comprehensive algorithms. Perfect for DSA learning, interviews, a
A comprehensive collection of data structures implemented in TypeScript with full test coverage.
MyLinkedList
)getSize()
, isEmpty()
, toArray()
, print()
, clear()
MyHashMap
)keys()
, values()
, entries()
, getCapacity()
, getLoadFactor()
MyStack
)isEmpty()
, isFull()
, size()
, search()
, contains()
MyQueue
)isEmpty()
, isFull()
, size()
, search()
, contains()
MySet
)add()
, delete()
, has()
, size()
, isEmpty()
MyTree
)addChild()
, remove()
, getHeight()
, getDepth()
, isBalanced()
MyBST
)insert()
, search()
, remove()
, findMin()
, findMax()
isValidBST()
, isBalanced()
, getSuccessor()
, getPredecessor()
hasLoop()
, getLoopCount()
, getLoopData()
, getLoopNodes()
MyAVLTree
)insert()
, search()
, remove()
, findMin()
, findMax()
isValidAVL()
, isBalanced()
, getNodeBalanceFactor()
, getNodeHeight()
MyRedBlackTree
)insert()
, search()
, remove()
, findMin()
, findMax()
isValidRedBlack()
, getNodeColor()
, isRed()
, isBlack()
, getParent()
, getSibling()
, getUncle()
MyGraph
)addVertex()
, addEdge()
, hasPath()
, getConnectedComponents()
MyHeap
)getMin()
, getMax()
, getKthElement()
, isValid()
MyTrie
)insert()
, search()
, startsWith()
, getWordsWithPrefix()
# Clone the repository
git clone <repository-url>
cd DST
# Install dependencies
npm install
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Build the project
npm run build
The project includes comprehensive test suites for all data structures:
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage report
npm run test:coverage
DST/
โโโ src/
โ โโโ DataStructures/
โ โ โโโ MyLinkedList.ts
โ โ โโโ MyHashMap.ts
โ โ โโโ MyStack.ts
โ โ โโโ MyQueue.ts
โ โ โโโ MySet.ts
โ โ โโโ MyTree.ts
โ โ โโโ MyBST.ts
โ โ โโโ MyAVLTree.ts
โ โ โโโ MyRedBlackTree.ts
โ โ โโโ MyGraph.ts
โ โ โโโ MyHeap.ts
โ โ โโโ MyTrie.ts
โ โโโ Test/
โ โ โโโ MyLinkedList.test.ts
โ โ โโโ MyHashMap.test.ts
โ โ โโโ MyStack.test.ts
โ โ โโโ MyQueue.test.ts
โ โ โโโ MySet.test.ts
โ โ โโโ MyTree.test.ts
โ โ โโโ MyBST.test.ts
โ โ โโโ MyAVLTree.test.ts
โ โ โโโ MyRedBlackTree.test.ts
โ โ โโโ MyGraph.test.ts
โ โ โโโ MyHeap.test.ts
โ โ โโโ MyTrie.test.ts
โ โโโ index.ts
โโโ package.json
โโโ tsconfig.json
โโโ jest.config.js
โโโ README.md
import { MyLinkedList } from './src/DataStructures/MyLinkedList';
const list = new MyLinkedList<number>();
list.append(1);
list.append(2);
list.prepend(0);
console.log(list.toArray()); // [0, 1, 2]
import { MyHashMap } from './src/DataStructures/MyHashMap';
const map = new MyHashMap<string, number>();
map.put('key1', 1);
map.put('key2', 2);
console.log(map.get('key1')); // 1
import { MyStack } from './src/DataStructures/MyStack';
const stack = new MyStack<number>();
stack.push(1);
stack.push(2);
console.log(stack.pop()); // 2
import { MyQueue } from './src/DataStructures/MyQueue';
const queue = new MyQueue<number>();
queue.enqueue(1);
queue.enqueue(2);
console.log(queue.dequeue()); // 1
import { MySet } from './src/DataStructures/MySet';
const set = new MySet<number>();
set.add(1);
set.add(2);
set.add(1); // Duplicate, won't be added
console.log(set.size()); // 2
import { MyTree } from './src/DataStructures/MyTree';
const tree = new MyTree<number>();
tree.addToRoot(1);
tree.addChild(1, 2);
tree.addChild(1, 3);
console.log(tree.preorder()); // [1, 2, 3]
import { MyBST } from './src/DataStructures/MyBST';
const bst = new MyBST<number>();
bst.insert(5);
bst.insert(3);
bst.insert(7);
console.log(bst.inorder()); // [3, 5, 7] (sorted)
console.log(bst.findMin()); // 3
console.log(bst.findMax()); // 7
console.log(bst.hasLoop()); // false (no loops in normal BST)
import { MyAVLTree } from './src/DataStructures/MyAVLTree';
const avl = new MyAVLTree<number>();
avl.insert(5);
avl.insert(3);
avl.insert(7);
avl.insert(1);
console.log(avl.inorder()); // [1, 3, 5, 7] (sorted)
console.log(avl.isBalanced()); // true (always balanced)
console.log(avl.getNodeBalanceFactor(5)); // 0 (balanced)
import { MyRedBlackTree } from './src/DataStructures/MyRedBlackTree';
const rbt = new MyRedBlackTree<number>();
rbt.insert(10);
rbt.insert(5);
rbt.insert(15);
rbt.insert(3);
rbt.insert(7);
console.log(rbt.inorder()); // [3, 5, 7, 10, 15] (sorted)
console.log(rbt.isValidRedBlack()); // true (validates RB properties)
console.log(rbt.getNodeColor(10)); // 'BLACK' (root is black)
console.log(rbt.isRed(5)); // true (some nodes are red)
import { MyGraph } from './src/DataStructures/MyGraph';
const graph = new MyGraph<string>();
graph.addVertex('A');
graph.addVertex('B');
graph.addEdge('A', 'B', 5);
console.log(graph.hasPath('A', 'B')); // true
import { MyHeap } from './src/DataStructures/MyHeap';
const heap = new MyHeap<number>(); // Min heap
heap.insert(3);
heap.insert(1);
heap.insert(2);
console.log(heap.peek()); // 1
import { MyTrie } from './src/DataStructures/MyTrie';
const trie = new MyTrie();
trie.insert('hello');
trie.insert('world');
console.log(trie.search('hello')); // true
console.log(trie.startsWith('hel')); // true
src/DataStructures/
src/Test/
src/index.ts
# Run all tests
npm test
# Run specific test file
npm test -- MyLinkedList.test.ts
# Run tests with verbose output
npm test -- --verbose
All data structures are optimized for:
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the ISC License - see the LICENSE file for details.
Happy Coding! ๐
FAQs
๐ Complete TypeScript Data Structures Library: Linked List, Hash Map, Stack, Queue, Set, Tree, BST, AVL Tree, Red-Black Tree, Graph, Heap, Trie with 100% test coverage, loop detection, and comprehensive algorithms. Perfect for DSA learning, interviews, a
The npm package dst-typescript-collection receives a total of 159 weekly downloads. As such, dst-typescript-collection popularity was classified as not popular.
We found that dst-typescript-collection demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.ย It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.