Skip to content

Course home

Data structures

Data structures

EasyMedium
1234567891011121314151617181920212223
Question 3

An algorithm is written in pseudocode using a RECORD data structure to find the fastest athlete in a running club's roster.

RECORD Runner
    name : String
    club : String
    age : Integer
    personalBest : Real
ENDRECORD

runner1 ← Runner('Amina', 'Oakfield AC', 24, 12.4)
runner2 ← Runner('Ben', 'Westside Harriers', 29, 11.2)
runner3 ← Runner('Carlos', 'Oakfield AC', 21, 13.1)
runner4 ← Runner('Devi', 'City Flyers', 27, 12.1)
roster ← [runner1, runner2, runner3, runner4]

fastestTime ← 99.9
bestIndex ← 0

FOR i ← 0 TO L1
    IF roster[i].personalBest < fastestTime THEN
        fastestTime ← roster[i].personalBest
        bestIndex ← i
    ENDIF
ENDFOR

OUTPUT roster[bestIndex].name, ' is the fastest runner.'

What should the label L1 be replaced by so that the algorithm correctly checks every runner in the array without throwing an error?

A

4

B

LEN(roster)

C

LEN(roster) - 1

D

bestIndex

Markscheme

Data structures Questions

  1. GCSE
  2. /Computer Science
  3. /Data structures

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

Question bank