Year 12

AQA A level Computer Science [P2] Design Tools Notes

Problem Solving & Design Tools

— Computer Science · A Level (9618) Paper 2 · Part B: Abstraction · Structure Charts · Flowcharts · State-Transition · Records · Structured English —
★ Exam Tip: Abstraction / decomposition questions are 2–5 mark "easy marks"; structure charts and flowcharts are drawn questions worth 3–7 marks — learn the symbols exactly.
Sir's notes: Structure-chart questions are "fun, easy" — think it through, don't panic. State-transition questions also come regularly. For a flowchart definition, "a pictorial representation of an algorithm" is enough. Pseudocode is only for understanding on paper — it is never run, and its syntax differs from language to language (university code will look different).

1. Abstraction

Definition: the process of simplifying a complex problem by focusing on the essential features and ignoring irrelevant details.

Need / benefits of abstraction: ① the solution is simplified — the problem is easier and quicker to design / implement ② the system is tailored to the need of the user
Link: the technique used to "filter out information that is not essential" = abstraction. Decomposition (Part A: stepwise refinement) = breaking into sub-problems.
library loans2 + 1 + 2 marks

A system manages book loans in a library. Registered users borrow books for a period of time.

(i) 3 items stored for each loan: User ID / username · Book ID · Date of loan / return date (1 mark for 1 correct, 2 marks for all 3, max 2) (ii) 1 item needed in the system but NOT stored per loan (must relate to users, books or loans): user's name / address / phone / DOB · book title / author / publisher / rack number / ISBN / price · length of loan (iii) 2 other operations (one given = list overdue books): create loan / borrow book · return book · send letter / email to user about overdue book · view loan history for a book · view loan history for a user
airline booking3 + 2 + 2 marks

Online booking system — tick whether each item is essential for the customer when making the booking:

Information Essential Not essential
Departure time ✓
Flight number ✓
Departure airport ✓
Aircraft type ✓
Ticket price ✓
Number of seats in aircraft ✓

Marks: 2 rows correct = 1 · 4 rows = 2 · all 6 = 3.

(ii) Technique: Abstraction. Benefit (max 1): solution simplified so easier / quicker to design / implement · system tailored to the need of the user. (iii) 2 more essential items: destination / arrival airport · arrival time / flight duration · date of flight · seat number · seat availability.

2. Decomposition into Program Modules

Decomposition = break the problem into sub-problems, each solved by a module (a function or a procedure).

Function Procedure
returns a value does NOT return a value
cinema booking3 + 1 marks

Cinema with several screens, each showing a different film. Describe three program modules.

✓ allows the user to search for the films being shown (input name of film they want)✓ allows the user to search for available seats✓ calculate the cost of the booking✓ book a given number of seats for a particular screening

(b) The type of module used to return a value = Function.

library overdue emails3 marks

New module generates emails to students with an overdue book. Identify three modules and their use (1 mark for name and use, max 3):

GetOverdueLoan() — identifies an overdue bookIdentifyStudent() — identifies the student with the overdue bookGetStudentEmail() — gets the student's email addressCreateEmail() — generates the emailSendEmail() — sends it

3. Structure Chart

Purpose: helps to understand a complex program and shows the relationship between modules — which module calls which and which parameters pass between them.

Features of a structure chart: ① hierarchy of modules ② iteration ③ selection ④ the parameters passed between modules

Symbols

value (data) passed between modules — open circle Boolean value / flag passed — filled circle selection (IF / CASE) — diamond at the calling module repetition (loop) — curved arrow around the calls by reference — value passed in and changed (two-way arrow)
an arrow's direction shows whether the value goes down (into) or up (out of) the module
Call by value Call by reference
copy of the variable passed — one-way down arrow variable itself passed — two-way arrow; value can be changed
car rentalstructure chart · 4–5 marks
Module Description
RentCar() customer pays for each rental by bank card or by account (→ selection)
PayByCard() called with HireCost; returns a BOOLEAN — was card payment successful
PayByAccount() called with HireCost, AccountNumber, CurrentBalance, AccountLimit; checks HireCost + CurrentBalance would exceed limit; if authorised updates CurrentBalance; returns BOOLEAN
RentCar()PayByCard()PayByAccount() HireCostflag HireCostAccountNumberAccountLimit CurrentBalanceflag (authorised) selection
CurrentBalance is two-way (read, then updated) — by reference · each module returns a BOOLEAN flag (filled circle) up
practice Q5draw the chart

Headers: PROCEDURE Lookup(P4 : INTEGER, BYREF M4 : STRING) · FUNCTION Update(T4 : INTEGER) RETURNS INTEGER · FUNCTION Validate(S2 : INTEGER, P3 : STRING) RETURNS BOOLEAN. A fourth module Renew() calls Validate() → Lookup() → Update() in that sequence.

Renew()Validate()Lookup()Update() P3S2flag P4M4 T4INTEGER
M4 is BYREF ⇒ two-way arrow · functions return a value up (Validate → filled flag; Update → open circle)

Reading a chart → writing module headers

TopLevel / SubA / SubBpseudocode headers

Chart: TopLevel calls SubA (A ↓, B ↓ in; C two-way) and SubB (D ↓, E ↓ in; a filled flag ↑ out). Types: A, D : STRING · C : CHAR · B, E : INTEGER. Identify which is a function and which a procedure.

SubB returns a Boolean flag ⇒ FUNCTIONFUNCTION SubB(D : STRING, E : INTEGER) RETURNS BOOLEANSubA returns nothing; C is two-way ⇒ PROCEDURE, C is BYREFPROCEDURE SubA(A : STRING, B : INTEGER, BYREF C : CHAR)

