0% found this document useful (0 votes)
148 views10 pages

9691-CIE-Answers (3.5) - Programming Paradigms

The document provides past exam answers for programming paradigms questions from 2000-2007. It includes answers on topics like object-oriented programming concepts (classes, inheritance, encapsulation, polymorphism), parameters (pass by value vs reference), stacks and calling procedures, and functional and logic programming concepts. The answers range from short definitions to longer multi-point explanations and examples.

Uploaded by

Tawanda Muchemwa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
148 views10 pages

9691-CIE-Answers (3.5) - Programming Paradigms

The document provides past exam answers for programming paradigms questions from 2000-2007. It includes answers on topics like object-oriented programming concepts (classes, inheritance, encapsulation, polymorphism), parameters (pass by value vs reference), stacks and calling procedures, and functional and logic programming concepts. The answers range from short definitions to longer multi-point explanations and examples.

Uploaded by

Tawanda Muchemwa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Reinforcement: 05-10 Years' relevant CIE answers.

Section 3.5

Past Papers Answers:

Section 3.5: Programming paradigms


May/June 2000
Oct/NOV 2000
May/June 2001
Oct/NOV 2001
May/June 2002
Oct/NOV 2002
May/June 2003
5. (a) - Produces re-usable code
- By creating a class library
- Inheritance
- To produce new objects
- Encapsulation of data
- To protect data integrity
- Polymorphism
- To use different versions of the same method (in different classes)
- Structure of data and the code in a class may be altered
- Without affecting programs that use the class
- Without affecting other classes
- Message passing between classes
(max 6) (6)
(b) (i) A template for creating objects (that share a common behaviour and
common structure) (1)
(ii) A class that inherits the structure and methods of another class (1)
(iii) A class that passes down its attributes and methods (1)
Total = 9 marks

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

-finds parent (dis,david)


-searches for parent (X,dis), finds X = john
-finds male (john), rejects X = john because not female
-backtracks to find next occurrence of (X,dis)
-finds parent (minah,dis)
-finds female (minah), reports minah is grandmother
(1 per -, max 2) (2)

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

(ii) - address in instruction is added to


- a value held in a special register called the index register
suitable diagram worth two marks
- allows a set of contiguous data (array) to be
accessed without altering instruction [3]

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

- Two letters, without more, possible


- Single digit possible
- Loop for multiple digits…
- inside $ loop
- Dollar loop correctly positioned to miss Digits and &
- & after digits loop
(1 per -, max 6) [6]
Oct/NOV 2007
11. (a) (i) – Third generation high level languages
– Problem orientated/designed to solve specific types of problem
– Describe (step by step) how to solve a problem
(1 per –, max 2) [2]
(ii) – Fourth generation high level languages
– Program told what the problem is/rather than steps necessary to solve it
– Searches database according to rules supplied
(1 per –, max 2) [2]
(b) (i) – Data can only be accessed using specific methods…
– provided by the class
– Objects cannot be corrupted by the user
(1 per –, max 2) [2]
(ii) – One class can include the data and methods of another…
– plus some of its own
– Allows for simple reuse of code/extension of original data and methods
without affecting the code.
(1 per –, max 2) [2]

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

(b) – Return address placed on stack


– Values of parameters placed on stack
– When necessary, values of parameters are read from stack and used
– Return address is read
– Calling program carried out from return address
(1 per –, max 4) [4]

10. (i) – Lower case letters are not defined [1]


(ii) e.g. < TERMINATOR > : : = .│?
< SPACE > : : = ^
< GROUP > : : = < WORD > < SPACE >
< SET > : : = < GROUP > < WORD > │< GROUP ><SET >
< SENTENCE > : : = < SET > < TERMINATOR >
Mark Points:
– Define Terminator
– Define Space
– Define Group
– Define Set
– Define Sentence
(1 per –, max 5) [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]

Oct/NOV 2009. P31


3. (a) Marks points:
-Address in instruction is decoded
-Contents of that memory location contain an address
-The address of the data to be used. [3]
(b) -Some areas of memory cannot be addressed because size of memory address
> space available in instruction
-Memory address will fit in a memory location [2]

Oct/NOV 2009. P32


Oct/NOV 2009. P33
3. (a) Marks points:
-Address in instruction is decoded
-Contents of that memory location contain an address
-The address of the data to be used. [3]
(b) -Some areas of memory cannot be addressed because size of memory address
> space available in instruction
-Memory address will fit in a memory location [2]

http://sites.google.com/site/computing9691/
Page 6 of 10
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.5

May/June 2010. P31


May/June 2010. P32
10. (a) (i) . is not defined [1]
(ii) an integer must not begin with a zero [1]

(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]

May/June 2010. P33


10 . a) (i) D is not defined [1]
(ii) a variable must not begin with an IDENTIFIER [1]
(b) <MAIN VARIABLE>::=<NZDIGIT><GROUP><END>
<NZDIGIT>::=1|2|3|4|5|6|7|8|9
<END>::= !|&
(1 per line of definition) [3]
(c)

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]

Oct/NOV 2010. P32


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]

Oct/NOV 2010. P33


May/June 2011. P31
2. (c) (i) -Address in instruction is the address of the address of / pointer to the
location...
-which contains the data to be used [2]
(ii) -Address in the instruction has added to it
-the contents of the Index Register/IR [2]
(iii) -Address in the Instruction is the displacement
-from the address of the first/current instruction
-the value is added to the PC [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]

May/June 2011. P32


2. (c) (i) -Address in instruction is the address of the address of / pointer to the
location...
-which contains the data to be used [2]
(ii) -Address in the instruction has added to it
-the contents of the Index Register/IR [2]
(iii) -Address in the Instruction is the displacement
-from the address of the first/current instruction
-the value is added to the PC [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]
(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

May/June 2011. P33


2. (b) (i) -Address in instruction is the address of the address of the location...
-which contains the data/instruction to be used
-Allows complete change in program by changing indirect address to
point to a different subroutine // allows greater range of memory to be
addressed/by example [3]
(ii) -Address in the instruction is added to
-the contents of the IR...
-which can then be incremented to allow access to a sequence of
locations// Allows the contents of an array to be accessed sequentially by
successive instructions // used to access a contiguous block of memory
[3]
9. (a) -can be processed directly by reading the expression from left to right
-is free of ambiguities
-does not require brackets
-does not require rules of precedence
-can be processed using a stack
(1 per -, max 2) [2]

(b) (i) Mark as follows...


–sign at the root 1
Correct left subtree 1
Correct right subtree 1

(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

You might also like