Data structures

EasyMedium
1234567891011121314151617181920212223
Question 23
Easy

An algorithm is written in pseudocode using a RECORD data structure to find the deepest research probe from a marine telemetry array.

RECORD DeepSeaProbe
    probeID : String
    location : String
    depth : Integer
    temperature : Real
ENDRECORD

probe1 ← DeepSeaProbe('P-101', 'Mariana Trench', 10911, 2.1)
probe2 ← DeepSeaProbe('P-102', 'Tonga Trench', 10882, 1.8)
probe3 ← DeepSeaProbe('P-103', 'Philippine Trench', 10540, 2.4)
probe4 ← DeepSeaProbe('P-104', 'Kermadec Trench', 10047, 1.5)
probe5 ← DeepSeaProbe('P-105', 'Kuril-Kamchatka Trench', 10500, 1.9)
activeProbes ← [probe1, probe2, probe3, probe4, probe5]

deepestDepth ← -1
deepestIndex ← 0

FOR k ← 0 TO L_BOUND
    IF activeProbes[k].depth > deepestDepth THEN
        deepestDepth ← activeProbes[k].depth
        deepestIndex ← k
    ENDIF
ENDFOR

OUTPUT activeProbes[deepestIndex].probeID, ' is the deepest probe.'

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

LEN(activeProbes)

LEN(activeProbes) - 1

5

deepestIndex

Data structures Questions

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