In a Binary Tree, each node can have at most two nodes. For a binary tree to be a binary search tree (BST), the data of
all the nodes in the left subtree of the root node should be less than or equals to the data of the root. The data of all the nodes
in the right subtree of the root node should be greater than the data of the root.
Deleting a node from Binary search tree is little complicated compare to inserting a node. It includes
two steps:
 Search the node with given value.
 Delete the node.
The algorithm has 3 cases while deleting node:
 Node to be deleted has is a leaf node (no children).
 Node to be deleted has one child (eight left or right child node).
 Node to be deleted has two nodes.
We will use simple recursion to find the node and delete it from the tree.
Here is the steps to delete a node from binary search tree:
Case 1: Node to be deleted has is a leaf node (no children).
 This is very simple implementation. First find the node reference with given value.
 Set corresponding link of the parent node to null. With this the node to be
deleted lost its connectivity and eligible for garbage collection.
Case 2: Node to be deleted has one child (eight left or right child node).
 First find the node reference with given value.
 Take the reference of the child node and assign its reference to the corresponding link of the parent node.
With this the node to be deleted lost its connectivity and eligible for garbage collection.
Case 3: Node to be deleted has two nodes.
 It is little complicated process.
 First find the node reference with given value.
 Find the minimum/maximum value of the right/left sub tree.
 Replace the node value with the minimum/maximum value.
 Now delete the minimum/maximum value from the nodes right/left sub tree.
We will use below binary tree for our code output:
