Question 6(b) 2021 · October-November · Paper 22 · 2 marks
Reveal official mark-scheme answer
Official answer for Question 6
Part (b)
Question 2
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
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
- Returns −1 if there are no elements set to 1
- Searches for the last row that has an array element set to 1
- Returns −1 if there are no elements set to 1
- Searches for the first column that has an array element set to 1
- Returns −1 if there are no elements set to 1
- Searches for the last column that has an array element set to 1
- Returns −1 if there are no elements set to 1
FirstRowSet() • Returns the index of that row (1 is the first row)
LastRowSet() • Returns the index of that row
FirstColSet() • Returns the index of that column (1 is the first column)
LastColSet() • Returns the index of that column
Question 17
Part (b)
Describe a feature of your solution to part
Part (a)
that indicates the pseudocode represents an
efficient algorithm.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................
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