Board slide writes "RETURN BOOLEAN" — the correctkeyword is RETURNS.

library structure chart2 + 3 marks

Module-A() calls Module-B(), Module-C(), Module-D() with a loop arc around the calls. (i) Explain: Module-A calls the other three modules; the process is repeated (iteration). (ii) New modules: Module-X() no parameters; Module-Y() takes a string and a real, returns a Boolean; Module-D() calls either X or Y.

Module-D()Module-X()Module-Y() stringrealflag
1 mark each: all rectangles labelled & connected · all (and only) parameters shown · selection diamond

4. Flowcharts

Definition: a visual representation of a process or algorithm that uses symbols and arrows to show the steps. Used in software development, engineering and business process management to visualise complex systems.

Symbols

START / END (terminator, oval)OUTPUT / PRINT / INPUT (parallelogram) ASSIGNMENT, CALCULATION (rectangle) e.g. N = 5process CONDITION / LOOP (diamond, with arrows back) Assignments related to FUNCTIONS — calling afunction or procedure (rectangle with double side bars)
diamond has exactly two exits — YES / NO (TRUE / FALSE)
STARTInput N1, N2Sum = N1 + N2Output SumEND
Input two numbers and print the sum
STARTInput N1 N1 > 0 ?N1 < 0 ? Print "Positive"Print "Negative"Print "Zero"END YESNOYESNO
Input a number; print positive, negative or zero (all branches join before END)
flowchart from pseudocodefunction Search()
FUNCTION Search() RETURNS INTEGERV ← GetLevel() L ← V * 1.34 C ← 0FOR N ← 1 TO 10 : V ← GetLevel() ; IF V > L THEN C ← C + 1 ENDIFOUTPUT "Process complete" ; RETURN C
STARTV = GetLevel()L = V * 1.34C = 0N = 1 N > 10 ?V = GetLevel()V > L ?C = C + 1N = N + 1 Output "Process complete"Return CEND YESNOYESNO
FOR loop: set N = 1 → test N > 10 (YES leaves the loop) → body → N = N + 1 → back to the test. GetLevel() uses the double-bar rectangle (function call).

5. State-Transition Diagram

How to read / draw: circles = states · arrows go from the current state to the next state · each arrow is labelled Input | Output · a filled dot with an arrow marks START · an arrow that goes back to its own state is a loop.
PIN validation4 marks
Current state Input Output Next state
S1 Input PIN S2
S2 Re-input PIN Display error S2
S2 Cancel Re-prompt S1
S2 Valid PIN Enable payment S4
S2 Too many tries Block Account S3
S1S2S3S4START Input PINCancel | Re-promptRe-input PIN | Display errorToo many tries | Block AccountValid PIN | Enable payment
marks: line S1→S2 with label · S2 loop label · S3 circle + label on incoming arrow · S4 circle + label on incoming arrow

6. Record Data Type

If you want to store a complete record in a single variable name, use a record.

EmpNo Name Age Department Salary
001 Alex S 26 Store 5000
002 Golith K 32 Marketing 5600

Definition: a data structure that stores multiple values of different data types under a single variable name. (An array = same type; a record = different types.)

Pseudocode — declare the typeTYPE NameOfDatatype
  DECLARE Value1 : DATATYPE
  DECLARE Value2 : DATATYPE
ENDTYPE
BookInformationworked example

Record Bookinformation: title : String · ISBN : Integer · Author : String. Create variable Book1: Title "Papersdock", ISBN 1027554, Author "Taha".

TYPE Bookinformation
  DECLARE Title : STRING
  DECLARE ISBN : INTEGER
  DECLARE Author : STRING
ENDTYPE
DECLARE Book1 : Bookinformation
Book1.Title ← "Papersdock"
Book1.ISBN ← 1027554
Book1.Author ← "Taha"
Booking record2 marks

Booking ID, customer ID, item ID and quantity (all integers) stored in a random file → declare data type Booking. 1 mark: TYPE…ENDTYPE; 1 mark: all 4 fields INTEGER.

TYPE Booking
  DECLARE BookingID : INTEGER
  DECLARE CustomerID : INTEGER
  DECLARE ItemID : INTEGER
  DECLARE Quantity : INTEGER
ENDTYPE
LibraryRecord2 marks

TYPE LibraryRecord: Title : STRING · Fiction : BOOLEAN · Author : STRING · NumberOfCopies : INTEGER. Variable LibraryBook. Assign "A Level Computer Science" to Title and FALSE to Fiction.

LibraryBook.Title ← "A Level Computer Science"
LibraryBook.Fiction ← FALSE

Access a field with variable.field (dot), assign with ←.

7. Structured English

Definition: the use of language with the syntax of structured programming to communicate the design of a computer program to non-technical users, by breaking it down into logical steps using English words.

Don't confuse: pseudocode ≠ Structured English. Structured English uses plain English words — no code symbols (no ←, no arrays written as Array[X]).
Pseudocodecount ← 0FOR X ← 1 TO 100  IF Array[X] = "Empty"    THEN count ← count + 1  ENDIFENDFOROUTPUT (count)
Structured EnglishInitialise count to zeroLoop 100 times  compare an element with "Empty" (in the loop)  increment the count if equal (in the loop)Output a message together with the count — not inside the loop
✓ Quick Recap — Part B
  • Abstraction = keep essential, ignore irrelevant → simpler, tailored
  • Structure chart: ○ value · ● Boolean flag · ◇ selection · curved arrow loop · ↔ by reference
  • Flowchart: oval start/end · parallelogram I/O · rectangle process · diamond decision · double-bar = call module
  • State diagram: circles = states, arrow label = Input | Output
  • Record: TYPE … ENDTYPE; fields of different types; access with dot