The algorithm in Figure 1 is intended to find and output the minimum value in an array of integers.
Figure 1
1 items = [14, 27, 8, 19, 5]
2 min_val = items
3 index = 0
4 while index < len(items) - 1
5 if items[index] < min_val then
6 min_val = items[index]
7 endif
8 index = index + 1
9 endwhile
10 print(min_val)
Describe how line 4 should be changed so that the program works correctly and checks all elements in the array.
298 exam-style questions on AQA GCSE Computer Science Programming concepts. Each one has a worked solution and a mark scheme showing where the marks go.