Computing (9691) · Oct/Nov 2015 · Question paper 22
Cambridge Computing (9691) question paper for paper 22, Oct/Nov 2015 — 9691/22/O/N/15, file 9691_w15_qp_22.pdf.
More Computing (9691) papers
Other papers · Oct/Nov 2015
- Paper 12Question paperMark scheme
- Paper 21Question paperMark scheme
- Paper 23Question paperMark scheme
- Paper 32Question paperMark scheme
Paper 22 in other years
- May/June 2016M/J 2016Question paperMark scheme
- May/June 2015M/J 2015Question paperMark scheme
- Oct/Nov 2014O/N 2014Question paperMark scheme
- May/June 2014M/J 2014Question paperMark scheme
- Oct/Nov 2013O/N 2013Question paperMark scheme
- May/June 2013M/J 2013Question paperMark scheme
- Oct/Nov 2012O/N 2012Question paperMark scheme
- May/June 2012M/J 2012Question paperMark scheme
Text of this paper
Cambridge International Examinations
Cambridge International Advanced Subsidiary and Advanced Level
* 6 3 5 0 9 1 4 3 8 7 *
9691/22
COMPUTING
Paper 2
October/November 2015
2 hours
Candidates answer on the Question Paper.
No additional materials are required.
READ THESE INSTRUCTIONS FIRST
Write your Centre number, candidate number and name on all the work you hand in.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
Answer all questions.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
This document consists of 12 printed pages.
DC (RW/CGW) 95649/3
© UCLES 2015
[Turn over
2
1
(a) Sheena wants to develop a program to keep details of the books she has read.
One way of storing this data will be to use records. Each record will contain the fields shown
in the table below.
Complete the table.
Field
Identifier
Example of
input data
Data type
Title
Title
How to solve it
Author
Author
G Polya
International
Standard Book
Number
ISBN
9780691119663
Number of
pages
NumberOfPages
253
Price ($)
BookPrice
12.50
Date started to
read book
DateStarted
28032012
Date finished
reading book
DateFinished
17052012
Paperback?
IsPaperback
TRUE
Rating
(range 0 to 5)
Rating
4
Field size
(in bytes)
[5]
(b) Use a high-level programming language to define a book record with identifier
BookRecordType and the fields listed in part (a).
Programming language
Code
[4]
© UCLES 2015
9691/22/O/N/15
3
(c) Sheena declares an array of records to store the book data:
DECLARE Book ARRAY[1 : 100] OF BookRecordType
At the beginning, the array elements will not contain book data.
Explain how the array should be initialised.
[2]
(d) The records are to be saved to a serial file.
Calculate the size, in kilobytes, of the file after details of 10 books have been saved.
Show your working.
[4]
© UCLES 2015
9691/22/O/N/15
[Turn over
4
(e) Sheena has entered some more book data.
Write pseudocode to save the array records to the serial file BookData.DAT
Only those array elements containing book data should be saved to the file.
[5]
(f)
Sheena wants to read previously saved data from the file.
Here is part of the pseudocode she wrote:
WHILE NOT EOF(BookData.DAT)
:
:
ENDWHILE
Explain what the function EOF() does when used in a program.
[2]
© UCLES 2015
9691/22/O/N/15
5
(g) Sheena wants to know the title of her favourite book. She plans to write code to search the
array Book.
(i)
Write pseudocode to output the title of the book with the highest rating. For now, assume
that only one book in the Book array has the highest rating.
[6]
(ii)
There may be more than one book with the highest rating. Sheena wants to output all the
titles that have this rating. The pseudocode will need to be changed.
Describe the changes you would need to make.
Do not write more pseudocode.
[2]
© UCLES 2015
9691/22/O/N/15
[Turn over
6
2
At the end of movies, when credits are listed, the year of production is often shown in Roman
numerals.
Roman numbers are formed by combining letters together and adding their value. The letters used
and their values are:
M: 1000
D: 500
C: 100
L:
50
X:
10
V:
5
I:
1
For example, MMXV is 1000 + 1000 + 10 + 5 = 2015.
Ali wants to write a program to convert a year written in Roman numerals to denary.
He has drawn the flowchart as part of the design for his solution.
FUNCTION NumeralValue(Letter)
CASE
Letter
OF
ELSE
'M'
'D'
'C'
'L'
'X'
'V'
'I'
RETURN Value
ENDFUNCTION
© UCLES 2015
9691/22/O/N/15
7
(a) (i)
Write program code to convert the flowchart into the function NumeralValue, using a
high-level programming language.
Programming Language
Code
[5]
(ii)
Ali needs to test this function before using it in his program.
Complete the table of test data.
Letter
Expected result
Type of data
(normal, borderline or invalid)
'D'
'V'
'I'
'Y'
[3]
© UCLES 2015
9691/22/O/N/15
[Turn over
8
(b) Ali writes pseudocode to convert a Roman number using:
•
the function NumeralValue() from part (a)
•
the string manipulation functions MID and LENGTH
Study the pseudocode:
RomanNumber ← "MDCLI"
Denary ← 0
FOR i ← 1 TO LENGTH(RomanNumber)
ThisLetter ← MID(RomanNumber, i, 1)
ThisNumber ← NumeralValue(ThisLetter)
Denary ← Denary + ThisNumber
ENDFOR
OUTPUT Denary
Dry-run the pseudocode by completing the trace table.
RomanNumber
Denary
"MDCLI"
0
i
ThisLetter
ThisNumber
OUTPUT
[5]
© UCLES 2015
9691/22/O/N/15
9
(c) (i)
The pseudocode has some features that make it easier to read and understand.
Identify two such features.
1
2
[2]
(ii)
Write program code to implement the pseudocode given in part (b).
Programming Language
Code
[8]
© UCLES 2015
9691/22/O/N/15
[Turn over
10
(d) The order of letters in Roman numbers is significant. Letters are placed from left to right, in
order of value, starting with the largest.
However, a sequence of four identical letters (such as IIII) is shortened as follows.
If a letter to the left is of lower value than the letter to its right, the left letter’s value becomes
negative.
Examples are shown in the following table:
Roman number
Shortened Roman number
Interpretation
Denary
IIII
IV
-1 + 5
4
VIIII
IX
-1 + 10
9
XXXX
XL
-10 + 50
40
LXXXX
XC
-10 + 100
90
CCCC
CD
-100 + 500
400
DCCCC
CM
-100 + 1000
900
Ali has to amend his pseudocode to include the conversion of these shortened Roman
numbers.
Ali has chosen some test data.
Complete the table.
RomanNumber
Expected result
Reason for choice
"MDCLXVI"
1666
Each letter used once in descending order
"CCC"
300
Multiple letters (but not 4 identical letters)
"IV"
"XIV"
"XY"
[4]
(e) Study the pseudocode below:
INPUT RomanNumber
ThisLetter ← MID(RomanNumber, 1, 1)
ThisNumber ← NumeralValue(ThisLetter)
Denary ← 0
FOR i ← 2 TO LENGTH(RomanNumber)
NextLetter ← MID(RomanNumber, i, 1)
NextNumber ← NumeralValue(NextLetter)
IF ThisNumber < NextNumber
THEN
ThisNumber ← - ThisNumber
ENDIF
Denary ← Denary + ThisNumber
ThisNumber ← NextNumber
ENDFOR
Denary ← Denary + ThisNumber
© UCLES 2015
9691/22/O/N/15
11
(i)
Dry-run the pseudocode using "IV" as input.
RomanNumber
ThisLetter
ThisNumber
"IV"
'I'
1
i
NextLetter
NextNumber
Denary
0
[2]
(ii)
Dry-run the pseudocode using "XY" as input.
RomanNumber
ThisLetter
ThisNumber
"XY"
'X'
10
i
NextLetter
NextNumber
Denary
0
[2]
(iii)
Comment on the result of the dry-run in part (e)(ii).
Describe what changes are required to the pseudocode.
[3]
(f)
Ali has written the final program code. There are syntax and logic errors in his program.
(i)
Describe when and how syntax errors are detected.
When
How
[2]
© UCLES 2015
9691/22/O/N/15
[Turn over
12
(ii)
Describe when and how logic errors are detected.
When
How
[2]
3
Sheena wants to use debugging tools available in her program development environment.
(a) Explain how each of the following are used:
(i)
Break point
[2]
(ii)
Stepping
[2]
(iii)
Variable check/watch
[2]
(b) Name the type of testing that is performed with such debugging tools.
[1]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable
effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will
be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
© UCLES 2015
9691/22/O/N/15