The best programs are written so that computing machines can perform them quickly and so that human beings can understand them clearly. A programmer is ideally an essayist who works with traditional aesthetic and literary forms as well as mathematical concepts, to communicate the way that an algorithm works and to convince a reader that the results will be correct. ― Donald E. Knuth

# Algorithms

## Tree

Problem :-
Implement an algorithm to insert a node in a Binary Search Tree ( BST ).

Solution :-
We need to follow the properties of Binary Search Tree ( BST ) to insert a node at an appropriate place in the tree. We use a recursive algorithm to traverse through different subtrees by comparing the value of the parent node ( P ) and the value of the node to be inserted ( N ). For e.g, if N -> data < P -> data , the new node will be inserted in the left subtree of P . So, we move to the left subtree and follow the same step. This process continues till we reach a node with 0 or 1 child where we can insert the new node.
Following figure illustrates how nodes are inserted in a BST :