A student is writing an algorithm for a warehouse stock allocation system. Shelf locations are tracked using arrays.
1 SET shelfA TO ["", "", "", "", "", "", "", "", "", ""]
2 SET countA TO 0
3 SET shelfB TO ["", "", "", "", "", "", "", "", "", ""]
4 SET countB TO 0
5 SET systemStatus TO "Active"
6 SET isFull TO False
7
8 DEFINE FUNCTION placeStock(pShelf, pBarcode)
9 DECLARE success AS BOOLEAN
10 SET success TO False
11 IF pShelf == 1 THEN
12 IF countA < 10 THEN
13 SET shelfA[countA] TO pBarcode
14 SET countA TO countA + 1
15 SET success TO True
16 END IF
17 ELSE
18 IF pShelf == 2 THEN
19 IF countB < 10 THEN
20 SET shelfB[countB] TO pBarcode
21 SET countB TO countB + 1
22 SET success TO True
23 END IF
24 END IF
25 END IF
26 OUTPUT "Operation: " & success
27 RETURN success
28 END FUNCTION
Give a line number of an instruction in the algorithm that assigns a value to an element of an array.
159 exam-style questions on Edexcel GCSE Computer Science Algorithms, covering Constructs for solving problems, Variables, constants and data structures, Arithmetic, relational and logical operators, Tracing algorithm output with trace tables, Types of error and correcting logic errors, Standard algorithms (sorts and searches), and Evaluating algorithm fitness and efficiency. Each one has a worked solution and a mark scheme showing where the marks go.