What is a binary tree?
A binary tree is a tree data structure in which each node has at most two children. Each node may have 0 or 1 or 2 children only.
COMPETITIVE EXAM SPECIAL
- The maximum number of nodes at level "L" of a binary tree is 2L
- The maximum number of nodes in a binary tree of height 'h' is 2h+1 1-1.
Full Binary Tree
It is a special kind of binary tree that has either zero children or two children.
Complete Binary Tree
In a complete binary tree all the tree levels are filled entirely with nodes, except the lowest level of tree.
Perfect Binary Tree
A binary tree is said to be 'perfect" if all the internal nodes have strictly two children and every external or leaf node is at the same level or same depth within a tree.
COMPETITIVE EXAM SPECIAL
A perfect binary tree having height 'h' has 2^(h+1)-1 nodes.
Balanced Binary Tree
A balanced binary tree is a binary tree in which the height of the left and right subtrees of any node differ by at most 1.
AVL Tree & Red Black Tree are examples of Balanced binary tree. Don't worry if you don't understand Balanced balanced binary tree. Watch this video to understand click to watch.
Conditions to achieve balanced binary tree
- The height of the left and right subtrees of any node differ by at most 1.
- The left subtree is balanced.
- The right subtree is balanced.
Degenerate Binary Tree
It is also refered as one sided tree. If every internal node has a single child then it is called Degenerate Binary tree.
0 Comments