p2 stuff cs
p2 stuff cs
Notes
Compiled by Carol M. S. Dandira
- Most of the notes are taken from Mark Schemes
- Where the notes are not taken from the mark schemes, I
explicitly specify the source
- The notes are in the order the syllabus points appear in the
syllabus… I didn’t skip any syllabus point between topic 9 to 12
- Please also use this in conjunction with the pseudocode guide
- Where context is needed, I include the question along with the
mark scheme answer
9.1 Computational Thinking Skills
Show an understanding of abstraction:
• Need for and benefits of using abstraction
They make the program more easier to understand / debug / maintain
•
• Describe the purpose of abstraction
A system is being developed to help manage a car hire business. A customer may hire a car for a number of
days.
An abstract model needs to be produced.
(a) Explain the process of abstraction and state four items of data that should be stored each time a car is
hired.
Abstraction is used to filter out information / data that is not necessary for the task
To keep only information / data that is necessary for the task
1. Car details: ID, Car Registration, car type etc Customer details: ID, name, address, licence details
etc
2. Start date (of hire)
3. Return date / Number of days (of hire)
4. Cost of hire
changes needed to convert one of the existing modules into this single
module: Parameters need to be passed to the module
Search algorithm is controlled by (global) variables / parameters
an algorithm is a solution to
a problem expressed as a sequence of defined steps
Refer to the insert for the list of pseudocode functions and operators.
1 (a) A program is being developed to help manage the membership of a football club.
Complete the following identifier table.
• a flowchart
-follow the arrows. Where there is a rectangle with two vertical lines on each width, that’s a subroutine and it is basically
either a function or a procedure.
A program will:
input 50 unique integer values output the largest value
output the average of the values excluding the largest value.
Draw a program flowchart to represent the algorithm.
Variable declarations are not required.
It is not necessary to check that each input value is unique.
TYPE Student
DECLARE StudentID : STRING
DECLARE Email : STRING
DECLARE Club_1 : INTEGER
DECLARE Club_2 : INTEGER
DECLARE Club 3: INTEGER
ENDTYPE
10.2 Arrays
Use the technical terms associated with arrays:
• Including index, upper and lower bound
Select a suitable data structure (1D or 2D array) to
use for a given task
appropriate way of indicating an unused array element.
Assign a value (of the correct data type) outside the normal range
Explain why it would be good practice to use arrays to store the data.
.. Algorithm to process / search / organise the data is easier to implement
// Values may be accessed via a loop-controlled variable / iterated
through using index
Makes the program easier to design / code / test / understand
Multiple instances referenced via a single identifier / so fewer identifiers needed // Easier to amend the program
when the number of students increases
Write pseudocode for:
1D arrays
DECLARE Membership : ARRAY [1:3000] OF Student // array of 3000 students
2D arrays
This algorithm is efficient because (A flag is used to) exit the loops // iteration is terminated as soon as a Screen
element with value 1 is found
Adding to a queue:
edit
delete data from these structures
A module AddIo () will add a value to the queue by manipulating the array and variables in part (a).
The queue implementation is circular. When pointers reach the end of the queue, they will wrap around' to the
beginning
Before a value can be added to the queue, it is necessary to check the queue is not full.
The algorithm to add a value to the queue is expressed in six steps.
Complete the steps.
Stack
Linked List:
An array (1D) to store the data and a second array (1D) to store the pointers
An (integer) variable to hold the start pointer and an (integer) variable to store the next free pointer
11.1 Programming Basics
Implement and write pseudocode from a given
design presented as either a program flowchart or
structured English
Write pseudocode statements for:
o the declaration and initialisation of constants
CONSTANT Pi =3.142
o the declaration of variables
DECLARE <Variable Name>: <Data type>
o the assignment of values to variables
<variable name> <- <value>
o expressions involving any of the arithmetic or
logical operators input from the keyboard and
output to the console
11.2 Constructs
Use pseudocode to write:
o an ‘IF’ statement including the ‘ELSE’ clause
and nested IF statements
o a ‘CASE’ structure
- refer to pseudocode guide please
o a ‘count-controlled’ loop:
o a ‘post-condition’ loop (REPEAT… UNTIL <condition>)
o a ‘pre-condition’ loop
The loop structure used in the pseudocode is not the most appropriate.
State a more appropriate loop structure and justify your choice.
Structure: A count-controlled loop
Justification: The number of iterations is known // repeats for the length of
InString
Use parameters:
• A procedure may have none, one or more
parameters
• A parameter can be passed by reference or by value
By reference / ref
The address of / pointer to the parameter is passed to the subroutine // if the parameter value is
changed in the subroutine this changes the original value
• Iterative
Taken from David Watson, and Hellen Williams textbook)
(i) Identify a life cycle method that would be appropriate in this case.
Give a reason for your choice.
Coding:
The program or set of programs is written using a suitable programming
language.
testing
The program is run many times with different sets of test data, to test that
it does everything it is supposed to do in the way set out in the program
design.
maintenance
The program is maintained throughout its life, to ensure it continues
to work effectively. This involves dealing with any problems that arise
during use, including correcting any errors that come to light, improving
the functionality of the program, or adapting the program to meet new
requirements. (From textbook)
• dry run
The process of checking the execution of an algorithm or program by recording variable values in a trace table.
• walkthrough
• white box
- White-box
In this method the internal structure design or implementation of the item being tested is known to the tester.
Tester validates the internal structure of the item under consideration along with the output. In short, white-box
testing is testing every path through the program code. In IDE setting breakpoints, stepping and subroutine
parameter checking are the features that provides to carry out white box testing. (Taken from
https://gceguide.cc/computer-science-9608-paper-2-theory-notes/)
• black box
In this method the internal structure design or implementation of the item being tested is not known to
the tester. Tester is mainly concerned with validation of output rather than how the output is produced.
In short, black-box testing is comparing expected value with actual results when program runs.
(Taken from https://gceguide.cc/computer-science-9608-paper-2-theory-notes/)
How data is chosen in black-box testing:
to test that the program does what it is supposed to do / to check that
the results are as expected
to use known valid, boundary and erroneous values
• integration
Modules that have already been tested individually
are combined into a single (sub) program which is then tested as a whole
• alpha
• This is the testing done on software 'in-house', meaning it is done by the developers
another term for 'first round of testing' (I took this definition from Znotes)
• beta
Testing carried out by a small group of (potential) users
Users will check that the website/software works as required / works in the real world //User will identify
errors in the website/software Users will feedback (problems) / suggestions for improvement
Problems / suggestions identified are addressed (before the program is sold)
• acceptance
• stub
• Abnormal
that should be rejected by a program as it is unsuitable
or could cause problems. (Taken from David Watson, and Hellen Williams textbook)
• Extreme
• that is on the limit of that accepted by a program; for
example, when testing a validation rule such as number >= 12 AND
number <= 32 the extreme test data would be 12 at the lower limit and
32 at the upper limit; both these values should be accepted. (Taken from David Watson, and Hellen Williams
textbook)
• Boundary
that is on the limit of that accepted by a program or
data that is just outside the limit of that rejected by a program;
for example, when testing a validation rule such as number >= 12 AND
number <= 32 the boundary test data would be 12 and 11 at the lower
limit and 32 and 33 at the upper limit; 12 and 32 should be accepted,
11 and 33 should be rejected. (Taken from David Watson, and Hellen Williams textbook)
• Adaptive
State the term used for changes that are made to a program in response to a specification change.
- Adaptive maintenance
The hardware that runs the program is changed and the program needs to be modified so that it works
with the new hardware.
Identify the type of maintenance that this represents and give one other reason why this type of maintenance
may be needed:
Adaptive
Reason: The (user) requirements) changes // to accommodate legislative changes
• Corrective
changes to correct a bug / problem / error in the program
I.D.E:
breakpoints
Stop the code running at a set point to check the flow/variable contents
i.e. variables, expressions, report
window
Library routines are beneficial because they are robust thus already tested and save programming
time. They can perform complex calculations which the programmer may not be able to perform.