Skip to content

Course home

Algorithms

Algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
Question 38

TicketCalc classifies cinema tickets by category according to a customer's age.

Here is the pseudo-code for an algorithm that determines the qualification category of a customer.

2 SET ageBoundaries TO [2, 12, 18, 65]
3 SET ticketType TO ["Infant", "Child", "Youth", "Adult", "Senior"]
4 SET found TO False
5 SET i TO 0
6
7 SEND "Enter age" TO DISPLAY
8 RECEIVE inAge FROM (INTEGER) KEYBOARD
9
10 WHILE (found = True) AND (i < LENGTH(ageBoundaries)) DO
11     IF (inAge > ageBoundaries[i]) THEN
12         SET i TO i + 1
13     ELSE
14         SET found TO True
15     END IF
16 END WHILE
17 SEND ticketType[i] TO DISPLAY

The pseudo-code produces an incorrect output.

When the user enters 15, the algorithm outputs "Infant". The correct output should be "Youth".

State the name for this type of error.

[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