1) A binary tree with 20 nodes has how many null branches?
ANS:21
A binary tree with n nodes has exactly n+ 1 null node.
2) How many different trees are possible with 10 nodes ?
ANS: 1014
If there are n nodes, there exist 2n-n different trees.
3) 8, 15, 13, 14 nodes were there in 4 different trees. Which of them could have formed a
full binary tree?
ANS: 15.
In general:
There are 2n-1 nodes in a full binary tree.
By the method of elimination:
Full binary trees contain odd number of nodes. So there cannot be
full binary trees with 8 or 14 nodes, so rejected. With 13 nodes you can form a complete
binary tree but not a full binary tree. So the correct answer is 15.
4) Of the following tree structure, which is, efficient considering space and time
complexities?
(a) Incomplete Binary Tree
(b) Complete Binary Tree
(c) Full Binary Tree
ANS :(b) Complete Binary Tree.
By the method of elimination:
Full binary tree loses its nature when operations of insertions and deletions are done.
For incomplete binary trees, extra storage is required and overhead of NULL node checking
takes place. So complete binary tree is the better one since the property of complete binary
tree is maintained even after operations like additions and deletions are done on it.
5) Convert the expression ((A + B) * C โ (D โ E) ^ (F + G)) to equivalent Prefix and
Postfix notations.
ANS:
Prefix Notation:
^ - * +ABC - DE + FG
Postfix Notation:
AB + C * DE - - FG + ^
6) Write a function to find cycles in a linked list.
ANS:
bool find_cycle(Node* head)
{
if(head == NULL // empty list
|| head->next == NULL // list with 1 node
|| head->next>next == NULL) // 2 nodes w/o cycle
{
return false;
}