An indie game developer is writing a script to sort a leaderboard of the top 6 player scores in descending order using a bubble sort algorithm.
The developer's draft algorithm is shown below:
1 scores[0] ← 1420
2 scores[1] ← 890
3 scores[2] ← 2150
4 scores[3] ← 530
5 scores[4] ← 1760
6 scores[5] ← 1110
7 FOR i ← 0 TO 4
8 FOR j ← 0 TO 4
9 IF scores[j + 1] > scores[j] THEN
10 temp ← scores[j]
11 scores[j] ← scores[j + 1]
12 scores[j + 1] ← temp
13 ENDIF
14 ENDFOR
15 ENDFOR
In a previous version of this script, lines 7 and 8 were written as:
7 FOR i ← 0 TO 5
8 FOR j ← 0 TO 5
Explain why the script would trigger a runtime error if the value 5 was used instead of 4 on line 8.