Computer Science (AS & A Level) · Oct / Nov 2021 · Paper 22 · Question 6
9618
As printed in the paper
The question as text
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. 11 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 FirstRowSet() • Searches for the first row that has an array element set to 1 • Returns the index of that row (1 is the first row) • Returns −1 if there are no elements set to 1 LastRowSet() • Searches for the last row that has an array element set to 1 • Returns the index of that row • Returns −1 if there are no elements set to 1 FirstColSet() • Searches for the first column that has an array element set to 1 • Returns the index of that column (1 is the first column) • Returns −1 if there are no elements set to 1 LastColSet() • Searches for the last column that has an array element set to 1 • Returns the index of that column • Returns −1 if there are no elements set to 1
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
6(a)[7]
6(b)[2]
6(c)(i)[2]
6(c)(ii)[2]
6(d)[6]
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

