/BinarySearchTree

Binary search trees (BST), sometimes called ordered or sorted binary trees, are a particular type of container: data structures that store "items" (such as numbers, names etc.) in memory. They allow fast lookup, addition and removal of items, and can be used to implement either dynamic sets of items, or lookup tables that allow finding an item by its key.

Primary LanguageJava

BinarySearchTree

Implement binary search trees using JAVA

A binary search tree is a rooted binary tree, whose internal nodes each store a key (and optionally, an associated value) and each have two distinguished sub-trees, commonly denoted left and right. The tree additionally satisfies the binary search property, which states that the key in each node must be greater than or equal to any key stored in the left sub-tree, and less than or equal to any key stored in the right sub-tree. The leaves (final nodes) of the tree contain no key and have no structure to distinguish them from one another.

Code rules: Positive inputs are add to the tree. Negative inputs are remove from the tree the element which has the absolute value of input.

Methods implemented:

  1. find
  2. contains
  3. get
  4. add
  5. remove
  6. min
  7. max
  8. toArray