# Expression Tree Multiple Choice Questions and Answers (MCQs)

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs) focuses on “Expression Tree”.

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

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

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

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

3. 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

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

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

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

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

6. 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)

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

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

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

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

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

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

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

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

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

11. What is the postfix expression for the following expression tree?

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

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

12. 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

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.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]