VIRTUAL LAB

Logo

1. Insertion


    Compare the node value with root.
  • If value <= root value, Move to left subtree
  • Else move to right subtree
  • Recur until a NULL node is found


2. Traversal


    Inorder
  • Recur left subtree until next node is NULL
  • Print the current node value
  • Recur right subtree until next node is NULL

  • Preorder
  • Print the current node value
  • Recur left subtree until next node is NULL
  • Recur right subtree until next node is NULL

  • Postorder
  • Recur left subtree until next node is NULL
  • Recur right subtree until next node is NULL
  • Print the current node value


3. Deletion


  • If node is a leaf node, remove node directly
  • Link previous node to deleted parent's child if only one child exists
  • Replace the node's value with its in-order successor if it has two children.