00:01
For this question, we're given information about post -fix notation.
00:04
It's a way of writing arithmetic expression without parentheses.
00:10
So the question we're asked is describe a non -recursive way of evaluating an expression in post -fix notation.
00:17
Post -fix notation and all the guidelines for post -fix notation is listed in the question.
00:23
So following those guidelines, to evaluate a post -fix expression, we need to iterate through the string and push operands to the stack until we encounter an operator.
00:32
Then when an operator is encountered, we calculate the result from the last two operands in the stack and then push it back to the stack.
00:40
In the end, we'll have one result remaining in the stack.
00:43
So what that means is essentially we'll keep adding things to the stack, right? one, two, three, until we encounter an operator.
00:52
Then we'll apply the operator to the last two in the stack, so two plus three.
00:57
And then we'll keep doing that until we have just one result remaining.
01:02
So we'll call this evaluate expression.
01:09
4.
01:10
Inti equals 0...