What is BST?

Binary Search Algorithm is a search algorithm that has O(logn) complexity.

Step to preform 'search' function in BST

  1. Check current(or first) node's value
  2. If current node's value is not what we what, compare it with value we want
  3. If value is bigger than current node, go to the right subtree
  4. If value is smaller than current node, go the left subtree
  5. Keep comparing nodes until you find the correct one or reach the end of tree

Image about BST

Extra link about BST

Here is a link that introduce Binary Search Tree.