Question 5
AQA Computer Science June 2020 Paper 1GCSE6 marks
On the specification
- 5.1
- 3.1 Fundamentals of algorithms3.3 Fundamentals of data representation
- 5.2
- 3.1 Fundamentals of algorithms3.2 Programming
- 5.3
- 3.3 Fundamentals of data representation
- 5.4
- 3.1 Fundamentals of algorithms
Question text
5 The algorithms shown in Figure 4 and Figure 5 both have the same purpose. The operator LEFTSHIFT performs a binary shift to the left by the number indicated. For example, 6 LEFTSHIFT 1 will left shift the number 6 by one place, which has the effect of multiplying the number 6 by two giving a result of 12 Figure 4 result ← number LEFTSHIFT 2 result ← result – number Figure 5 result ← 0 FOR x ← 1 TO 3 result ← result + number ENDFOR 5.1 Complete the trace table for the algorithm shown in Figure 4 when the initial value of number is 4 You may not need to use all rows of the trace table. [2 marks] result 5.2 Complete the trace table for the algorithm shown in Figure 5 when the initial value of number is 4 You may not need to use all rows of the trace table. [2 marks] x result 5.3 The algorithms in Figure 4 and Figure 5 have the same purpose. State this purpose. [1 mark] 5.4 Explain why the algorithm shown in Figure 4 can be considered to be a more efficient algorithm than the algorithm shown in Figure 5. [1 mark]