-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to DSA Toolbox, a comprehensive library of data structures and algorithms designed to streamline your development process! This library is built for JavaScript and TypeScript, offering both fundamental and advanced data structures, search algorithms, sort algorithms, and more.
Whether you're building a lightweight application or handling large datasets, DSA Toolbox provides an optimized library to make your coding journey efficient and fun.
DSA Toolbox offers a variety of powerful toolbox:
- Binary Search
- Exponential Search
- Hybrid Search
- Linear Search
- Ternary Search
- HeapSort
- MergeSort
- TimSort
- LFU (Least Frequently Used)
- LRU (Least Recently Used)
- Heaps: MaxHeap, MinHeap
- Linked Lists: Singly Linked List, Doubly Linked List
- Queues & Stacks
- Treaps (Binary Search Tree with heap properties)
- Trees: AVL Tree, Red-Black Tree, Binary Search Tree, B-Tree, Trie
- Probabilistic Structures: Bloom Filter, HyperLogLog, CountMinSketch, SkipList, MinHash, SimHash, TDigest
To install the DSA Toolbox:
pnpm add dsa-toolbox
Then you can import the Data Structure or the Algorithm you want to use:
import {
binarySearch,
exponentialSearch,
hybridSearch,
linearSearch,
ternarySearch,
heapSort,
mergeSort,
timSort,
LFUCache,
LRUCache,
MaxHeap,
MinHeap,
DoublyLinkedList,
LinkedList,
HyperLogLog,
CountMinSketch,
BloomFilter,
SkipList,
TDigest,
MinHash,
SimHash,
Queue,
Stack,
Treap,
AVLTree,
BTree,
BinarySearchTree,
RedBlackTree,
Trie,
} from 'dsa-toolbox';
binarySearch(sortedData, target, { compareFn: (a, b) => a - b, isSorted: true });
ternarySearch(data, target, 0, sortedData.length - 1, {
compareFn: (a, b) => a - b,
isSorted: false,
});
const queue = new Queue<number>();
data.forEach((item) => queue.enqueue(item));
const avlTree = new AVLTree<number>();
avlTree.insert(10);
avlTree.insert(20);
avlTree.insert(5);
avlTree.insert(4);
avlTree.insert(15);
avlTree.search(10);
More usage examples can be found here:
- https://github.com/helabenkhalfallah/dsa-toolbox/blob/main/benchmark-algo.ts
- https://github.com/helabenkhalfallah/dsa-toolbox/blob/main/benchmark-ds.ts
- In tests files, for example:
For detailed explanations of each data structure and algorithm, please visit:
- Trees in Data Structures: More than Just Wood
- Heaps: Beyond First-Come-First-Served Queue Wizard
- Yet Another Way to Balance BSTs: The Treaps Approach
- The Secret Life of Caches: A Deep Dive into LRU and LFU
- Probabilistic Data Structures for Large Data Challenges
The goal of DSA Toolbox is to provide high-performance and versatile solutions for everyday programming needs. Whether you're building applications that require fast search and sort, or you're working with large datasets and need to optimize storage, DSA Toolbox has you covered.
If you have any questions or need support, feel free to:
- Open an issue on GitHub
- Reach out through discussions
DSA Toolbox is open-source and available under the MIT License.
For contributions, we invite you to read our Contributing Guide to get started and ensure a smooth process.
Let's code smarter and more efficiently with DSA Toolbox! ๐