0.4.0 • Published 9 years ago

bst-playground v0.4.0

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

BST Playground

BST Playground module can be used to try out BST algorithms.

Installation

$ npm install bst-playground

Version

0.3.0

Functions

  • createNode(value)
  • createTree(inOrder, postOrder)
  • class Node
  • depth()
  • find(value)
  • height()
  • isBst()
  • lca(values)
  • visitInOrder()
  • visitPostOrder()

createNode(value)

returns a node with the given value. value is number type.

createTree(inOrder, postOrder)

creates tree with the given inOrder and postOrder traversals - both arrays. return the root node of the tree.

class Node

depth()

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.

find(value)

finds & returns node with value. otherwise, undefined.

isBst()

returns true if the subtree at this node is BST. otherwise, false.

lca(values)

returns least common ancestor of the given nodes (values). If none, returns undefined.

height()

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

visitInOrder()

visits tree in in order and returns the values in an array.

visitPostOrder()

visits tree in post order and returns the values in an array.

License

MIT

0.4.0

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago

1.0.0

9 years ago