Question 1

AQA Computer Science June 2024 Paper 1 (7516/1)AS5 marks

On the specification

3.4 Theory of computation3.1 Fundamentals of programming
Question text

1 Figure 1 S1 ← "011101" S2 ← "001100" C ← "0" R ← "" FOR J = 0 TO 5 X ← 5 - J D1 ← S1[X] D2 ← S2[X] IF C = "0" THEN IF D1 = D2 THEN S ← "0" C ← D1 ELSE S ← "1" ENDIF ELSE IF D1 = D2 THEN S ← "1" C ← D1 ELSE S ← "0" ENDIF ENDIF R ← CONCATENATE(S, R) ENDFOR OUTPUT R The function CONCATENATE(X, Y) returns the string formed by concatenating the string Y to the end of string X. For example, CONCATENATE("cat", "dog") returns "catdog". The strings are zero index based. Complete Table 1 by hand-tracing the algorithm in Figure 1. You may not need to use all the rows in Table 1. You do not need to indicate that C, D1, D2 and S are strings. The first row of Table 1 has already been completed for you. Table 1 S1 S2 C R J X D1 D2 S "011101" "001100" "0" "" OUTPUT: Copy the contents of all the unshaded cells in Table 1 into your Electronic Answer Document. [5 marks]