A student is writing an algorithm for a smart locker system. Compartments are tracked using arrays.
1 SET lockerGroupA TO ["", "", "", "", "", ""]
2 SET occupiedA TO 0
3 SET lockerGroupB TO ["", "", "", "", "", ""]
4 SET occupiedB TO 0
5 SET operationalStatus TO "Ready"
6 SET systemLocked TO False
7
8 DEFINE FUNCTION assignLocker(pGroup, pPasscode)
9 DECLARE assigned AS BOOLEAN
10 SET assigned TO False
11 IF pGroup == "Alpha" THEN
12 IF occupiedA < 6 THEN
13 SET lockerGroupA[occupiedA] TO pPasscode
14 SET occupiedA TO occupiedA + 1
15 SET assigned TO True
16 END IF
17 ELSE
18 IF pGroup == "Beta" THEN
19 IF occupiedB < 6 THEN
20 SET lockerGroupB[occupiedB] TO pPasscode
21 SET occupiedB TO occupiedB + 1
22 SET assigned TO True
23 END IF
24 END IF
25 END IF
26 OUTPUT "Success: " & assigned
27 RETURN assigned
28 END FUNCTION
State 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.