Representing algorithms

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
Question 41
Medium

An algorithm is designed to validate the flight parameters of a high-altitude research balloon and calculate its ascent distance.

1  validMission ← False
2  REPEAT
3      ascentDistance ← -99
4      OUTPUT 'Enter launch altitude (km)'
5      launchAlt ← USERINPUT
6      OUTPUT 'Enter burst altitude (km)'
7      burstAlt ← USERINPUT
8      IF launchAlt ≥ burstAlt THEN
9          OUTPUT 'Launch altitude must be below burst altitude'
10     ELSE
11         IF burstAlt > 35 THEN
12             OUTPUT 'Burst altitude cannot exceed 35 km safety limit'
13         ELSE
14             validMission ← True
15         ENDIF
16     ENDIF
17 UNTIL validMission = True
18 ascentDistance ← burstAlt - launchAlt
19 OUTPUT ascentDistance

The table below shows three independent tests used to check the algorithm.

Complete the table to show the values of the validMission and ascentDistance variables at the end of each independent test execution.

Test typeTest datavalidMissionascentDistance
NormallaunchAlt12
burstAlt30
ErroneouslaunchAlt40
burstAlt25
BoundarylaunchAlt10
burstAlt35
[4]

Representing algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Representing algorithms