Use the Infix to Prefix algorithm shown in class to translate the following arithmetic expressions into the fully parenthesized "prefix notation" of Scheme expressions.
(11 - (((27 / 18) / 131) + 927))
v + w - x + y - z
v + w - (x + y - z)
To translate these arithmetic expressions from infix to prefix notation, we can follow these steps using the Infix to Prefix algorithm:
Step 1: Reverse the expression
The first step in the algorithm is to reverse the order of the expression.
Expression: (11 - (((27 / 18) / 131) + 927))
Reversed: 927 + (((131 / (18 / 27)) - 11)
Expression: v + w - x + y - z
Reversed: z - y + x - w + v
Expression: v + w - (x + y - z)
Reversed: (z - y + x) - w + v
Step 2: Convert to postfix notation
Next, we convert the reversed expression to postfix notation. We can use a stack to help us with this process.
Expression: 927 + (((131 / (18 / 27)) - 11)
Postfix: 927 131 18 27 / / 11 - +
Expression: z - y + x - w + v
Postfix: z y - x + w - v +
Expression: (z - y + x) - w + v
Postfix: z y - x + w - v +
Step 3: Reverse the postfix expression
Finally, we reverse the postfix expression obtained from the previous step to get the prefix notation.
Expression: 927 131 18 27 / / 11 - +
Prefix: + 927 - / / 131 / 18 27 11
Expression: z y - x + w - v +
Prefix: + - z y + x - w v
Expression: z y - x + w - v +
Prefix: + - + z y x - w v
So, the fully parenthesized "prefix notation" of the given expressions are:
1) (11 - (((27 / 18) / 131) + 927)): + 927 - / / 131 / 18 27 11
2) v + w - x + y - z: + - + z y x - w v
3) v + w - (x + y - z): + - + z y x - w v
I hope this helps! Let me know if you have any further questions.