Skip to content

Instantly share code, notes, and snippets.

View taradinoc's full-sized avatar

Tara taradinoc

View GitHub Profile
@taradinoc
taradinoc / order statistic tree.js
Created December 18, 2020 01:46 — forked from davidfurlong/order statistic tree.js
Order statistic tree (Binary Search Tree with Rank and Size)
// 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 :