Binary Search Tree

Inserting a new node into a BST

  • Start from root.
  • Compare the inserting element with root and if it's lesser than root, then recurse for left, else recurse for right.
  • After reaching the end, just insert that node at left(if less than current), else right.