1.0.0 • Published 8 months ago

binary-search-tree-package v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

Binary Search Tree

A binary search tree (BST) is a data structure that consists of nodes, each containing a value and two children (left and right). The binary search tree maintains the property that for each node, the values in the left subtree are less than the node's value, and the values in the right subtree are greater.

Features

Tree(array) returns a balanced binary search tree (BST) with numerous methods available for use. These include:

insetVal(val) & deleteVal(val) accept values and either add or remove them to the BST

find(node) accepts a node and returns the node with the given value

levelOrder() traverses the tree in breadth-first level order and prints each node's data

preOrder(), inOrder(), and postOrder() each traverse the tree in their respective depth-first order and print the data to the console

height(node) accepts a node and returns its height (number of edges in the longest path from a given node to a leaf node)

depth(node) accepts a node and returns its depth (number of edges in the longest path from a given node to the tree’s root node)

isBalanced() checks if the tree is balanced and returns true or false

reBalance() re-balances an unbalanced tree

1.0.0

8 months ago