What is a binary Search Tree?

A binary Search Tree is a method used to store data. Each element, or node, is sorted in order to access elements faster when searching for them.

Steps for inserting

  1. Start at the root and compare it to the value.
  2. If the root is greater than the element, go into the left child of the root, otherwise go in the right.
  3. Repeat the previous steps, with comparing the current node to the inserted node, until there is no child to go into. Insert it there.

Link to Wikipedia