Past-paper question · 2021 October-November · Paper 22 · Q6(b)

Question 6(b) 2021 · October-November · Paper 22 · 2 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)

✓
One mark for:

Question 2

✓
•
✓
(A flag is used to) exit the loops // iteration is terminated
✓
•
✓
as soon as a Screen element with value 1 is found
✓
9618/22
✓
Cambridge International AS & A Level – Mark Scheme
✓
October/November
✓
PUBLISHED
✓
2021
✓
Question
✓
Answer
✓
Marks

Mark scheme 9618_w21_ms_22.pdf →

Show text version of question

Question 6

Part (b)

Question 6

A mobile phone has a touchscreen. The screen is represented by a grid, divided into 800 rows

and 1280 columns.

The grid is represented by a 2D array Screen of type INTEGER. An array element will be set to 0 unless the user touches that part of the screen.

Many array elements will set to 1 by a single touch of a finger or a stylus.

The following diagram shows a simplified touchscreen. The dark line represents a touch on the screen. All grid elements that are wholly or partly inside the outline will be set to 1. These elements are shaded. The element shaded in black represents the centre point of the touch.

Question 11

Question 6

A
program is needed to find the coordinates (the row and column) of the centre point. The centre

point on the diagram shown is row 6, column 11.

Assume:

  • the user may only touch one area at a time
  • screen rotation does not affect the touchscreen.

The programmer has decided to use global values CentreRow and CentreCol as coordinate values for the centre point.

The programmer has started to define program modules as follows:

Module Description

  • Searches for the first row that has an array element set to 1
  • FirstRowSet() • Returns the index of that row (1 is the first row)

  • Returns −1 if there are no elements set to 1
  • Searches for the last row that has an array element set to 1
  • LastRowSet() • Returns the index of that row

  • Returns −1 if there are no elements set to 1
  • Searches for the first column that has an array element set to 1
  • FirstColSet() • Returns the index of that column (1 is the first column)

  • Returns −1 if there are no elements set to 1
  • Searches for the last column that has an array element set to 1
  • LastColSet() • Returns the index of that column

  • Returns −1 if there are no elements set to 1

Question 17

Part (b)

Describe a feature of your solution to part

Part (a)

that indicates the pseudocode represents an

efficient algorithm.

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

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

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

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

[2]
Topic relevance

Why this question appears here

71% assigned-topic match · Algorithm design and problem-solving › Algorithms

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 9618_w21_qp_22.pdf

Keep practising this topic