A binary search tree has nodes with comparable key. the root node has two subtree which is left and right and for every parent node the left child node should have less value than the parent node and the right child node should have greater value than the parent node.

This is an example of ordered Binary search Tree (BTS). This helps with easier search, insert and more

How It Works? Let’s say you want to find the value of 76. The concept is simple you start with the root. It will compare the value of the root of 100 to 76 and if the value you are searching for is smaller than the root you will go to the left subtree of the root. Which will take you to the parent node of 50 then it will compare again the value 76 to 50. If the value you are search for is larger than the node it will go right. Now it will take you to 75 which is the child node of 50. Now the process continues the same way and will compare 76 to 75. Which by now we know that since 76 is larger than 75 it will take us to the right child node of 75 which is 76. There you go Thats how it work.

How it works for insert? Let’s see, now we have to keep in mind the rules of BST which are a parent node can only have two child node. Second the child node with a lesser value to the parent will be placed to the left and the child node with greater value than the parent will be placed to the right.

Now if we are trying to insert the value of 123. It should look like this.

Just coding