Time allowed: 1 hour 30 minutes
(a) Complete the flowchart logic below by filling in the empty boxes and labels. The flowchart should ask for a user's age. If the age is greater than or equal to 18, it outputs "Adult", otherwise it outputs "Child".
(b) Explain two benefits of using parameters to pass data into a subprogram, rather than using global variables.
(a) Compare the efficiency of a Linear Search to a Binary Search when searching for an item in a very large, sorted array.
(b) State why a Linear Search must be used if the array contains unsorted data.
(a) Tick (✓) one box in each row to show whether the statement applies to a Compiler, an Interpreter, or Both.
| Statement | Compiler | Interpreter | Both |
|---|---|---|---|
| Translates high-level code into machine code | |||
| Translates and executes the code line-by-line | |||
| Produces a final executable file that can be distributed | |||
| Stops translating as soon as the first error is found |
(b) Explain why a software company would choose to use a Compiler rather than an Interpreter when releasing their final commercial software to the public.
(a) State the difference between Validation and Verification.
(b) Identify two methods a programmer can use to improve the maintainability of their code, and state how each method helps.
Method 1:
How it helps:
Method 2:
How it helps:
(a) Define the term Casting in programming.
(b) Write a single line of OCR Reference Language to cast the string variable "54" to an integer and store it in a variable called numValue.
(c) A program uses the string variable sensorStatus = "Warning-Active".
Complete the table to show the output of each string manipulation statement.
| Statement | Output |
|---|---|
print(sensorStatus.left(7)) | |
print(sensorStatus.length) | |
print(sensorStatus.substring(8, 6)) | |
print(sensorStatus.upper) |
Context: Eco-Tech Environmental Monitoring System
(a) An environmental alarm triggers (P = 1) if the temperature is high (A = 1) OR the humidity is high (B = 1), AND the manual override switch is NOT pressed (C = 0).
Draw a logic gate circuit to represent the Boolean expression: P = (A OR B) AND (NOT C)
(b) Complete the truth table for the logic circuit.
| A | B | C | (A OR B) | (NOT C) | P |
|---|---|---|---|---|---|
| 0 | 0 | 0 | |||
| 0 | 0 | 1 | |||
| 0 | 1 | 0 | |||
| 0 | 1 | 1 | |||
| 1 | 0 | 0 | |||
| 1 | 0 | 1 | |||
| 1 | 1 | 0 | |||
| 1 | 1 | 1 |
(a) The system receives data from a temperature sensor. A valid temperature reading is between 0 and 100 degrees inclusive.
Complete the test plan table with one example of test data for each category, and state the reason for choosing that data.
| Test Category | Test Data Example | Reason for Test |
|---|---|---|
| Normal Data | ||
| Valid Boundary Data | ||
| Invalid Data |
(b) Explain why it is essential to test the sensor software with Invalid data during development.
A technician must authenticate to override the alarm. The correct passcode is "ECO2026".
Write an algorithm that:
A trace table is used to test the power-saving algorithm for a remote sensor.
Complete the trace table for this algorithm.
| batteryLevel | powerSave | hours | Output |
|---|---|---|---|
| 100 | False | 0 | |
*Note: Section B total is 40 marks: Q6(10) + Q7(10) + Q8(10) + Q9(10)*