Past-paper question · 2018 May-June · Paper 21 · Q6(b)

Question 6(b) 2018 · May-June · Paper 21 · 8 marks

Original past-paper question for 6(B)
Original past-paper question for 6(B)
Original past-paper question for 6(B)
Reveal official mark-scheme answer Official mark-scheme answer for 6(B)

Official answer for Question 6

Part (b)

✓
FUNCTION Lighten() RETURNS BOOLEAN
✓
MAX8
✓
DECLARE OldPixelValue : INTEGER
✓
DECLARE NewPixelValue : INTEGER
✓
DECLARE PixelTemp : REAL
✓
DECLARE BurnFlag : BOOLEAN
✓
DECLARE i : INTEGER
✓
DECLARE j : INTEGER
✓
BurnFlag ← FALSE
✓
FOR i ← 1 TO 8
✓
FOR j ← 1 TO 8
✓
OldPixelValue ← Picture[i, j]
✓
PixelTemp ← OldPixelValue * 1.1
✓
NewPixelValue ← INT(PixelTemp)
✓
IF NewPixelValue >= 255
✓
THEN
✓
NewPixelValue ← 255
✓
BurnFlag ← TRUE
✓
ENDIF
✓
Picture[i, j] ← NewPixelValue
✓
ENDFOR
✓
ENDFOR
✓
RETURN BurnFlag
✓
ENDFUNCTION
✓
1 mark for each of the following:

Question 1

✓
Function heading as above and ending

Question 2

✓
Declare and initialise local variable for return BOOLEAN / other mechanism
✓
to record 'burnt out'
✓
3 Declare local variables for loop counters
✓
4 Correct nested loops
✓
5 Accessing element from array
✓
6 Calculating new value and convert to an INTEGER
✓
7 Comparing new value with 255 and if greater:
✓
8 «limit to 255 and assign to original element
✓
9 «Set flag / other mechanism if limit applied (Only change once)
✓
10 Return a BOOLEAN (following conversion if other mechanism used) MUST
✓
WORK
✓
9608/21
✓
Cambridge International AS/A Level – Mark Scheme
✓
May/June 2018
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_s18_ms_21.pdf →

Show text version of question

Question 6

Part (b)

Part (b)

A 2D array, Picture, contains data representing a bitmap image. Each element of the array

represents one pixel of the image. The image is grey-scale encoded where the value of each pixel ranges from 0 (representing black) to 255 (representing white) with intermediate values representing different levels of grey.

The following is an example of an image and the corresponding data values for the Picture array.

Bitmap image Values

In pseudocode, the array is declared as follows:

DECLARE Picture : ARRAY[1:8, 1:8] OF INTEGER

Question 13

A
function, Lighten(), is required to lighten the image. Lightening an image may cause it to

‘burn out’. An image is said to be ‘burnt out’ if any pixel is set to the maximum value of 255.

The function Lighten() will:

1. increase the value of each pixel by 10% 2. return TRUE if the resultant image is ‘burnt out’.

Write pseudocode to implement the Lighten() function.

Assume that the array Picture is a global variable.

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

..........................................................................................................................................................

......................................................................................................................................................[8]

Question 14

Topic relevance

Why this question appears here

91% assigned-topic match · Data types and structures › Data types and records

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9608_s18_qp_21.pdf

Keep practising this topic