Question 10

AQA Computer Science June 2022 Paper 1C (8525/1C)GCSE8 marks

On the specification

10.1
3.1 Fundamentals of algorithms3.2 Programming
10.2
3.1 Fundamentals of algorithms3.2 Programming
10.3
3.2 Programming
10.4
3.2 Programming
Question text

10 box Figure 9 shows a subroutine represented using pseudo-code. Figure 9 SUBROUTINE calculate(n) a  n b  0 REPEAT a  a DIV 2 b  b + 1 UNTIL a ≤ 1 OUTPUT b ENDSUBROUTINE The DIV operator is used for integer division. 10.1 Complete the trace table for the subroutine call calculate(50) You may not need to use all the rows in the table. [4 marks] n a b OUTPUT 50 10.2 State the value that will be output for the subroutine call calculate(1) box [1 mark] 10.3 The identifier for the variable b in Figure 9 was not a good choice. State a better identifier for this variable that makes the algorithm easier to read and understand. [1 mark] 10 4 box . A REPEAT…UNTIL iteration structure was used in Figure 9. Figure 9 has been included again below. Figure 9 SUBROUTINE calculate(n) a  n b  0 REPEAT a  a DIV 2 b  b + 1 UNTIL a ≤ 1 OUTPUT b ENDSUBROUTINE Figure 10 shows another subroutine called calculate that uses a WHILE…ENDWHILE iteration structure. Figure 10 SUBROUTINE calculate(n) a  n b  0 WHILE a > 1 a  a DIV 2 b  b + 1 ENDWHILE OUTPUT b ENDSUBROUTINE One difference in the way the subroutines in Figure 9 and Figure 10 work is: • the REPEAT…UNTIL iteration structure in Figure 9 loops until the condition is true • the WHILE…ENDWHILE iteration structure in Figure 10 loops until the condition is false. Describe two other differences in the way the subroutines in Figure 9 and Figure 10 box work. [2 marks] 1 2