Question Constellation Sign up for free

AQA · GCSE · Computer Science · Higher

Tracing an algorithm table

Q05.0 3 marks

Figure 4 shows an algorithm, represented using pseudo-code. The algorithm calculates the total cost of hiring a hotel for a wedding.

Figure 4
numberOfGuests ← USERINPUT
numberOfRooms ← USERINPUT
charge ← 25
IF numberOfGuests > 50 THEN
totalCost ← numberOfGuests * 2
ELSE
IF numberOfGuests ≥ 25 THEN
totalCost ← numberOfGuests * 4
ELSE
totalCost ← numberOfGuests * 5
ENDIF
ENDIF
totalCost ← totalCost + (numberOfRooms * 100)
IF totalCost < 1400 THEN
totalCost ← totalCost + charge
ENDIF
OUTPUT totalCost

Complete the table using the algorithm in Figure 4.

Practice unavailable

This question can be viewed, but its original response format is not available for practice yet.

Write your answer first. You can study the marking guidance whenever you need it.

Study the marking See what earns credit and compare it with a full-mark answer.

Marking points

  1. 1 Gives the correct output for inputs 50 and 30.
  2. 2 Gives the correct output for inputs 20 and 10.
  3. 3 Gives the correct output for inputs 500 and 5.

Why this answer loses marks

I calculated every row using the branch taken by the first input case.

Each row is a separate run, so its conditions and later adjustments must be traced independently.