AQA GCSE · Question 10.1 · Fundamentals of algorithms
Figure 9 shows an algorithm, represented in pseudo-code, used to display students' test scores. The algorithm does not work as expected and the teacher wants to find the error.
The algorithm should display three test scores for each student:
- Natalie has results of 78, 81 and 72
- Alex has results of 27, 51 and 54
- Roshana has results of 52, 55 and 59.
Figure 9
1 names ← ['Natalie', 'Alex', 'Roshana']
2 scores ← [78, 81, 72, 27, 51, 54, 52, 55, 59]
3 count ← 0
4 FOR i ← 0 TO 2
5 person ← names[i]
6 OUTPUT 'Student: ', person
7 FOR j ← 0 TO 1
8 OUTPUT j + 1
9 result ← scores[i * 3 + j]
10 OUTPUT result
11 count ← count + 1
12 ENDFOR
13 ENDFOR
Complete the trace table for the algorithm shown in Figure 9. You may not need to use all the rows in the table.
Figure 9 shows an algorithm, represented in pseudo-code, used to display students' test scores. The algorithm does not work as expected and the teacher wants to find the error.
The algorithm should display three test scores for each student:
- Natalie has results of 78, 81 and 72
- Alex has results of 27, 51 and 54
- Roshana has results of 52, 55 and 59.
Figure 9
1 names ← ['Natalie', 'Alex', 'Roshana']
2 scores ← [78, 81, 72, 27, 51, 54, 52, 55, 59]
3 count ← 0
4 FOR i ← 0 TO 2
5 person ← names[i]
6 OUTPUT 'Student: ', person
7 FOR j ← 0 TO 1
8 OUTPUT j + 1
9 result ← scores[i * 3 + j]
10 OUTPUT result
11 count ← count + 1
12 ENDFOR
13 ENDFOR
Complete the trace table for the algorithm shown in Figure 9. You may not need to use all the rows in the table.
How to approach this question
Full Answer
Common mistakes
Practice the full AQA GCSE Computer Science Paper 1 Python
31 questions · hints · full answers · grading
Expert