There are four stages in the compilation of a program written in a high-level language. a) Four
Question:
There are four stages in the compilation of a program written in a high-level language.
a) Four statements and four compilation stages are shown below. Copy the diagram below and connect each statement to the correct compilation stage.
b) Write the Reverse Polish Notation (RPN) for the following expression.
c) An interpreter is executing a program.
The program uses the variables a, b, c and d.
The program contains an expression written in infix form. The interpreter converts the infix expression to RPN. The RPN expression is:
The interpreter evaluates this RPN expression using a stack.
The current values of the variables are:
i) Copy the diagram below and show the changing contents of the stack as the interpreter evaluates the expression. The first entry on the stack has been done for you.
ii) Convert back to its original infix form, the RPN expression:
iii) One advantage of using RPN is that the evaluation of an expression does not require rules of precedence.
Explain this statement.
Step by Step Answer:
Cambridge International AS & A Level Computer Science
ISBN: 9781510457591
1st Edition
Authors: David Watson, Helen Williams