Skip to content

Course home

Representing algorithms

Representing algorithms

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
Question 44

An algorithm is designed to analyze a sequence of temperature sensor readings stored in an array named telemetry. The algorithm's purpose is to find the length of the longest continuous period during which the temperature remained constant (the longest steady-state run).

The pseudocode below contains several missing parts, represented by the labels L1 and L2.

telemetry ← [array of temperature readings]
max_steady ← 0
curr_steady ← L1
index ← 0
WHILE index < LEN(telemetry) - 1
    IF telemetry[index] = telemetry[index + 1] THEN
        curr_steady ← curr_steady + 1
    ELSE
        IF curr_steady > max_steady THEN
            max_steady ← curr_steady
        ENDIF
        curr_steady ← L2
    ENDIF
    index ← index + 1
ENDWHILE
IF curr_steady > max_steady THEN
    max_steady ← curr_steady
ENDIF

Identify the correct value that must be assigned to L2 to ensure the algorithm correctly calculates the maximum steady-state run length.

A

000

B

111

C

max_steady\text{max\_steady}max_steady

D

index\text{index}index

Markscheme

Representing algorithms Questions

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

208 exam-style questions on AQA GCSE Computer Science Representing algorithms. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank