Engineering Questions with Answers - Multiple Choice Questions

Expression Tree MCQ’s

1 - Question

The leaves of an expression tree always contain?
a) operators
b) operands
c) null
d) expression

View Answer

Answer: b
Explanation: The leaves of an expression tree always contain the result of a given expression (i.e.) operands.




2 - Question

A node can have a minimum of one child.
a) true
b) false

View Answer

Answer: a
Explanation: It is possible for a node to have at least one child, as is the case with the unary minus operator.




3 - Question

 What does the other nodes of an expression tree(except leaves) contain?
a) only operands
b) only operators
c) both operands and operators
d) expression

View Answer

Answer: b
Explanation: The nodes other than leaves always contain only operators. There cannot be any operand in those nodes.




4 - Question

An expression tree is a kind of?
a) Binary search tree
b) Fibonacci tree
c) Binary tree
d) Treap

View Answer

Answer: c
Explanation: The expression tree is a binary tree. It contains operands at leaf nodes and remaining nodes are filled with operators. The operands and the operators can be arranged in any order (ascending, descending).




5 - Question

The expression obtained by recursively producing a left expression, followed by an operator, followed by recursively producing a right expression is called?
a) prefix expression
b) infix expression
c) postfix expression
d) paranthesized expression

View Answer

Answer: b
Explanation: It is an infix expression because the format of an infix expression is given by operand-operator-operand.




6 - Question

The average depth of a binary tree is given as?
a) O(N)
b) O(log N)
c) O(M log N)
d) O(√N)

View Answer

Answer: d
Explanation: The average depth of a binary expression tree is mathematically found to be O(√N).




7 - Question

Only infix expression can be made into an expression tree.
a) true
b) false

View Answer

Answer: b
Explanation: All infix, prefix and postfix expressions can be made into an expression tree using appropriate algorithms.




8 - Question

An expression tree is created using?
a) postfix expression
b) prefix expression
c) infix expression
d) paranthesized expression

View Answer

Answer: a
Explanation: A postfix expression is converted into an expression tree by reading one symbol at a time and constructing a tree respectively.




9 - Question

++a*bc*+defg is an?
a) postfix expression
b) infix expression
c) prefix expression
d) invalid expression

View Answer

Answer: c
Explanation: It is a prefix expression obtained from a preorder traversal since it is of the form operator-operand-operand.




10 - Question

An expression tree’s nodes can be deleted by calling?
a) malloc
b) calloc
c) delete
d) free

View Answer

Answer: d
Explanation: In Binary trees, nodes are created by calling malloc and they are deleted by calling free.




11 - Question

What is the postfix expression for the following expression tree?

a) abcde++**
b) ab+cde+**
c) abc+de+**
d) abcd+*e+*

View Answer

Answer: b
Explanation: If the given expression tree is evaluated, the postfix expression ab+cde+** is obtained.




12 - Question

In an expression tree algorithm, what happens when an operand is encountered?
a) create one node pointing to a stack
b) pop the nodes from the stack
c) clear stack
d) merge all the nodes

View Answer

Answer: a
Explanation: When an operand is encountered, create one node trees and push it on to the stack. When an operator is encountered, pop the pointers from last two trees from the stack.

Get weekly updates about new MCQs and other posts by joining 18000+ community of active learners