BST Playground module can be used to try out BST algorithms.
$ npm install bst-playground
0.3.0
- createNode(value)
- createTree(inOrder, postOrder)
- class Node
- depth()
- find(value)
- height()
- isBst()
- lca(values)
- visitInOrder()
- visitPostOrder()
returns a node with the given value. value is number type.
creates tree with the given inOrder and postOrder traversals - both arrays. return the root node of the tree.
returns depth of a node. from wikipedia: The depth of a node is the number of edges from the node to the tree's root node.
finds & returns node with value. otherwise, undefined.
returns true if the subtree at this node is BST. otherwise, false.
returns least common ancestor of the given nodes (values). If none, returns undefined.
returns height of a node. from wikipedia: The height of a node is the number of edges on the longest downward path between that node and a leaf
visits tree in in order and returns the values in an array.
visits tree in post order and returns the values in an array.
MIT