A binary tree is a tree where every node has two or fewer children. The children are usually called left and right. (bad name given kids, how will you the left guy to go on right). Every node contains some data that we call a key.
A binary search tree is a binary tree in which every node contains a key that satisfies following criteria:
When every node of the Binary tree has two(2) or zero(0) children then we call it as Full Binary Tree. Both types of nodes can appear at all levels in the tree.
An example is given in the following figure.
A complete binary tree is formed when every level of the tree is completely filled, except possibly from the last level. Also, the last level has all nodes as left as possible.
We get a perfect binary tree when all tree internal nodes have two children, as well as all leaves, are uniformed by having the same depth.
We can call a binary tree as Balanced Binary tree when the difference between the height of left and right subtree for every node is not more than 1
The height is, number of nodes present from the leaf to the given node. The height always starts with 0, when there is only root then the height of the tree is 0. If the tree is empty the height of the tree is -1
Be careful, when you you are calculating the height. Denoted the height difference in the image
Below tree satisfies the Balanced tree conditions
Below tree doesnot satisfy the Balanced tree condition
This article is written by Pavan, who is serving notice period in an MNC, Bangalore. He thought, let the articles speak rather than his image. He is also the same person who created the reporter for Protractor Jasmine