Advantages of linked list representation of binary trees over arrays?
1. Advantages of linked list representation of binary trees over arrays?
a] dynamic size
b] ease of insertion/deletion
c] ease in randomly accessing a node
d] both dynamic size and ease in insertion/deletion
2. Disadvantages of linked list representation of binary trees over arrays?
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
3. Which of the following traversing algorithm is not used to traverse in a tree?
a] Post order
b] Pre order
c] Post order
d] Randomized
View Answer
4. Level order traversal of a tree is formed with the help of
a] breadth first search
b] depth first search
c] dijkstra’s algorithm
d] prims algorithm
5. Identify the reason which doesn’t play a key role to use threaded binary trees?
a] The storage required by stack and queue is more
b] The pointers in most of nodes of a binary tree are NULL
c] It is Difficult to find a successor node
d] They occupy less size
6. 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
7. 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
8. 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
9. What must be the missing logic below so as to print mirror of a tree as below as an example?
data-structure-questions-answers-binary-trees-linked-lists-q9
if[rootnode]:
mirror[rootnode–>left]
mirror[rootnode–>right]
//missing
end
a] swapping of left and right nodes is missing
b] swapping of left with root nodes is missing
c] swapping of right with root nodes is missing
d] nothing is missing