1.

Devise an algorithm to insert a node in a Binary Search Tree.

Answer»

An algorithm to insert a node in a Binary Search Tree is given below:

  • Assign the current node to the ROOT node.
  • If the root node's value is GREATER than the value that has to be added:
    • If the root node has a LEFT CHILD, GO to the left.
    • Insert node here if it does not have a left child.
  • If the root node's value is less than the value that has to be added:
    • If the root node has a right child, go to the right.
    • Insert node here if it does not have the right child.


Discussion

No Comment Found