Javascript implementation of classic and advanced data structures.
Install via NPM:
$ npm install @styiannis/data-structures
Print data structures list
const ds = require('@styiannis/data-structures');
console.log( ds );
// Output:
{
'BTree': [Function: BTree],
'BinarySearchTree': [Function: BinarySearchTree],
'LeftThreadedBinarySearchTree': [Function: LeftThreadedBinarySearchTree],
'RedBlackTree': [Function: RedBlackTree],
'RightThreadedBinarySearchTree': [Function: RightThreadedBinarySearchTree],
'ThreadedBinarySearchTree': [Function: ThreadedBinarySearchTree]
}
Basic data structure usage
const { RedBlackTree } = require('@styiannis/data-structures');
// Create a Red-black tree
const rbt = RedBlackTree();
// Insert items into the tree
rbt.set( 46, 'foo' );
rbt.set( 13, 'baz' );
rbt.set( 75, 'bar' );
// Get tree item value specified by key
console.log( rbt.get( 13 ) ); // Output: 'baz'
// Check for key within the tree
console.log( rbt.has( 46 ) ); // Output: true
// Remove item from tree
console.log( rbt.delete( 75 ) ); // Output: true
- Red Black Tree
- Binary Search Tree
- Threaded Binary Search Tree
- Right Threaded Binary Search Tree
- Left Threaded Binary Search Tree
This project is licensed under the MIT License