Question
The player begins the game at a common location, and proceeds to explore the game world using the input commands and responding to the displayed
The player begins the game at a common location, and proceeds to explore the game world using the input commands and responding to the displayed output. Some rooms have multiple entrances and exits, and some have many ways in, but only one way out (e.g., sliding down a tunnel). Sometimes you may encounter a maze, and dropping an inventory item will help you navigate out. Your answer need
only consider expression forms encountered in the expression:
h(a, g(b), c) * 3 + d
[12 marks]
(b) In Java, expressions are evaluated strictly left-to-right. Consider compiling
the function f in the following Java class definition:
class A
{
static int a,b;
void f() { ... <
int g(int x) { ... a++; ... }
};
Indicate what both the intermediate code and (improved as above) target code
might be for <
(i) b = g(7) + a;
(ii) b = a + g(7);
(iii) b = (-g(7)) + a;
(iv) b = a - g(7);
Comment on any inherent differences in efficiency at both the intermediate
code and target code levels.
[8 marks]
7 [TURN OVER
CST.2005.5.8
7 Comparative Programming Languages
Most large programs that have been written with considerable care and thoroughly
checked still seem to contain bugs at a rate of over one per 3000 lines of source
code. Systems involving hundreds of millions of lines of code can thus be expected
to contain tens of thousands of potentially catastrophic errors.
(a) List several kinds of programming errors that can appear in programs and
discuss their relative importance in relation to the long-term reliability of a
large application program. [7 marks]
(b) Suggest potential ways by which programmers may reduce the number of
programming errors they make, paying particular attention to language
features that might help, extra features in program development systems and
possible changes in overall system architecture. [8 marks]
(c) In what ways would you expect languages 25 years from now to differ from
those that are currently popular? [5 marks]
8 Databases
(a) Define the core operators of the relational algebra. [5 marks]
(b) Describe two differences and two similarities between the relational algebra
and SQL. [4 marks] Explain how a parse tree representing an expression can (i) be converted
into stack-oriented intermediate code and then (ii) be translated into simple
machine code for a register-oriented architecture (e.g. ARM or IA32) on
an instruction-by-instruction basis. Also indicate how this code might be
improved to remove push-pop pairs introduced by (ii). The play proceeds with the player inputting a text command sequence. The game then responds by displaying the outcome. Sometimes the outcome will be a long, descriptive paragraph explaining what is happening. Other times, it will be a description of what the player can see at that location. Usually, the first time visiting a location will trigger a long descriptive output, and subsequent visits will display an abbreviated output (e.g., "You are at the chasm again"). How could this problem be overcome? [5 marks] (iii) The designer also wishes the real-time system. Although each of these techniques can provide new information of value to a software project, costs can be reduced if information is available earlier in the design cycle. The game proceeds until the player either perishes or wins. The player can perish in an interaction with a nasty character, by starvation or thirst, or by falling down a hole or off a cliff. A win is usually indicated by a return to a "safe area" with all the treasures.
The establishment of a safe area can benefit the game play by allowing the player to "stash" inventory items for safe keeping or to relieve him or herself of carrying multiple items.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started