1.
How to travel a tree in linkedlist representation?
Answer: Option 'D'
Also level order traversing is possible.
2.
What is missing in this logic of finding a path in the tree for a given sum (i.e checking whether there will be a path from roots to leaf nodes with given sum) ?
checkSum(struct bin-treenode *root , int sum) : if(root==null) return sum as 0 else : leftover_sum=sum-root_node-->value //missing
Answer: Option 'A'
if(left subtree and right subtree) then move to both subtrees
else if only left subtree then move to left subtree carrying leftover_sum parameter
else if only right subtree then move to right subtree carrying leftover_sum parameter.
3.
What is the code below trying to print?
void print(tree *root,tree *node) { if(root ==null) return 0 if(root-->left==node || root-->right==node || print(root->left,node)||printf(root->right,node) { print(root->data) } }
Answer: Option 'C'
We are checking if left or right node is what the argument sent or else if not the case then move to left node or right node and print all nodes while searching for the argument node.
4.
Advantages of linked list representation of binary trees over arrays?
Answer: Option 'D'
both dynamic size and ease in insertion/deletion
5.
Disadvantages of linked list representation of binary trees over arrays?
Answer: Option 'D'
Random access is not possible and extra memory with every element
6.
What may be the psuedo code for finding the size of a tree?
Answer: Option 'A'
Draw a tree and analyze the expression. we are always taking size of left subtree and right subtree and adding root value(1) to it and finally printing size.
7.
Why we prefer threaded binary trees?
Answer: Option 'D'
All the given options are properties for a threaded tree.
8.
Level order traversal of a tree is formed with the help of
Answer: Option 'A'
breadth first search
Level order is similar to bfs.