Algorithm :
Define Node class which has three attributes namely: data left and right. Here, left represents the left child of the node and right represents the right child of the node.
* When a node is created, data will pass to data attribute of the node and both left and right will be set to null.
* Define another class which has an attribute root.
* Root represents the root node of the tree and initialize it to null.
* a. insert()
will add a new node to the tree:
* It checks whether the root is null, which means the tree is empty. It will add the new node as root.
* Else, it will add root to the queue.
* The variable node represents the current node.
* First, it checks whether a node has a left and right child. If yes, it will add both nodes to queue.
* If the left child is not present, it will add the new node as the left child.
* If the left is present, then it will add the new node as the right child.
* a. Inorder()
will display nodes of the tree in inorder fashion.
* It traverses the entire tree then prints out left child followed by root then followed by the right child.