Professional Documents
Culture Documents
The Aim of this assignment is to help you understand the application of algorithms to Arrays of Records.
Consider the "Qualifying" Array of Records data on Page 191.
The algorithm in Fig 4.28 calculates the fastest lap time for each car.
Complete these 2 parts in ONE word document and upload it when you are finished.
1. Copy the algorithm and FOR EACH LINE explain the purpose of the line. In doing so describe the purpose of all variables as
they occur and of the indices in the array. (It is not sufficient to write "starts a WHILE loop". You must explain the loop and say what
the loop achieves in the whole algorithm.) You can expect a question like this in the next assessment task. You might want to do this
in a table, in landscape.
Algorithm
BEGIN CalculateFastestLaps
Count = 1
WHILE Count <= Total Cars
Num = 2
Fastest = 1
WHILE Num <= 5
IF Qualifying(Count).Lap(Num) < Qualifying(Count).Lap(Fastest) THEN
Fastest = Num
ENDIF
Num = Num + 1
ENDWHILE
Display Qulifying(Count).Driver, Qualifying(Count).Lap(Fastest)
Count = Count + 1
ENDWHILE
END CalculateFastestLaps
Output
The output of this algorithm will display the fastest lap time for each car.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++
Algorithm
The Algorithm
BEGIN CalculateFastestLaps
Count = 1
WHILE Count <= Total cars
Num = 2
Fastest = 1
WHILE Num <= 5
IF Qualifying(Count).Lap(Num) <
Qualifying(Count).Lap(Fastest) THEN
Fastest = Num
ENDIF
Num = Num + 1
ENDWHILE
Display Qualifying(Count).Driver,
Qualifying(Count).Lap(Fastest)
Count = Count + 1
ENDWHLE
END CalculateFastestLaps
Output
The output of this algorithm will display the fastest lap time for each car, such as: KLINGMANN- 7:59, STIPPLER- 7:57,
MULLER- 8:31