/Binary-Search-Tree

Binary search trees implemented with JavaScript

Primary LanguageJavaScript

Binary-Search-Tree

Binary search trees implemented with JavaScript

Functions

  • buildTree(array) takes an array of data and turns it into a balanced binary tree full of Node objects appropriately placed
  • insert(value) adds a new node containing the given value
  • delete(value) deletes the node containing the given value
  • find(value) returns the node with the given value
  • levelOrder() traverses the tree in breadth-first level order
  • inorder() traverses the tree in inorder depth-first order
  • preorder() traverses the tree in preorder depth-first order
  • postorder() traverses the tree in postorder depth-first order
  • height(node) returns the height of the given node
  • depth(node) returns the depth of the given node
  • isBalanced() checks if the tree is balanced
  • rebalance() rebalances an unbalanced tree