Computer Science (AS & A Level) · Oct / Nov 2023 · Paper 22 · Question 8
9618
As printed in the paper
The question as text
A class of students are developing a program to send data between computers. Many computers are connected together to form a wired network. Serial ports are used to connect one computer to another. Each computer: • is assigned a unique three-digit ID • has three ports, each identified by an integer value • is connected to between one and three other computers. Data is sent as individual message strings. Each string contains the destination ID (the ID of the computer that is to receive the message) followed by the data: <DestinationID><Data> Messages may pass through several computers on the way to their destination. When a message arrives at a computer, that is not the destination, the program needs to forward it on to another computer using one of its serial ports. The port to use is obtained from information that is stored in an array RouteTable. RouteTable is a global 2D array of integers. It is declared in pseudocode as follows: DECLARE RouteTable : ARRAY[1:6,1:3] OF INTEGER The values in the first two columns of RouteTable define a range of ID values. Column 3 gives the corresponding port number to use when forwarding the message to a computer with an ID within this range. For example, the contents of RouteTable could be: Column 1 Column 2 Column 3 Row 1 100 199 1 Row 2 200 259 2 Row 3 −1 <undefined> <undefined> Row 4 260 399 2 Row 5 400 599 3 Row 6 600 999 1 In this example, a message that arrives with a DestinationID of "283" will be forwarded using port 2. Row 3 in the example shows an unused row. These may occur anywhere. Unused rows have the column 1 element set to −1. The value of unused elements in the other two columns is undefined. 17 The programmer has defined the first program module as follows: Module Description GetPort() • takes a DestinationID as a parameter of type string • searches for the range corresponding to the DestinationID in the array • returns the port number, or returns −1 if no corresponding range is found
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
8(a)[7]
8(b)[7]
8(c)(i)[3]
8(c)(ii)[1]
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

