#Day25 #100DaysOfCode
A full binary tree has either 0 or 2 children. A node that has 0 chidren is a leaf node. Therefore, a single node can be a full BT.
There are 3 quantities go with full BT: no of leaves(l), no of internal nodes(i), total nodes(n).
internal nodes are non-leaf nodes, including root node.
in full BT, no of leaves = no of internal nodes + 1.
there are many more formula can be derived with the 3 quantities. See Programiz.
A perfect BT has 2 children at every node. All leaves are at same level.
I don't think a single node can be a perfect BT. Therefore, a tree of 3 nodes is the base case.
There are 2 conditions to be checked with perfect BT.
_ height of subtrees = height of tree - 1
_ even so, subtrees might be crooked, therefore, need to check whether subtrees are perfect BT.
A full binary tree has either 0 or 2 children. A node that has 0 chidren is a leaf node. Therefore, a single node can be a full BT.
There are 3 quantities go with full BT: no of leaves(l), no of internal nodes(i), total nodes(n).
internal nodes are non-leaf nodes, including root node.
in full BT, no of leaves = no of internal nodes + 1.
there are many more formula can be derived with the 3 quantities. See Programiz.
A perfect BT has 2 children at every node. All leaves are at same level.
I don't think a single node can be a perfect BT. Therefore, a tree of 3 nodes is the base case.
There are 2 conditions to be checked with perfect BT.
_ height of subtrees = height of tree - 1
_ even so, subtrees might be crooked, therefore, need to check whether subtrees are perfect BT.