Computer Science · Oct / Nov 2020 · Paper 1 HL · Question 13
Adapt for 2027Inverting and rotating an image stored in a 2D array is covered by B2.2.2; rewrite the pseudocode in Python or Java.
IBCS
As printed in the paper
The question as text
13. Images in computers are stored as two-dimensional arrays. A black-and-white image (Figure 1) is stored as a 10 × 10 two-dimensional array named MAT (Figure 2). Each element of MAT holds a number for a colour; 1 represents the colour black and 0 represents the colour white. Figure 1: The simple black-and-white image Figure 2: The corresponding two-dimensional array MAT [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [0] 0 0 0 0 0 0 0 1 0 0 [1] 0 0 0 1 0 0 0 0 1 0 [2] 0 0 0 1 0 0 0 0 0 1 [3] 0 0 0 1 0 0 0 0 0 0 [4] 0 0 0 1 0 0 0 0 0 0 [5] 0 0 0 1 0 0 0 0 0 0 [6] 0 0 0 1 0 0 0 0 0 0 [7] 0 0 0 1 0 0 0 0 0 0 [8] 0 0 0 1 1 1 1 1 0 0 [9] 0 0 0 0 0 0 0 0 0 0 In an application, the black-and-white image can be inverted (all white pixels are changed to black, and all black pixels are changed to white). Method invert(N,A)accepts a positive integer N and an N × N two-dimensional array A that holds the data for a simple black-and-white image; it returns the inverted N × N two-dimensional array A.
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
13(a)[3]
13(b)(i)[1]
13(b)(ii)[2]
13(c)[3]
13(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.

