Evaluate expression abc*d where a=4 b = 3, c=2, d=5
(data structure)
Answers
Answered by
0
Explanation:
Operators act on the two nearest values to the right (two, since we are only using binary operators above).
The above prefix expression can hence be reduced as below (evaluate inside-out (this is how the stack-based algo evaluation of the expression happens)):
*/b+-dacd
= */b+ (d - a) cd
= */b [(d-a) + c] d
= * {b / [(d-a) + c] } d
= {b / [(d-a) + c] } * d
Substituting a=3, b=6, c=1, d=5,
answer = {6/ [5-3 + 1]} * 5
= 6/3 * 5
= 10
Similar questions
Environmental Sciences,
1 month ago
Chemistry,
2 months ago
Math,
9 months ago
English,
9 months ago