Algorithms

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738
Question 10
Medium

A pseudocode algorithm that monitors weather drone altitude readings is shown below.

The first four inputs read from the file AltitudeLog.txt are 180, 320, 95, and 240 in that order.

Complete the trace table showing the execution of the pseudocode with these four inputs. You may not need to use all the rows in the table.

1 SET altitude TO 0
2 SET min_alt TO 500
3 SET max_alt TO 200
4
5 FOR EACH altitude FROM "AltitudeLog.txt" DO
6     IF (altitude < min_alt) THEN
7         SET min_alt TO altitude
8     ENDIF
9     IF (altitude > max_alt) THEN
10        SET max_alt TO altitude
11    ENDIF
12 END FOREACH
13
14 SEND min_alt & " to " & max_alt TO DISPLAY
altitudemin_altmax_altDisplay
[6]

Algorithms Questions

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