In an expression tree algorithm, what happens when an operand is encountered?

Category: QuestionsIn an expression tree algorithm, what happens when an operand is encountered?
Editor">Editor Staff asked 1 month ago

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
 
This key question is from Trees in portion Trees of Data Structures & Algorithms I
 
I had been asked this question in my homework.

1 Answers
Editor">Editor Staff answered 1 month ago

Correct choice is (a) create one node pointing to a stack
 
For 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.