Skip to content

Course home

Algorithms

Algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
Question 24

Here is a pseudo-code algorithm designed to calculate the forecasted server load scaling for an online platform over a 5-hour launch window.

2  # Expected loads over 5 hours post-launch
3  SET hourNumber TO ["+1", "+2", "+3", "+4", "+5"]
4  SET loadScaling TO [115, 130, 145, 160, 180]
5  SET goodInput TO False
6
7  # Validate base load capacity
8  WHILE (goodInput = False) DO
9      SEND "Enter the baseline server capacity (min 500): " TO DISPLAY
10     RECEIVE baseCapacity FROM (INTEGER) KEYBOARD
11
12     IF (baseCapacity >= 500) THEN
13         SET goodInput TO True
14         SEND "Baseline capacity recorded: " & baseCapacity TO DISPLAY
15     ELSE
16         SEND "Invalid baseline capacity" TO DISPLAY
17     END IF
18 END WHILE
19
20 # Calculate hourly scaling requirements
21 FOR i FROM 0 TO (LENGTH(hourNumber)-1)
22     SET scaleFactor TO loadScaling[i] / 100
23     SET forecastedLoad TO baseCapacity * scaleFactor
24     SEND "Hour " & hourNumber[i] & " forecast: " & forecastedLoad TO DISPLAY
25 END FOR

Complete the trace table to show the execution of lines 21 to 25 of the pseudo-code for the event iteration where i = 2 when the user enters the value 800 at line 10.

baseCapacityiLENGTH(hourNumber)scaleFactorloadScaling[i]forecastedLoad
[6]
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