# Binary Trees using Linked Lists | Data Structure MCQs

1.

A.) dynamic size
B.) ease of insertion/deletion
C.) ease in randomly accessing a node
D.) both dynamic size and ease in insertion/deletion

both dynamic size and ease in insertion/deletion

2.

A.) Randomly accessing is not possible
B.) Extra memory for a pointer is needed with every element in the list
C.) Difficulty in deletion
D.) Random access is not possible and extra memory with every element

Random access is not possible and extra memory with every element

3.

How to travel a tree in linkedlist representation?

A.) using post order traversing
B.) using pre order traversing
C.) using post order traversing
D.) all of these

Also level order traversing is possible.

4.

Level order traversal of a tree is formed with the help of

B.) depth first search
C.) dijkstra’s algorithm
D.) prims algorithm

Level order is similar to bfs.

5.

Why we prefer threaded binary trees?

A.) storage required by stack and queue is more
B.) pointers in most of nodes of a binary tree are NULL
C.) difficult to find a successor node
D.) all of the above

All the given options are properties for a threaded tree.

6.

What may be the psuedo code for finding the size of a tree?

A.) find_size(root_node–>left_node) + 1 + find_size(root_node–>right_node)
B.) find_size(root_node–>left_node) + find_size(root_node–>right_node)
C.) find_size(root_node–>right_node) – 1
D.) find_size(root_node–>left_node + 1

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.

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```

A.) code for having recursive calls to either only left tree or right trees or to both subtrees depending on their existence
B.) code for having recursive calls to either only left tree or right trees
C.) code for having recursive calls to either only left tree
D.) code for having recursive calls to either only right trees

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.

8.

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)
}
}
```

A.) just printing all nodes
B.) not a valid logic to do any task
C.) printing ancestors of a node passed as argument
D.) printing nodes from leaf node to a node passed as argument