Question 9.Calculate the result of the following prefix expression: +, -, *, 8, 4, 7, 6, 2,5Answer:
Answers
Answered by
3
Answer:
3004.95798704 this is your answer
Answered by
0
31 is the result of the given prefix expression i.e. +, -, *, 8, 4, 7, 6, 2, 5.
Explanation:
- Given prefix expression is +, -, *, 8, 4, 7, 6, 2, 5
- Evaluation will be started from the end
- First, 5 will get pushed in the stack
- Then 2, 6, 7, 4, 8 will get pushed into the stack in order one above another respectively
- Then * operation will get turn and pop on top 2 numbers which are 8 and 4 which will result in 8 * 4 = 32 and will get pushed to the top of the stack.
- Then - the operation will get turn and pop on top 2 numbers which are 12 and 7 which will result in 32 - 7 = 25 and will get pushed to the top of the stack.
- Lastly + operation will get a turn and pop on top 2 numbers which are 25 and 6 which will result in 25 + 6 = 31 and will get pushed to the top of stack.
- Now as the expression is finished the top element which is 31 will get shown as output.
Hence, 31 is the result of the given prefix expression i.e. +, -, *, 8, 4, 7, 6, 2, 5.
Similar questions