May 23 Q13
May 23 Q13
Three dice are thrown, with faces that have numbers from 1 to 6.
The dice are thrown seven times, and the data are stored in a two-dimensional array called
DICEDIAL (see Figure 2).
[0] 4 2 2
[1] 4 4 4
[2] 5 2 3
[3] 6 5 5
[4] 5 5 6
[5] 1 1 4
[6] 3 2 1
(a) Construct an algorithm in pseudocode to calculate the sum of all values stored in the
DICEDIAL array. [3]
The DuplicateNum() sub-program will produce the following from the values used in Figure 2:
DuplicateNum(DICEDIAL,0) returns 2
DuplicateNum(DICEDIAL,2) returns 0
The sub-program highestRT(DICEDIAL) accepts the DICEDIAL array and outputs the
highest row total and the indexes of all the rows with that total.
From the example data given in Figure 2, highestRT(DICEDIAL) would output that the
highest row total is 16, and it occurs in the rows with indexes 3 and 4.