avl-trees-js
v1.2.3
Published
A module to perform all the avl tree implementations using node.js.Minimizes height recursions hence faster
Downloads
5
Maintainers
Readme
avl-trees-js is a light package that allows you to perform all the avl tree operations efficiently
Installation
$ npm install avl-trees-js
Importing
// Using Node.js `require()`
const avl= require('avl-trees-js ');
// Using ES6 imports
import avl from 'avl-trees-js ';
###Insertion
avl.insert(value);
###Traversing you can traverse in: inOrder,postOrder and PreOrder
avl.traverse('orderToTraverse',cb());
e.g
avl.traverse('postOrder',cb());
by default you traverse in order i.e
avl.traverse(cb());
###Getting Maximum and Minimum
avl.Max()
returns the node with the maximum value. To get the value just add getData() to the retrieved node. note: .getData() retrieves the stored value in a node i.e
avl.Max().getData()
same applies to min except we use Min() in place of Max()
###deleting nodes from the tree
avl.remove(nodeValue)
removes the node with the value and rebalances the tree
###finding the node with the a given value
avl.find(nodeValue)
returns null incase no node with that value exists
###Testing
npm test