1.2.3 • Published 4 years ago

avl-trees-js v1.2.3

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

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
1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.0.0

4 years ago