Tiny Binary Search Tree
tiny-bst is a micro BST library for the browser or server. tiny-bst can be installed from npm & bower, and supports AMD loaders or script tags. When loaded as a script, tiny-bst is available as 'bst()'.
Finds a Node in the BST
Adds a Node to the BST
Removes a Node from the BST
Returns a reverse sorted Array of the BST
Returns the data
property of a Node
Returns a sorted Array of the BST
var bst = require("tiny-bst"),
mybst = bst();
mybst.insert(3);
mybst.insert(24);
mybst.insert(1);
mybst.sort(); // [1, 3, 24]
mybst.reverse(); // [24, 3, 1]
mybst.find(3).left.show(); // 1
mybst.remove(3);
mybst.root.show(); // 24
mybst.root.left.show(); // 1
var bst = require("tiny-bst"),
mybst = bst();
mybst.insert(3, {abc: true});
mybst.insert(24, {abc: false});
mybst.insert(1, {abc: true});
mybst.sort(); // [1, 3, 24]
mybst.reverse(); // [24, 3, 1]
mybst.find(3).left.show(); // {abc: true}
mybst.remove(3);
mybst.root.show(); // {abc: false}
mybst.root.left.show(); // {abc: true}
Copyright (c) 2014 Jason Mulligan
Licensed under the BSD-3 license.