Nuns Playing Monopoly

    Binary-search-tree

    0.0.1 • Public • Published

    BST : BinarySearchTree

    BST.js is a Javascript library for Binary Search Tree. A simple binary search tree data structure implementation in Javascript. This implementation does not allow duplicate values to be inserted into the tree, ensuring that there is just one instance of each value.

    Installing

    Using NPM:

    npm install bst

    Using Bower:

    bower install bst

    Getting Started

    BST js contains the following functions:

    • add
    • contains
    • minValue
    • removeTree
    • traversalTree
    • size
    • toArray
    • toString
    • maxDepth
    • remove etc.

    Let's see how it's actually works:

    JavaScript (Client Side):

    var binarySearchTree = new BST();	//initlize binary tree

    Node JS (Server Side):

    var bst = require('./BST.js');
    var binarySearchTree = new bst.BST()	//initlize binary tree

    Function Usage

    //Adding a node 
    binarySearchTree.add(23);
    binarySearchTree.add(89);
    
    //search an element
    binarySearchTree.contains(89);
    
    //Remove an element
    binarySearchTree.remove(89);
    
    //Traversing an binary search tree
    binarySearchTree.traversalTree({type:'inorder'},callback); //For inorder traversal
    binarySearchTree.traversalTree({type:'preorder'},callback); //For preorder traversal
    binarySearchTree.traversalTree({type:'postorder'},callback); //For postorder traversal
    
    //maximum depth of Binary search tree
    binarySearchTree.maxDepth();
    
    //Return binary search tree elements in array
    binarySearchTree.toArray();
    
    //Return binary search tree elements in string form
    binarySearchTree.toString();

    Authors

    License

    This project is licensed under the MIT License - see the LICENSE.md file for details

    Acknowledgments

    Install

    npm i Binary-search-tree

    DownloadsWeekly Downloads

    7

    Version

    0.0.1

    License

    none

    Last publish

    Collaborators

    • techhysahil