Skip to content

Course home

Algorithms

Algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
Question 76

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.

[1]
Markscheme

Algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Algorithms

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.

Question bank