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 are 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 to 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. [Diagram showing a grid with a shaded oval touch, a black shaded centre at row 6, col 11, with axes labeled 6 and 11] A program is needed to find the coordinates (the row and column) of the centre point. The centre point on the diagram above 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 started to define program modules as follows: Module Description SetRow() • Called with three parameters of type INTEGER: (generates test • a row number data) • the number of pixels to be skipped starting from column 1 • the number of pixels that should be set to 1 • Sets the required number of pixels to 1 For example, SetRow(3, 8, 5) will give row 3 as in the diagram shown. SearchInRow() • Takes two parameters of type INTEGER: • a row number • a start column (1 or 1280) • Searches the given row from the start column (either left to right or right to left) for the first column that contains an element set to 1 • Returns the column number of the first element in the given row that is set to 1 • Returns –1 if no element is set to 1 SearchInCol() • Takes two parameters of type INTEGER: • a column number • a start row (1 or 800) • Searches the given column from the start row (either up or down) for the first row that contains an element set to 1 • Returns the row number of the first element in the given column that is set to 1 • Returns –1 if no element is set to 1
✓ Correct Answer
The correct answer is —. This question tests the candidate's understanding of data structures within the Computer Sciencesyllabus. The examiner's mark scheme requires...
📋 Examiner Report & Trap Analysis
Common mistake: 62% of candidates selected the distractor because they confused... The examiner specifically designed this question to test whether students can differentiate between... To secure full marks, candidates must demonstrate...
Unlock the Examiner's Answer
Sign up for free to reveal the correct answer, the official mark scheme breakdown, and the examiner trap analysis for this question.
Sign Up Free to Unlock →Join thousands of Cambridge students already using Oracle Prep