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


Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17
Articles: 40701