This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use: var tree = new OST(); tree.select(4); tree.insert(key,value) | |
var OST = function () { | |
// Order statistic tree node | |
var Node = function (leftChild, key, value, rightChild, parent) { | |
return { | |
leftChild: (typeof leftChild === "undefined") ? null : | |
leftChild, | |
key: (typeof key === "undefined") ? null : key, | |
value: (typeof value === "undefined") ? null : value, | |
rightChild: (typeof rightChild === "undefined") ? null : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* File: bst.js | |
* | |
* A pure JavaScript implementation of a binary search tree. | |
* | |
*/ | |
/* | |
* Class: BST | |
* |