Time allowed: 1 hour 30 minutes
Answer all the questions.
The total mark for this paper is 80.
(a) A program is designed to calculate the total cost of a shopping basket. Identify the inputs, processes, and outputs for this program.
(b) Draw a structure diagram for a system that manages a "Smart Home". The system should include sub-modules for "Heating", "Security", and "Lighting".
(a) Draw the logic diagram for the following Boolean expression: (A AND B) OR (NOT C).
(b) Complete the truth table for the expression in 2(a).
| A | B | C | A AND B | NOT C | Result |
|---|---|---|---|---|---|
| 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) Explain the difference between a Binary Search and a Linear Search. State one condition required for a binary search to work.
(b) Describe how a Bubble Sort algorithm works to sort an array of numbers into ascending order.
(c) Perform a Binary Search for the number 18 in the following list. Show the state of the list at each step.
[2, 5, 8, 12, 15, 18, 22, 25, 30]
(a) Explain the three basic programming constructs: Sequence, Selection, and Iteration. Provide a short pseudocode example for each.
(b) The following algorithm has a logic error. Identify the error and provide a refined version of the code.
Identification:
Refined Code:
(a) Explain what is meant by Casting and why it is necessary when a user inputs their age.
(b) Identify the most suitable data type for the following pieces of data:
(a) Describe how Input Validation and Authentication contribute to the robustness of a program.
(b) Explain the purpose of testing during the development of a program. Contrast Iterative Testing with Final Testing.