9691-CIE-Answers (3.5) - Programming Paradigms
9691-CIE-Answers (3.5) - Programming Paradigms
Section 3.5
Oct/NOV 2003
8. (i) - Data can only be accessed by the methods provided by the class
- Name can only be accessed from the class Person
(ii) - Where one class is a subclass of another it can use its methods
- Pupil can use getname() from Person (4)
May/June 2004
Question 7.
(a) <VARIABLE NAME>;;=<ALPHA>I<ALPHA><DIGIT><DIGIT>I<ALPHA><ALPHA>
(1 per alternative, 1 for correct use of notation, max 4) (4)
(b) <VARIABLE NAME>::=<X>I<Y>
<X>::= <ALPHA>I<ALPHA><X>
<Y>::= <ALPHA><NZD><DIGIT>
<NZD>::= 1I2I3I4I5I6I7I8I9
(2 for definition of X, 1 for definition of Y, 1 for definition of NZD, 1 for two options
for variable name, max 4) (4)
http://sites.google.com/site/computing9691/
Page 1 of 10
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.5
Oct/NOV 2004
7. (a) (i) A variable which is defined for a particular use in only one part of a
program /can only be used in block in which it is defined
(ii) Can be used and have its value manipulated throughout a program
(iii) Information about a data item being supplied to a function or procedure
when it is called (and return data to calling routine) (3)
(b) A parameter passed by value...
a local copy of the data is stored
in a separate location from the original
the value of the parameter can be manipulated
new value is discarded and return to original when procedure is terminated
A parameter passed by reference...
parameter is stored in original location
a pointer is passed indicating where parameter is stored
any changes will remove old value of parameter
new value available to calling program
(1 per point, max 5) (5)
(c) Empty stack
100 entered as return address
6 as parameter
SP above 6
6 read by procedure
SP decremented
300,2,3 added to stack
SP above 3
3 and 2 read,
SP decremented twice
End of second procedure, return address read as 300
SP decremented
End of first procedure, return address 100 read
SP decremented
Accept any consistent use of SP
Diagrams showing the above are acceptable
(1 per point, max 6) (6)
May/June 2005
8. (a) (i) -A particular variable is assigned a value
-e.g. if male(X) then dis is an instance of X/X is instantiated to dis
(ii) -The intention to find all instances that satisfy a rule/set of facts
-e.g. If rule is male(X) then the goal is to find dis and david and john
(iii) -If the result of one rule does not apply in a second rule, then go back
to find another result of the first rule
-e.g. parent (john,dis) is found if we are searching for mother of dis.
This fails the second part of the rule for mother because john is male,
so backtracking is used to return to the next example satisfying the
first part of the rule.
(1 per -) (6)
(b) (i) grandmother (x,y) :- grandparent (x,y), female (x)
(1 mark for grandparent (x,y) 1 mark for female(x)) (2)
(ii) -Ignores parent (john,dis) parent (john,may) parent (dis,sto) because
Y<> david
http://sites.google.com/site/computing9691/
Page 2 of 10
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.5
Oct/NOV 2005
(b) (i) -Where memory larger than can be accessed by address in instruction
-allows full size of register to be used for address
-Typically if memory locations are 32 bit then 2^32 locations can be
addressed
-Allowing more memory to be accessed
(ii) -Where a number of contiguous locations
-need to be accessed in order
-e.g. contents of array
-address in instruction does not change, only contents of IR
(1 per -, max 3 per dotty, max 4) [4]
May/June 2006
6. (a) (i) - data and the permitted operations on that data are defined together
(class)
- objects in classes can pass messages from one to another
- classes can share some characteristics (inheritance, derivation)
(1 per -, max 2) [2]
(ii) - programs are expressed as a number of rules (relationships)
- and a set of facts
- program specifies what must be done, not how to do it.
(1 per -, max 2) [2]
(b) (i) - address in instruction is
- the address of the address of the data
suitable diagram worth two marks.
- used to access areas of memory that are not accessible using the space
available for the address in the instruction code [3]
http://sites.google.com/site/computing9691/
Page 3 of 10
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.5
Oct/NOV 2006
10. (a) -a number of programmers can all work on the same piece of software
-individual expertise can be utilized
-errors are far more easily spotted because…
-each procedure/function is much simpler to solve than the original problem
-individual procedures are far easier to test than a whole project
-library routines can be utilized
-procedure can be used multiple times
-functions are mathematically provable to be correct/faulty
(1 per -, max 4) (4)
(c) -return address placed on stack
-along with values of parameters
-parameters read off stack by procedure
-any returning values placed on stack by procedure
-return to address at top of stack at end of procedure.
(1 per -, max 4) (4)
May/June 2007
6. (a) (i) - The value to be searched for is passed/in this case the actual name
“SMITH” is passed
(ii) - The address of the value is passed/The location of the name is passed
(allowing it to be altered if necessary). [2]
(b) (i) - The value of the variable only exists in the procedure
- The counter used to control the loop (so that it does not effect a repeat
use of the variable).
(ii) - the value of the variable exists throughout the code of the program
- the variable used to hold the details searched for (needs to be used
outside the procedure).
(Note: Other examples are fine with reasonable explanation. 1 per -, max 4) [4]
10.
Mark Points:
- Recognisable syntax diagram showing sequence
- Single letter possible
http://sites.google.com/site/computing9691/
Page 4 of 10
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.5
May/June 2008
10. (a) (i) -A particular fact that fits the rule
-e.g. If fresh (X) then guppy is an instance of X/X is instantiated to guppy
[2]
(ii) -The intention to find all instances that satisfy a rule/fact
-e.g. If rule is fresh (X) then the goal is to find guppy, roach [2]
(iii) -If the result of one rule does not apply in a second rule, then go back to
find another result of the first rule
e.g. -find a salt water eater of roach
-eats (guppy, roach) is found
-fresh (guppy) shows guppy is a fresh water fish
-eats (salmon, roach)
-salt (salmon) shows salmon is a salt water fish
-salmon satisfies the rule
(1 per -, max 4) [4]
Oct/NOV 2008
7. (a) (i) A (self contained) set of instructions/piece of
code/subprogram/subroutine
(ii) Information about a data item being given to a procedure when it
is called [2]
http://sites.google.com/site/computing9691/
Page 5 of 10
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.5
May/June 2009
2. (a) (i) -Data and methods are kept together/Data can only be accessed using
the methods attached to it. [1]
(ii) -Computer told facts and rules and then manipulates them to provide
answers to queries. [1]
http://sites.google.com/site/computing9691/
Page 6 of 10
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.5
(b) <REAL>::=<FIRST><POINT><NUMBER>│<FIRST><POINT>
<FIRST>::=<INTEGER>│<ZERO>
<POINT>::= .
<ZERO> ::= 0
Mark points:
-Definition contains . (point)/Definition contains 0
-Definition has integer OR 0 before the point AND number or nothing after the point
-Correct use of notation
(Note: No marks for redefining meta variables given in question)
-Definition of zero [3]
(c)
Mark Points:
Before point:
-Allows only 0
-NZ Digit alone
-NZ Digit AND unlimited digits
After point:
-Possibility of no digits
-Unlimited digits
(1 per -, max 4) [4]
http://sites.google.com/site/computing9691/
Page 7 of 10
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.5
Mark Points:
-Allows single LETTER
-Allows unlimited LETTERs
-Allows single DIGIT and only after LETTERs
-Allows single IDENTIFIER but only after LETTERs (and DIGIT)
(1 per -, max 4) [4]
Oct/NOV 2010. P31
9. (i) -Data and methods are kept together
-Data can only be accessed using methods attached to it [2]
(ii) -Computer given facts and rules
-required outcomes are described, not how to achieve them [2]
(iii) -Instructions are one-to-one with machine code/binary
-Use of mnemonics / labels
-Memory locations can be accessed directly
(1 per -, max 2) [2]
9. (a) -reverse Polish expressions can be processed directly from left to right
-Is free of ambiguities
-does not require brackets
-does not require use of rules of precedence
(1 per -, max 2) [2]
http://sites.google.com/site/computing9691/
Page 8 of 10
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.5
(b)
Mark points:
-at least two operators shown between transitions
-a and b in first stage
-a+b after first operator
-e,d,c, (a+b) in stack in correct order
-(d-e)
-c*(d-e)
-(a+b)-c*(d-e)
(1 per -, max 6) [6]
9. (a) -reverse Polish expressions can be processed directly from left to right
-Is free of ambiguities
-does not require brackets
-does not require use of rules of precedence
(1 per -, max 2) [2]
(b)
Mark points:
-at least two operators shown between transitions
-a and b in first stage
-a+b after first operator
-e,d,c, (a+b) in stack in correct order
-(d-e)
-c*(d-e) -(a+b)-c*(d-e) (1 per -, max 6) [6]
http://sites.google.com/site/computing9691/
Page 9 of 10
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.5
(ii) ab+cde-*-
Mark as follows...
a b + (at the start of the expression)
cde-*
Minus sign at the RHS of expression
(1 per -, max 6)
[6]
Oct/NOV 2011. P31
Oct/NOV 2011. P32
Oct/NOV 2011. P33
May/June 2012. P31
May/June 2012. P32
May/June 2012. P33
http://sites.google.com/site/computing9691/
Page 10 of 10