New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

js-tree-utils

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-tree-utils

Node Binary Search Tree Library

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Node Binary Search Tree Library

Includes a standard Binary Search Tree, AVL Tree and Red-Black Tree.

Please star if you like this repo :)

Quick Start

$ npm install node-tree --save

Standard Binary Search Tree

Worst case big O notation:

  • Space: O(n)
  • Search: O(n)
  • Insert: O(n)
  • Delete: O(n)

Binary Search Tree Usage

Include a binary search tree:

var BinarySearchTree = require('node-tree').BinarySearchTree;

Create Binary Search Tree and optionally pass in options:

var options = {
  // options here
};

var btree = new BinarySearchTree(options);

Insert records (key, value):

btree.insert(12, 'test');

Check if tree contains a key:

var key = btree.contains(5);
console.log('Has 5?: ', key);

Return the tree in order:

var list = btree.inOrder();

Get the max key of tree:

btree.maxKey()

Get the min key of tree:

btree.minKey()

Get the size of tree:

btree.size()

AVL Tree

Worst case big O notation:

  • Space: O(n)
  • Search: O(log n)
  • Insert: O(log n)
  • Delete: O(log n)

AVL Tree Usage

Include a avl search tree:

var AvlTree = require('node-tree').AvlTree;

Create AVL and optionally pass in options:

var options = {
  // options here
};

var avlTree = new AvlTree(options);

An Avl Tree has the same methods available as the standard BST.

Keywords

FAQs

Package last updated on 16 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc