1. The most suitable data structure used to represent the derivations in compiler:
a) Queue
b) Linked List
c) Tree
d) Hash TablesAnswer: c
Explanation: The tree, known as “Parse tree” when used in a compiler, is the data
structure of choice to represent the source program.
2. Which of the following statement is false in context of tree terminology?
a) Root with no children is called a leaf
b) A node can have three children
c) Root has no parent
d) Trees are collection of nodes, with a parent child relationship
Answer: a
Explanation: A node has atmost one parent, drawn above the node, and zero or more
children drawn below. Lines connect parents to children. There is one node, one root, that
has no parent; this node appears to be at the top of the tree. Nodes with no children are
called leaves. Nodes that are not leaves are called interior nodes.
3. In which order are the children of any node ordered?
a) From the left
b) From the right
c) Arbitrarily
d) None of the mentioned
Answer: a
Explanation: The children of a node are ordered from the left and drawn so. If N is to the
left of node M, then all the descendents of N are considered to be to the left of all the
descendents of M.
4. Which among the following is the root of the parse tree?
a) Production P
b) Terminal T
c) Variable V
d) Starting Variable S
Answer: d