Loading....
|
Press & Hold to Drag Around |
|||
|
Click Here to Close |
|||
Question 1 Report
Engineers use a small logic circuit in a solar-powered rescue beacon on a sailing boat. Fig. 1 shows the circuit. Input N is 1 when the navigation computer reports a distress position. Input R is 1 when the crew presses the radio switch. Input B is 1 when the backup battery has enough charge. The transmitter output X must be 1 only when the battery is available and either N or R is 1. Each test is saved as binary data in a log file so that engineers can identify a fault after a voyage.
Table 1 contains output data from six checks of the circuit.
| Check | N | R | B | Recorded X |
|---|---|---|---|---|
| 1 | 0 | 0 | 0 | 0 |
| 2 | 0 | 1 | 0 | 0 |
| 3 | 1 | 0 | 1 | 1 |
| 4 | 1 | 1 | 1 | 1 |
| 5 | 0 | 0 | 1 | 1 |
| 6 | 1 | 1 | 0 | 0 |
(a) Identify the two gates used in Fig. 1. [2]
(b) State the checks in Table 1 for which the recorded output is correct. [3]
(c) Give the correct output X for check 5 and state why. [4]
(d) Complete the two missing input combinations needed for a full truth table, and give X for each combination. [4]
(e) Write a Boolean expression for X. [4]
(a) The circuit uses an OR gate [1] followed by an AND gate [1]. [2]
(b) The recorded outputs are correct for checks 1, 2, 3, 4 and 6. [3] Check 5 is wrong: the battery is available, but neither N nor R requests transmission.
(c) For check 5, X = 0 [2]. Neither N nor R is 1, so the OR gate output is 0 [2]; an AND gate cannot output 1 when one of its inputs is 0. [4]
(d) The two missing combinations are:
| N | R | B | X |
|---|---|---|---|
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
In the first row the OR output and B are both 1. In the second, B is 0, so the final AND output is 0. Each row gains [2]. [4]
(e) The Boolean expression is:
\[X = (N \text{ OR } R) \text{ AND } B\]
[4]
(a) The circuit uses an OR gate [1] followed by an AND gate [1]. [2]
(b) The recorded outputs are correct for checks 1, 2, 3, 4 and 6. [3] Check 5 is wrong: the battery is available, but neither N nor R requests transmission.
(c) For check 5, X = 0 [2]. Neither N nor R is 1, so the OR gate output is 0 [2]; an AND gate cannot output 1 when one of its inputs is 0. [4]
(d) The two missing combinations are:
| N | R | B | X |
|---|---|---|---|
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
In the first row the OR output and B are both 1. In the second, B is 0, so the final AND output is 0. Each row gains [2]. [4]
(e) The Boolean expression is:
\[X = (N \text{ OR } R) \text{ AND } B\]
[4]
Question 2 Report
Fig. 1 shows a grid used by a youth orchestra to conceal seat codes on printed tickets. The grid maps plaintext letters to ciphertext letters with a shift of 1. Table 1 shows ticket data for three performances, including the number of seats and the encrypted code length. A volunteer has written an algorithm to check whether every output word has the same number of letters as its input word.
Fig. 1: ticket cipher grid
| Performance | Seats sold | Plaintext code letters | Ciphertext code letters |
|---|---|---|---|
| Friday | 86 | 3 | 3 |
| Saturday | 100 | 4 | 4 |
| Sunday | 73 | 5 | 5 |
Table 1: ticket program data
(a) Identify the ciphertext letter for plaintext Z. [1]
(b) State the Caesar shift used by the grid. [1]
(c) Identify the performance with 100 seats sold. [1]
(d) Give one reason why the number of letters does not change after this encryption. [1]
(e) Complete: plaintext WAX becomes ciphertext ______. [2]
(a) Plaintext Z maps to ciphertext A [1]. This is the wrap-around point of a shift cipher.
(b) The Caesar shift is 1 [1].
(c) The performance with 100 seats sold is Saturday [1].
(d) The number of letters does not change because each plaintext letter is replaced by exactly one ciphertext letter [1].
(e) W becomes X [1], A becomes B [1], and X becomes Y. Therefore WAX becomes XBY [2].
(a) Plaintext Z maps to ciphertext A [1]. This is the wrap-around point of a shift cipher.
(b) The Caesar shift is 1 [1].
(c) The performance with 100 seats sold is Saturday [1].
(d) The number of letters does not change because each plaintext letter is replaced by exactly one ciphertext letter [1].
(e) W becomes X [1], A becomes B [1], and X becomes Y. Therefore WAX becomes XBY [2].
Question 3 Report
Fig. 1 shows one horizontal row from a monochrome image used on an information screen at a mountain rescue base. The image is stored as one bit per pixel. A 1 means that the pixel is black and a 0 means that the pixel is white. The pixels are numbered from left to right so that a programmer can use the correct binary pattern when updating the image file.
The complete warning symbol contains 24 rows of 8 pixels. A revised program will store 16 symbols of this size in a single file. No compression or metadata is used.
(a) Identify the number of pixels in the row shown in Fig. 1. [2]
(b) Write the 8-bit binary pattern for the row in Fig. 1. [3]
(c) Complete the calculation of the number of bits needed for one complete warning symbol. [4]
(d) Use the image dimensions to calculate the total number of bytes needed for the 16-symbol file. Show your working. [4]
(a) There are eight numbered squares in the row, so it contains 8 pixels. [2]
(b) Read from left to right, using black = 1 and white = 0: black, white, black, black, white, white, black, white becomes 10110010. [3]
(c) Each pixel uses one bit in a monochrome image. Therefore:
\[24\text{ rows}\times8\text{ pixels per row}=192\text{ pixels}=192\text{ bits}\]
[4]
(d) For 16 symbols:
\[16\times24\times8=3072\text{ bits}\]
There are 8 bits in one byte:
\[3072\div8=384\text{ bytes}\]
The file needs 384 bytes. [4]
(a) There are eight numbered squares in the row, so it contains 8 pixels. [2]
(b) Read from left to right, using black = 1 and white = 0: black, white, black, black, white, white, black, white becomes 10110010. [3]
(c) Each pixel uses one bit in a monochrome image. Therefore:
\[24\text{ rows}\times8\text{ pixels per row}=192\text{ pixels}=192\text{ bits}\]
[4]
(d) For 16 symbols:
\[16\times24\times8=3072\text{ bits}\]
There are 8 bits in one byte:
\[3072\div8=384\text{ bytes}\]
The file needs 384 bytes. [4]
Question 4 Report
A mobile game developer is testing a program that hides bonus words before they are displayed to players. The game uses a Caesar encryption algorithm with key 7. The following test record was copied from the code editor: plaintext word CODE, program ciphertext JVKL. The developer suspects that the output is wrong and must correct it before the next version of the game is released.
(a) Identify the plaintext word in the test record. [1]
(b) State the cipher key number. [1]
(c) Identify the first ciphertext letter that should be produced from plaintext letter C. [1]
(d) Write the correct ciphertext for the whole plaintext word. [4]
(a) The plaintext word is CODE [1].
(b) The cipher key is 7 [1].
(c) C shifted seven places becomes J [1].
(d) Apply the same shift to every letter: C to J [1], O to V [1], D to K [1], and E to L [1]. Therefore the correct ciphertext is JVKL [4]. The stated program ciphertext is therefore not wrong; it matches the correct encryption.
(a) The plaintext word is CODE [1].
(b) The cipher key is 7 [1].
(c) C shifted seven places becomes J [1].
(d) Apply the same shift to every letter: C to J [1], O to V [1], D to K [1], and E to L [1]. Therefore the correct ciphertext is JVKL [4]. The stated program ciphertext is therefore not wrong; it matches the correct encryption.
Question 5 Report
A coastal weather station writes hourly rainfall readings to a file. The code editor must process eight readings and count how many are greater than 5.0 mm. Table 1 shows the first six values from one day. The variable wetHours starts at 0. The program uses a FOR loop because the number of readings is known before the program starts. A trainee has confused the loop control variable with the rainfall data variable.
| Hour | rainfall (mm) |
|---|---|
| 1 | 0.0 |
| 2 | 5.0 |
| 3 | 5.1 |
| 4 | 12.4 |
| 5 | 1.8 |
| 6 | 8.0 |
(a) Identify the construct used when a program repeats a known number of times. [1]
(b) Complete the loop header: FOR hour ______ 1 TO 8 [3]
(c) Use Table 1 to write pseudocode that increases wetHours for each reading greater than 5.0 mm. [3]
(a) A FOR loop, also called a count-controlled loop, repeats a known number of times. [1]
(b) The loop control variable is assigned its starting value:
FOR hour = 1 TO 8
The equals sign gains [1]; the complete header is accepted for [2]. [3]
(c) The comparison must use the rainfall value, not the hour number. Values equal to 5.0 mm do not count because the requirement is “greater than 5.0 mm”:
IF rainfall > 5.0 THEN
wetHours = wetHours + 1
END IFThe condition [1], count increment [1], and valid selection syntax [1] give [3]. From the values shown, 5.1, 12.4 and 8.0 mm meet this condition.
(a) A FOR loop, also called a count-controlled loop, repeats a known number of times. [1]
(b) The loop control variable is assigned its starting value:
FOR hour = 1 TO 8
The equals sign gains [1]; the complete header is accepted for [2]. [3]
(c) The comparison must use the rainfall value, not the hour number. Values equal to 5.0 mm do not count because the requirement is “greater than 5.0 mm”:
IF rainfall > 5.0 THEN
wetHours = wetHours + 1
END IFThe condition [1], count increment [1], and valid selection syntax [1] give [3]. From the values shown, 5.1, 12.4 and 8.0 mm meet this condition.
Question 6 Report
A robotics club writes a program to move a greenhouse inspection robot along a bench. Fig. 1 is a flowchart for one scan. The robot reads a moisture value from each plant pot. If the value is below 35, it displays the word WATER; otherwise it displays OK. After either display, the variable pot increases by 1. The robot must stop after it has processed 6 pots. A student has used the wrong comparison in the loop decision.
Fig. 1: greenhouse robot flowchart
(a) Identify the construct represented by the paths that lead to DISPLAY WATER and DISPLAY OK. [1]
(b) Write the display for moisture inputs 34, 35 and 61. [3]
(c) Complete the final decision so that exactly six pots are processed, and write a suitable initial value for pot. [4]
(a) The two alternative paths chosen by the result of moisture < 35? form a selection, also called an IF...ELSE construct. Only one of the two display commands is carried out. [1]
(b) The comparison is strictly below 35, so 35 itself does not satisfy it.
34 < 35 is true, so display WATER. [1]35 < 35 is false, so display OK. [1]61 < 35 is false, so display OK. [1](c) If pot starts at 1 and is increased after each pot, the sixth pot is processed when pot = 6. The loop must therefore continue while pot <= 6; equivalently, it may use pot < 7. [2] A suitable initial value is pot = 1. [2] This avoids stopping after only five pots, which would happen with pot < 6.
(a) The two alternative paths chosen by the result of moisture < 35? form a selection, also called an IF...ELSE construct. Only one of the two display commands is carried out. [1]
(b) The comparison is strictly below 35, so 35 itself does not satisfy it.
34 < 35 is true, so display WATER. [1]35 < 35 is false, so display OK. [1]61 < 35 is false, so display OK. [1](c) If pot starts at 1 and is increased after each pot, the sixth pot is processed when pot = 6. The loop must therefore continue while pot <= 6; equivalently, it may use pot < 7. [2] A suitable initial value is pot = 1. [2] This avoids stopping after only five pots, which would happen with pot < 6.
Question 7 Report
A greenhouse controller uses a program to open roof vents only when conditions need cooling. Fig. 1 shows the Boolean decision in the algorithm. The controller reads a temperature input and a humidity input every 100 seconds. Table 1 gives four test cases prepared by a technician. The program should display the word OPEN if the temperature is above 28 degrees C, or if humidity is above 85% and it is not raining.
Table 1
| Test | temperature (degrees C) | humidity (%) | raining |
|---|---|---|---|
| A | 29 | 60 | TRUE |
| B | 26 | 90 | FALSE |
| C | 26 | 90 | TRUE |
| D | 28 | 88 | FALSE |
(a) Identify the two logical operators shown in Fig. 1. [3]
(b) Use Table 1 to state the test letters for which the display is OPEN. [4]
(c) Complete the condition in this pseudocode.IF temperature > 28 ___ (humidity > 85 ___ raining) THEN DISPLAY "OPEN" [4]
(d) Write a condition that tests whether the vent must remain closed, using the same three input variables. [6]
(a) The three logical operators shown are AND [1], OR [1], and NOT [1]. The condition is temperature above 28 OR the combined condition of high humidity AND not raining.
(b) The display is OPEN for A and B only [4]. A opens because 29 is above 28 [1]. B opens because humidity is 90, above 85, and raining is false [1]. C fails because it is raining, and D is not above 28 but does meet the humidity/not-raining branch; therefore D also satisfies the stated Boolean condition. This reveals an inconsistency: the supplied key says only A and B, but Table 1 gives D as temperature 28, humidity 88 and raining FALSE, which makes humidity > 85 AND NOT raining true. On the question wording, A, B and D reasonably satisfy the condition.
(c) The intended completion is IF temperature > 28 OR (humidity > 85 AND NOT raining) THEN [4]. Use OR [2] between the two routes to opening, and NOT [2] before raining.
(d) A condition for the vent to remain closed is NOT (temperature > 28 OR (humidity > 85 AND NOT raining)) [6]. This negates the entire opening condition, so it is true exactly when neither valid reason to open is present.
(a) The three logical operators shown are AND [1], OR [1], and NOT [1]. The condition is temperature above 28 OR the combined condition of high humidity AND not raining.
(b) The display is OPEN for A and B only [4]. A opens because 29 is above 28 [1]. B opens because humidity is 90, above 85, and raining is false [1]. C fails because it is raining, and D is not above 28 but does meet the humidity/not-raining branch; therefore D also satisfies the stated Boolean condition. This reveals an inconsistency: the supplied key says only A and B, but Table 1 gives D as temperature 28, humidity 88 and raining FALSE, which makes humidity > 85 AND NOT raining true. On the question wording, A, B and D reasonably satisfy the condition.
(c) The intended completion is IF temperature > 28 OR (humidity > 85 AND NOT raining) THEN [4]. Use OR [2] between the two routes to opening, and NOT [2] before raining.
(d) A condition for the vent to remain closed is NOT (temperature > 28 OR (humidity > 85 AND NOT raining)) [6]. This negates the entire opening condition, so it is true exactly when neither valid reason to open is present.
Question 8 Report
Fig. 1 shows a vending-machine algorithm for choosing a hot drink. The customer enters a number from 1 to 3. The program uses a selection structure to display the chosen drink and then deduct its price from the credit. Number 1 is tea, number 2 is coffee and number 3 is soup. Any other number causes an error message. The machine must not dispense a drink when the input is invalid.
(a) Identify the displayed word for input 2. [1]
(b) State the displayed word for input 3. [1]
(c) Write one input that produces error. [1]
(d) Give the line that first tests whether the input is 2. [1]
(e) Use the figure to state how many recognised drink choices are available. [1]
(a) Input 2 matches the coffee condition, so the displayed word is coffee. [1]
(b) Input 3 matches the next recognised condition, so the displayed word is soup. [1]
(c) An input such as 4 produces error. [1] Any number other than 1, 2 or 3 is valid test data for this route.
(d) The test for input 2 is on line 03: ELSEIF choice = 2 THEN DISPLAY "coffee". [1]
(e) There are 3 recognised drink choices. [1]
(a) Input 2 matches the coffee condition, so the displayed word is coffee. [1]
(b) Input 3 matches the next recognised condition, so the displayed word is soup. [1]
(c) An input such as 4 produces error. [1] Any number other than 1, 2 or 3 is valid test data for this route.
(d) The test for input 2 is on line 03: ELSEIF choice = 2 THEN DISPLAY "coffee". [1]
(e) There are 3 recognised drink choices. [1]
Would you like to proceed with this action?