My Revision Notes Aqa Alevel Computer Science 3rd Edition 3rd Edition Mark Clarkson Instant Download
My Revision Notes Aqa Alevel Computer Science 3rd Edition 3rd Edition Mark Clarkson Instant Download
https://ebookbell.com/product/my-revision-notes-aqa-alevel-
computer-science-3rd-edition-3rd-edition-mark-clarkson-36446100
https://ebookbell.com/product/my-revision-notes-aqa-alevel-computer-
science-mark-clarkson-36461814
https://ebookbell.com/product/my-revision-notes-aqa-a-level-law-2nd-
edition-beauman-craig-54844910
https://ebookbell.com/product/my-revision-notes-aqa-alevel-politics-
us-and-comparative-politics-rowena-hammal-simon-lemieux-34170390
https://ebookbell.com/product/my-revision-notes-aqa-a-level-maths-
applied-stella-dudzic-36668422
My Revision Notes Aqa Alevel Accounting David Lewis
https://ebookbell.com/product/my-revision-notes-aqa-alevel-accounting-
david-lewis-44582460
https://ebookbell.com/product/my-revision-notes-aqa-asalevel-history-
revolution-and-dictatorship-russia-19171953-robin-bunce-neil-
owen-49930240
https://ebookbell.com/product/my-revision-notes-aqa-asalevel-history-
the-making-of-a-superpower-usa-18651975-peter-clements-44587064
https://ebookbell.com/product/my-revision-notes-aqa-gcse-91-business-
malcolm-surridge-54844930
https://ebookbell.com/product/my-revision-notes-aqa-as-chemistry-uk-
ed-rob-king-11275366
Looking to boost your learning?
Ensure you’re on track to excel in your studies with trusted
A-level study and revision resources from Hodder Education.
Student Magazines
Workbooks Ideal for developing independent
learning skills, our Student
Maximise your potential with
Magazines provide in-depth
these write-in workbooks written
information surrounding subject
by experienced authors to help
content, with topical articles
you to practise and apply what
and expert exam advice to help
you have learned during your
deepen your understanding and
course. Build confidence and
put knowledge into context.
independent learning skills
through a blend of focused course
guidance and varied practical
activities.
Answers to workbook
questions available online
at hodderplus.co.uk Also available as eMagazines
www.hoddereducation.co.uk/studentworkbooks www.hoddereducation.co.uk/magazines
AQA
A-level
COMPUTER
SCIENCE
THIRD EDITION
Mark Clarkson
325487_01_MRN_AQA_CS_001-033.indd Page 2 6/29/21 9:39 PM f-0116 /103/HO02206/work/indd
Every effort has been made to trace all copyright holders, but if any have been inadvertently
overlooked, the Publishers will be pleased to make the necessary arrangements at the first
opportunity.
Although every effort has been made to ensure that website addresses are correct at time of
going to press, Hodder Education cannot be held responsible for the content of any website
mentioned in this book. It is sometimes possible to find a relocated web page by typing in
the address of the home page for a website in the URL window of your browser.
Hachette UK’s policy is to use papers that are natural, renewable and recyclable products
and made from wood grown in well-managed forests and other controlled sources. The
logging and manufacturing processes are expected to conform to the environmental
regulations of the country of origin.
Orders: please contact Hachette UK Distribution, Hely Hutchinson Centre, Milton Road,
Didcot, Oxfordshire, OX11 7HH. Telephone: +44 (0)1235 827827.
Email [email protected]. Lines are open from 9 a.m. to 5 p.m., Monday to Friday.
You can also order through our website: www.hoddereducation.co.uk
ISBN: 978 1 3983 2548 7
© Mark Clarkson 2021
First edition published in 2016. This edition published in 2021 by
Hodder Education,
An Hachette UK Company
Carmelite House
50 Victoria Embankment
London EC4Y 0DZ
www.hoddereducation.co.uk
Impression number 10 9 8 7 6 5 4 3 2 1
Year 2025 2024 2023 2022 2021
All rights reserved. Apart from any use permitted under UK copyright law, no part of this
publication may be reproduced or transmitted in any form or by any means, electronic
or mechanical, including photocopying and recording, or held within any information
storage and retrieval system, without permission in writing from the publisher or under
licence from the Copyright Licensing Agency Limited. Further details of such licences (for
reprographic reproduction) may be obtained from the Copyright Licensing Agency Limited,
www.cla.co.uk
Cover photo © Maksym Yemelyanov - stock.adobe.com
Illustrations by Aptara, Inc.
Typeset in India by Aptara, Inc.
Printed in Spain
A catalogue record for this title is available from the British Library.
325487_01_MRN_AQA_CS_001-033.indd Page 3 6/29/21 9:40 PM f-0116 /103/HO02206/work/indd
topic by topic. Use this book as the cornerstone My Revision Planner 7 Computer organisation and architecture
158 Internal hardware components
162 The stored program concept
My Revision Planner
My Revision Planner
162 Structure and role of the processor and its components
Introduction 173 External hardware devices
6 Command words
8 Consequences of using computers
1 Fundamentals of programming 182 Moral, ethical, legal and cultural issues and opportunities
9 Programming
9 Fundamentals of communication and networking
have:
143 Types of program translator
145 Logic gates
152 Boolean algebra
4 5
✚ revised and understood a topic Check your understanding and progress at www.hoddereducation.co.uk/myrevisionnotesdownloads
/103/HO02206/work/indd
Data structures and abstract Multi-dimensional arrays games and physical models,
and are discussed in more
data types
A two-dimensional array can be written down as a table. detail towards the end of
A two-dimensional array can be thought of as an array of one-dimensional this chapter.
arrays.
quizzes
require a separate selection statement to interrogate each one, and additional Array A data structure for
code would be needed each time the number of variables increased. Numbers [1]
holding values in a table. Numbers
Using a data structure called an array means that it is possible to step through [0] [1] [2] [3]
[0] [1] [2] [3]
each item using a loop, reducing the amount of code and making the code [1] 11 13 17 19
[0] 1 3 5 7
much more flexible . Exam tip
[1] 11 13 17 19 Numbers [2]
Arrays can also be defined
Single- and multi-dimensional arrays [2] 23 29 31 37 [0] [1] [2] [3]
using the first index to find
[3] 41 43 47 51 [2] 23 29 31 37
(or equivalent) Numbers [2][2]
the column and the second
Numbers [3]
index to find the item in that
An array is a fixed-size collection of values, all of the same data type. column. Always read the
Index A value indicating the [0] [1] [2] [3] question carefully as any
Single-dimensional arrays position of a value with in [3] 41 43 47 51 ambiguities should be made
A single-dimensional array can be written down as a single row of a table. an array or list. Numbers [3][1] clear.
Each individual item in the array is referred to using the identifier (or List A data structure similar Figure 2.1 A two-dimensional array called Numbers
variable name) of the array, followed by the index in brackets (usually square to an array, commonly used Making links
In the example above the contents of Numbers[0][3] can be found by isolating
in Python in place of an
brackets). Each index position can hold data. row 0 and then finding the item in position 3. One common use for a
array.
two-dimensional array is
Index [0] [1] [2] [3] [4] A two-dimensional array is useful because it can store more complex data; for
storing a matrix. Matrices
example, the scores for different students or values for different days.
Data 1 3 5 7 11 Exam tip are often used in complex
It is possible to find the size of a two-dimensional array using the Length maths, and can also be used
In most languages (including
function (exact syntax varies by programming language). to represent a graph data
Note C#, Delphi/Pascal, Java &
structure. This is explored
VB.Net) the array index For an array with indexes defined as [row][column], to find the number of
Arrays are always declared as a fixed size and cannot be changed later in the program. further later in this chapter.
starts at 0, but be very rows, find the number of one-dimensional arrays the table can be split into:
In an array, all data must be of the same data type. careful when reading
NumberOfRows ← Length(ArrayName)
Lists are very similar to arrays, however it is possible to alter the size of a list while the exam questions as some
Matrix A rectangular, two-
program is running and it is possible to store data of differing types in the same list. languages and some To find the number of columns, find the length of a row in the table: dimensional collection of
scenarios will have the array
In some languages (notably including Python) it is much more common to use a list, NumberOfColumns ← Length(ArrayName[0]) values.
index starting at 1.
whereas in others it is much more common to use an array. Nested A selection
To interrogate a two-dimensional array it is necessary to use nested loops.
You are not expected or required to show your understanding of the difference statement or loop inside
FOR i ← 0 to Length(Numbers) // Step through each row another selection statement
between the two, and you should use whichever version is most suitable for your
chosen programming language. FOR j ← 0 to Length(Numbers[i]) // Step through each or loop.
value in that row
Arrays are an effective solution for storing several values because a FOR loop OUTPUT Numbers[i][j] Exam tip
can be used to iterate (or loop) over an array.
ENDFOR Make sure you are able to
In this example Numbers is the name of an array and Length(Numbers) hand trace a program such
ENDFOR as the one above to fully
returns the size of the array (the number of items is contains).
Using the principle above, it is possible to think of a three-dimensional array understand which counter
FOR i ← 0 TO Length(Numbers) variable is addressing the
as an array of two-dimensional arrays.
OUTPUT Numbers[i] row or column index of the
34 table. 35
ENDFOR
Check your understanding and progress at www.hoddereducation.co.uk/myrevisionnotesdownloads My Revision Notes AQA A-level Computer Science Third Edition
My Revision Planner
My Revision Planner
Introduction
6 Command words
1 Fundamentals of programming
9 Programming
22 Programming paradigms
23 Object-oriented programming
My Revision Planner
162 Structure and role of the processor and its components
173 External hardware devices
8 Consequences of using computers
182 Moral, ethical, legal and cultural issues and opportunities
9 Fundamentals of communication and networking
188 Communication
190 Networking
195 The internet
201 The Transmission Control Protocol/Internet Protocol
10 Fundamentals of databases
214 Conceptual models and entity relationship modelling
216 Relational databases
217 Database design and normalisation techniques
222 Client-server databases
11 Big Data
224 Big data
12 Functional programming
227 Functional programming paradigm
230 Writing functional programs
13 Systematic approach to problem solving
235 Aspects of software development
241 Glossary
Introduction
Introduction
Assessment objectives
✚ AO1 You should be able to demonstrate knowledge and understanding of
the principles and concepts of computer science, including abstraction, logic,
algorithms and data representation.
✚ AO2 You must be able to apply your knowledge and understanding of the
principles and concepts of computer science, including to analyse problems in
computation terms.
✚ AO3 You must be able to design, program and evaluate computer systems
that solve problems, making reasoned judgements about these and presenting
conclusions.
Command words
Familiarity with the relevant command words is important. It helps you to
avoid wasting time in the exam room (for example, trying to evaluate when
there is no requirement for it). The most frequently used command words
used for the A-level papers are listed here.
✚ Calculate… requires you to work out the value of something. A correct
final answer, to the required degree of accuracy and with the correct units,
will score full marks. Working is usually required, and correct working can
score marks. (AO2)
✚ Compare… requires you to identify similarities and differences between
ideas, technologies, or approaches. (AO1)
✚ Create… requires you to write program code that solves a problem. Even if
you struggle to get the syntax correct, marks are awarded for evidence of
the approach taken as well as for working code. (AO3)
✚ Define… requires you to specify the meaning of a technical term in order
to show that you understand what it means. (AO1)
✚ Describe… requires you to set out the characteristics of a device or a
computing concept. These can be very short questions worth 1 mark, or
long-answer questions worth up to 12 marks. (AO1)
✚ Discuss… requires you to present the key points. These questions are
typically of medium length, worth 4-6 marks. You should aim to present as
many points as you can and, where appropriate, provide balance between
advantages and disadvantages. (AO1)
✚ Draw… requires you to produce a diagram. These are usually technical
diagrams such an E-R diagram for a database, or a logic circuit diagram. (AO2)
✚ Explain… requires you to provide purposes or reasons. These questions
are used to assess your knowledge of a topic and can sometimes be used
within a specific context. If a question is asked in relation to a particular
scenario then you should always make sure you link to the scenario in
your answer. (AO1, AO2)
✚ Express… requires you to convert an input into a particular format.
Examples might include encrypting a message or calculating a value. (AO2)
✚ Modify… requires you to take an existing section of program code and add
to or edit it. This is commonly asked as part of Section D in Component 1,
involving changes to the skeleton program. (AO3)
✚ State… requires you to express some knowledge in clear terms. These questions
6
are usually short answer questions and are usually worth 1 mark. (AO1)
Introduction
process should be included. (AO3)
✚ Write… requires you to create a program or a Boolean expression to solve
a specific problem. These questions can be quite lengthy and partially
complete answers are usually worth a significant proportion of the marks.
(AO2, AO3)
Component 1
Component 1 is an on-screen exam, largely focused on programming
and computation. In advance of the exam, you and your teachers will
be provided with a skeleton program and a small pack of background
information.
The exam will be taken using a programming language you have studied
throughout the course, and will be pre-selected by your teacher. The available
languages are:
✚ C# ✚ Python
✚ Java ✚ VB.net
✚ Pascal/Delphi
The skeleton program is a working program that is functional but could
be improved. Typical examples include text-based role-playing games or
simulations.
For A-level students the pre-release information is available from September
of that academic year (typically Year 13).
The pre-release information should be given to you by your teacher, but they
may choose not to give the information out straight away, depending on how
and when they plan to deliver the content.
The A-level exam is split into four sections:
1 Section A: Questions about programming and computation; for example,
finite state machines, standard algorithms, trace tables, Turing machines and
computation logic.
2 Section B: A programming problem (unrelated to the skeleton program);
for example, writing a program to convert between binary and denary
numbers.
3 Section C: Questions about the skeleton program; for example, identifying
specific variables or programming constructs, hierarchy charts, class
diagrams and explaining the purpose of specific elements.
4 Section D: Improving the skeleton code; for example, adding an extra menu
option, improving exception handling, adding new functionality.
Programming syntax
Some questions in Component 1 will include algorithms written using AQA
pseudo-code. It is important to be able to read and understand this pseudo-
code and, in some cases, to write program code in your chosen programming
Introduction
Component 2
Component 2 is a traditional-style written paper, largely focused on the more
theoretical components of this course.
The topics covered in this paper test subject content from Chapters 5–12, and
typically include:
✚ data representation ✚ networking
✚ computer systems ✚ databases and Big Data
✚ computer hardware ✚ functional programming.
✚ consequences of computing
As this is a written paper, no practical programming activities are assessed,
though some practical elements such as calculations, data conversions and
trace tables (especially for assembly language and instruction sets) are likely
to appear.
This paper will generally include short answer questions (1–2 marks) that will
assess your knowledge, questions that will assess your ability to apply your
knowledge (3–4 marks), and a small number of longer-answer questions that
require detailed discussion (6–12 marks).
For these longer-answer discussion questions, credit is awarded for
identifying, discussing and evaluating potential issues.
✚ Marks are awarded for identifying relevant knowledge; for example,
suggesting appropriate input devices for collecting data or identifying the
methods by which wireless data transmissions can be intercepted.
✚ To reach the top mark bands it is important to follow a line of reasoning, using
your knowledge to write in connected sentences in a way that makes sense
and relates to the context of the question. Explaining how each point links to
the scenario and adding as much technical detail and vocabulary as you can
makes it more likely that you will score well on this type of question.
✚ Always make sure you back up any arguments or suggestions you make
with facts, logical arguments and technical details, as unsubstantiated
statements don’t demonstrate your understanding.
Component 3
Component 3 is a non-examination assessment (NEA) component, based on
completing a programming project.
The programming project is extremely open-ended, and it is up to you to
identify a real-world problem and then work through each phase of the
systems development lifecycle in order to solve it.
It is beyond the scope of this book to go into detail in terms of completing
the programming project, but typical examples include online booking and
scheduling systems, computer games with a simple AI component, animal
population simulations, and so on. There is no definitive list of expected or
excluded projects and your teacher will be able to provide with much more
specific guidance.
1 Fundamentals of programming
Programming
Data types
It is important to declare variables using the correct data type. This will make
sure that memory is not wasted, and that the program is able to process the
data correctly.
Different data types are processed in different ways; for example, adding two
strings produces a different result to adding two integers.
"123" + "456" = "123456"
Note
All programming languages deal with data types slightly differently.
It is important to note that Python does not support the character data type, using
only a string to store text of any length. Python also does not support the array data
type. The closest alternative is a list data type.
Programming concepts
For each of the programming concepts you should be familiar with both the
Pseudo-code A format
pseudo-code used by AQA and the syntax used in your own programming
for program code that
language.
is not specific to one
programming language.
Declaration Used extensively in
Variable declaration is the process of creating a variable. Component 1. Pseudo-code
is useful for describing an
In languages which are strongly typed (for example, C#, Pascal/Delphi, Java algorithm that could be
and VB.net) the data type of the variable is stated, followed by the variable’s coded in one of several
identifier. In these languages it is possible to declare a variable without different languages.
initially assigning a value to it.
Syntax The strict rules
✚ int Age; (C# and Java)
and structures used within
✚ var Age: integer; (Delphi and Pascal)
a specific programming
✚ Dim Age As Integer (VB.net)
language. You will only be
In languages which are weakly typed (for example, Python) a value must be assessed in the syntax of
assigned to a new variable, and no data type is declared as the data type can one programming language
be changed during the course of the program. for Component 1.
✚ Age = 18 (Python) Declaration The creation
Constants are declared in a similar way, but with a key word that indicates of a variable in memory.
the variable cannot be changed. Because the value of a constant cannot be
changed later, they must be declared with an initial value:
Exam tip
✚ const int MAX = 3; (C#)
✚ Const MAX = 3; (Pascal/Delphi) In Component 1 you will
✚ final int MIN = 3; (Java) be presented with pseudo-
✚ Const MAX As Integer = 3 (VB.net) code algorithms to read,
and to turn into program
Python does not support the use of constants and therefore it is not possible code, but you will not be
to prevent the accidental assignment of a new value to a constant. expected to write answers
using pseudo-code.
Making links
Practical programming
It is important to consider where a variable is declared. A variable declared inside an questions are intended to
IF statement, loop or subroutine can only be used within that section of the code be coded using the specific
and will be destroyed once that section has ended. This issue is dealt with more in the programming language you
section on local and global variables. have been entered for.
10
1 Fundamentals of programming
✚ Assignment in most programming languages uses an equals sign (for
example, Score = 12)
Sequencing
Program code is executed in the order in which it appears. For example, given
the code:
x ← 5
OUTPUT x
x ← x + 1
The value 5 will be output before the value of x is increased.
Nested selection
Nested IF statements occur when an IF statement is placed inside an IF
Nested Placing a
statement.
programming structure
IF animal = "dog" THEN inside another programming
1 Fundamentals of programming
structure.
IF target = "sheep" THEN
OUTPUT "Dog chases sheep"
Revision activity
ELSE
✚ Write a program in your
OUTPUT "Dog wags tail"
chosen programming
END IF language that uses an
IF statement to allow
END IF the user to choose one
of four options.
Now test yourself
✚ Re-write the program
9 What programming concept is implemented using an IF statement? to use a SWITCH
10 Which part of an IF statement does not need a condition? statement.
11 What alternative to an IF statement is sometimes used if there are several
possible options? Exam tips
12 What is meant by a nested IF statement?
Be very careful with the
Answers available online start and end conditions
when creating FOR loops.
While a pseudo-code
Iteration algorithm may explicitly
When a block of code needs to be repeated, this is referred to as iteration. start and end at given
values, the implementation
Definite iteration for a FOR loop may be
Definite iteration, or count-controlled iteration, refers to the use a FOR loop, less clear (for example,
where the number of times to repeat is known. Even if the number of times to in Python for i in
repeat isn’t always the same, if it is known at the start of the loop then a FOR range(1,5) would stop
loop should be used. at i = 4 and in Java for
(int i = 1; i < 5;
You should be familiar with the syntax of a FOR loop in your own i++) would also stop at
programming language as well as the pseudo-code you might see in an exam: i = 4).
FOR i ← 1 TO 5 Although the specification
refers to definite and
OUTPUT "This is step " + i
indefinite iteration, question
ENDFOR papers typically use the
terms count-controlled and
Indefinite iteration condition-controlled iteration.
Indefinite iteration or condition-controlled iteration refers to a loop where
the number of iterations is not known. A typical example might be a
Iteration The repetition of
validation loop, asking a user to enter a valid input and repeating while a process or block of code.
their answer is invalid.
Definite iteration,
Indefinite loops can be further split into those that assess the condition at the or count-controlled
start of the loop (a WHILE loop) and those that assess the condition at the end iteration Iterating a fixed
of the loop (a DO-WHILE loop). number of times (also
In AQA pseudo-code: known as a count-controlled
loop, implemented as a
A WHILE loop will have the condition at the top of the loop, allowing the program to FOR loop).
bypass the code inside completely. For example: Indefinite iteration, or
value ← 5 condition-controlled
iteration Iterating until a
WHILE value < 100 DO
condition is met (also known
value ← value * 2 as a condition-controlled
ENDWHILE loop, implemented in AQA
pseudo-code as a WHILE
12 loop or DO-WHILE loop).
A DO-WHILE loop will have the condition at the bottom of the loop, forcing the program Note
to pass through the code at least once. For example:
Python does not support
DO
the use of a DO-WHILE
1 Fundamentals of programming
OUTPUT "Enter shoe size:" loop, but students are still
expected to be familiar with
ShoeSize ← INPUT
the concept. One solution
WHILE ShoeSize > 12 to this problem is to copy
and paste the first iteration
of the code before a WHILE
Nested iteration loop. Another is to create
Nested iteration means having a loop within a loop. This is used in a number
a REPEAT … UNTIL
of applications, including when working with 2D arrays, and in a number of structure.
standard algorithms including the bubble sort.
FOR i ← 1 TO 3
FOR j ← 1 TO 5 Remember
OUTPUT "Outer loop = " + i + " | Inner loop = " + j Remember that if you know
how many times to loop you
ENDFOR
should use a FOR loop. If
ENDFOR you don’t know how many
times then use a WHILE or
Now test yourself DO-WHILE loop.
13 What type of loop is also called a count-controlled loop? Remember that the inner
loop is completed multiple
14 When should you use a condition-controlled loop?
times for each step around
15 Describe the difference between a WHILE loop and a DO-WHILE loop. the outer loop. Selection
16 Suggest two possible uses for nested iteration. and iteration statements
can be nested inside each
Answers available online other, potentially many
layers deep.
Revision activity
✚ Write a program that uses iteration to print out the 12 times table.
Debug The process of
✚ Write a program that uses nested iteration to print out all of the times tables from 1
identifying and removing
to 12.
errors from program code.
Self-documenting
Meaningful identifier names code Program code that
It is important to choose identifiers for variables (and subroutines) that tell other uses naming conventions
programmers something about the purpose of that variable (or subroutine). and programming
✚ Var1, Var2 and Var3 are very poor choices as they make it very hard to conventions that help other
read the code and to debug if there are any errors. programmers to understand
✚ UserName, UserAge and DateUserLastLoggedIn are much more the code without needing
meaningful and are key to writing self-documenting code. to read additional
documentation.
It is not usually possible to use spaces in identifier names. Common strategies
to aid readability include the use of CamelCase, Kebab-Case or Snake_Case.
Now test yourself
Exam tip
17 Describe two
In Component 1, Section B and Section D, it is very important to use any identifier
advantages of using
names exactly as they are provided in the question. If the identifier name is not given
meaningful identifier
explicitly then remember that making it easier for the examiner to understand the
names.
code makes it more likely you will pick up the marks.
18 Explain the term self-
documenting code.
Note
Answers available
The use of meaningful identifier names to produce self-documenting code can have a online
significant impact on the marks available in the NEA.
13
Subroutines
Information on subroutines can be found in the section Purpose of subroutines.
Arithmetic operations
1 Fundamentals of programming
There are several key operators you should make sure you are familiar with.
Simple arithmetic operators include those for addition (+), subtraction (-), Exam tip
multiplication (*) and division (/).
DIV and MOD are common
It is important to understand the different types of division operation that can
terms for integer division
be carried out: and modulo. Make sure you
✚ Real or float division will result in a real or float answer; for example, are comfortable with how
5 / 2 = 2.5 they function.
✚ Integer division will strip any fractional part of the answer, effectively
rounding down; for example, 5 DIV 2 = 2
✚ The modulo operator will find the modulus – the remainder of an integer Operators Symbols used
division, as a whole number; for example, 5 MOD 2 = 1 to indicate a function.
DIV and MOD are useful for converting between different number systems, Modulus The remainder of
the division of one number
including conversion between units of time, imperial measurements, and
by another.
between numbers using different bases (for example, denary and hexadecimal).
Exponentiation The
Exponentiation refers to powers; for example, 2^3 = 2*2*2 = 8
raising of one number to the
Rounding can be carried to a given number of decimal places or significant power of another.
figures, generally using a function; for example, round(3.14,1) = 3.1,
Rounding Reducing the
round(3.16,1) = 3.2 number of digits used to
Additional functions can be used that always round up or always round down; represent a value while
for example, roundup(3.142,1) = 3.2 maintaining its approximate
value.
Rounding down has the same effect as truncation.
Truncation Removing any
Exam tip value after a certain number
of decimal places.
Some questions in Component 1 will assess your understanding of programming
principles in general and may involve having to read and show understanding of
pseudo-code. Other questions will require you to write your own program code in your
chosen programming language, so it is important to make sure you are familiar with
the specific operators and functions that are used in that programming language.
19 What is the difference between float division and integer division? Write a program that uses
DIV and MOD to convert a
20 What is the value of 7.86 when rounded to one decimal place?
given number of hours into
21 What is the value of 7.86 when truncated to one decimal place? a number of days.
Answers available online
Relational operations
Relational operators are used in comparisons, typically in selection
statements and condition-controlled loops. A relational operation, or
comparison operation, will always return either True or False.
The relational operators are as follows:
= or == Equal to
!= or <> or ≠ Not equal to
> Greater than
>= Greater than or equal to
< Less than
14 <= Less than or equal to
Note
Different programming languages have different syntax rules for the equal to
comparison operator.
1 Fundamentals of programming
AQA pseudo-code and VB.net use a single equals (=).
C#, Pascal/Delphi, Java and Python use a double equals (==).
State whether each of these is True or False when x ← 60. C# and Java are not able to
22 x != 60 make use of the standard
relational operators when
23 x < 60
comparing strings. String
24 x >= 60 handling operations are
25 x = 60 discussed on page 16.
Boolean operations
Boolean operations can be used to invert the logic of a conditional statement,
or to combine two or more conditions together.
NOT Will invert the logic (that is, a condition that returns True will become False).
AND Both conditions must be True.
OR Either one condition must be True, or both.
XOR One condition must be True and the other False.
Making links
The exam for Component 2 assesses understanding of Boolean logic in much more
detail, including questions on Boolean algebra. The same basic principles apply
whether combining logical statements in a practical programming setting or solving
Boolean equations. For a more in-depth examination of Boolean logic see Chapter 6.
Where a = 50 and b = 100, would each overall condition be True or False? Write a program to calculate
the output of simple logic
26 NOT (a = b)
circuits for NOT, AND, OR
27 a < 100 AND b > 100 and XOR.
28 a > b OR b = 2*a
29 a < b XOR b = 100
Variables are used to store values that are used in a computer program. The
Exam tip
value of a variable can be changed while the program is running (such as a
score, a running total, a user’s name). Component 1, Section C will
often start with asking you
A named constant is a variable whose value cannot be changed while the
1 Fundamentals of programming
16
1 Fundamentals of programming
✚ C#, Delphi and VB.net require the start position and the length.
Make sure you read any pseudo-code questions that involve substrings carefully,
and make sure you are comfortable programming with substrings using the language
chosen for your exam.
Some languages treat a string as an array of characters and can use an index array to
refer to a specific character; for example, string[3]. Some languages require the
use of functions such as charAt(int).
Make sure you are familiar with all of the operations above in your own language in
advance of the Component 1 exam.
Revision activity
✚ Write a program that will ask for a string and display each character’s
numeric code.
✚ Write a program that will ask for a series of numeric codes and convert them
into a single string which is displayed.
Exam tip
In most years there is some random number generation included in the skeleton code.
If you forget the correct syntax during the exam then make sure you know where to
find a working example from the skeleton code to help you.
Revision activity
✚ Write a program that will ask for a minimum and maximum number and will
generate a float between those two values.
✚ Write a program like that one above that will generate an integer between those
two values.
17
Exception handling
Exception handling is used to deal with situations where a program may
Exam tip
crash. The program should try to execute a block of code and then catch the
1 Fundamentals of programming
Purpose of subroutines
A fundamental aspect of improving the efficiency of program code is the use
of subroutines. Exam tip
A subroutine allows a programmer to take a section of program code that Make sure you are able
performs a specific task and move it out of line of the rest of the program. to explain the difference
between a function and a
This means that the programmer can call the subroutine in order to run that
procedure, and that you can
block of code at any point.
identify which subroutines
Subroutines are called using the subroutine’s identifier, followed by are which in the skeleton
any arguments that must be passed in parentheses; for example, code. This is a common
DisplayGreeting(name). topic in section C.
Subroutines that do not require any parameters must still be called using
parentheses; for example, DisplayDate(). Subroutine A named block
of code designed to carry
The advantages of subroutines are:
out one specific task.
✚ the subroutine can be called multiple times without needing to duplicate
Call The process of running
the code
a subroutine by stating
✚ changes to the subroutine only need to be made once its identifier, followed by
✚ it is easier to read the code any required arguments in
✚ it is easier to debug the code if there is a problem parentheses.
✚ subroutines can be re-used in other programs Pass The transfer of a
✚ the job of writing a program can be split, with each programmer tackling value, or the value of a
their own subroutines. variable, to a subroutine.
Making links
Using meaningful, self-documenting identifiers for subroutines is important to make
18 your code more readable. It is essential to do this as part of your NEA.
Subroutines are broken down into two types: functions and procedures.
Function A subroutine that
A function is a subroutine that returns a value once it has finished executing. returns a value.
A typical use of a function is to carry out a calculation and return the result. Procedure A subroutine
that does not return a value.
1 Fundamentals of programming
A procedure is a subroutine that does not return a value. A typical use of a
Module A file that contains
procedure is to display some data and/or prompts to the user.
one or more subroutines
Subroutines can be grouped together in a file to form a module or library. that can be imported and
These subroutines can then be re-used in other programs. used in another program.
Library A collection of
It is common to import libraries that have already been written to help solve modules that provide
problems; for example, in Java import java.util.* or, in Python, import related functionality.
random.
Parameters
The parameters of a subroutine are the variables that must be passed to a Parameters The variables
subroutine when it is called. This is declared when the subroutine is written. that a subroutine needs in
For example, in the code Procedure DisplayTemperature(int Temp, order for the subroutine
bool Celsius), the subroutine called DisplayTemperature needs to be passed to run.
an integer value and a Boolean value. Arguments The actual
values that are passed to
When a subroutine is called, the values must be passed as arguments; for the subroutine at runtime.
example, DisplayTemperature(20,True).
Returning a value
Functions must always return a value at the end of their execution. This is Return To pass a value or the
carried out with a return statement. contents of a variable back
For example: to the place in the program
where the function was called.
Function Double(int StartVal)
return 2*StartVal Now test yourself
End function 44 Describe what is meant
The value that is returned is passed back to the part of the program that by the term parameter.
called the function. 45 Explain the purpose of a
return statement.
It is possible for a subroutine to have several different return statements – for
example, within a selection structure – but the subroutine will stop once a Answers available
value has been returned. online
Local variables
When a subroutine is called, any variables passed as parameters and any Local variables Variables
variables declared within that subroutine are referred to as local variables. that are declared within a
These variables can only be accessed within that subroutine and will be subroutine and can only be
destroyed once the subroutine has finished executing. This is referred to as accessed by the subroutine
the scope of the variable. during the execution of that
subroutine.
Scope The visibility of variables
(either local or global).
19
the program
✚ easier to debug
✚ variable identifiers can be re-used in separate subroutines Modular Independent of
✚ subroutines can be more easily re-used (subroutines are modular). other subroutines.
Knowing that local variables are destroyed once that section of code has
finished executing, it is important to note that variables declared within a
selection statement or iteration structure will also be destroyed at the end of
that section of code. It is therefore very important to choose carefully where
in the program a variable will be declared.
Global variables
Global variables are variables that are declared in the main program and can
Global variables Variables
be read or altered in any subroutine.
that can be accessed from
Accessing global variables from within subroutines reduces the need for any subroutine.
passing parameters and using return statements but should generally be
avoided where possible.
Making links
Global variables are, however, useful for named constants.
Try to limit your use of
Now test yourself global variables when
working on your NEA
46 Explain what is meant by the scope of a variable. programming project. Using
47 Explain three advantages of using local variables. a modular structure for your
subroutines will increase
48 Explain three disadvantages of using global variables.
the range of marks you are
49 Describe a situation where it would be appropriate to use a global variable able to access.
Answers available online
Stack frames
When a subroutine is called a stack frame is created. This stack frame
contains: Stack frame The collection
✚ the return address – where to return to in the program once the subroutine of data associated with a
has finished executing subroutine call.
Call stack A data structure
✚ parameters – the variables to which data was passed when the subroutine
that stores the stack frames
was called
for each active subroutine
✚ local variables – any variables declared within that subroutine.
while the program is running.
Newly called subroutines are added to the top of the call stack and the top
stack frame is removed once that subroutine has been completed.
Exam tip
Making links Make sure you can recall
Stacks are a complex data structure with a variety of uses in programming. Stacks and the three things stored
other complex data structures are explored further in Chapter 2. in a stack frame as this
is a common question in
Section A.
Now test yourself
Recursive techniques
Some algorithms are best solved by solving smaller and smaller instances
Recursion The process of
of the same problem. To achieve this, a function must call itself repeatedly –
a function repeatedly calling
1 Fundamentals of programming
this is known as recursion. One example of recursion is used in calculating a itself.
factorial.
A factorial is calculated by multiplying a number by all of the integers less
than itself. The ‘!’ is used as the mathematical symbol for ‘factorial’. For
example:
5! = 5 × 4 × 3 × 2 × 1
This can be simplified as 5 × 4!
4! = 4 × 3!
3! = 3 × 2!
2! = 2 × 1!
1! = 1
A recursive subroutine will continue to call itself (known as the general case) General case A case in
until it reaches a decision that returns a value without calling itself (known as which a recursive function is
the base case or terminating case). called and must call itself.
Base case The case in
The pseudo-code algorithm for a factorial calculator might read: which a recursive function
Function Factorial (int n) terminates and does not call
itself.
IF n <= 1 THEN
RETURN 1
Exam tips
ELSE
Following a recursive
RETURN n * Factorial (n-1) algorithm can be very tricky
and it is important to get
END IF
lots of practice using trace
End Function tables to step through
recursive algorithms.
If n = 1 or less then the function cannot attempt to break the task down
any further, and should stop calling itself recursively, returning the result of Section B questions can
1 (1! = 1). This is the base case. require the use of recursion
to achieve full marks,
In all other cases the function will call itself. This is the general case. though a non-recursive
It is possible to have more than one general case and more than one base case. solution will always be
possible.
Now test yourself
21
Programming paradigms
Programming paradigms
1 Fundamentals of programming
Procedural-oriented programming
Procedural-oriented programming is designed to allow programmers to use a
Making links
structured, top-down approach to solve a given problem.
For more on subroutines
The program designer uses decomposition to break the problem down into
see the section Purpose of
increasingly small sub-problems, each of which can then be solved using a
subroutines above on
subroutine (either a function or a procedure).
page 18.
The main program will then be constructed by calling subroutines which will,
in turn, call other subroutines in order to solve the original problem. Top-down approach
A method of planning
Data can be passed to subroutines and values can be returned from them,
solutions that starts with
allowing the different parts of the program to interact with each other.
the big picture and breaks
This type of computer program is generally simpler to understand and the it down into smaller sub-
subroutines can be re-used at different points in the program without needing problems.
to copy it. This type of program is very modular and can easily be updated by Decomposition A
changing one subroutine. method of solving a larger
problem by breaking it up
into smaller and smaller
Hierarchy charts problems until each
Procedural-oriented programs can be represented using hierarchy charts. problem can’t be broken
Simple hierarchy charts show the relationship between subroutines, such down any further.
as the chart shown in Figure 1.1, with lines used to connect subroutines Hierarchy charts A
wherever one subroutine calls another. diagram that shows which
subroutines call which other
subroutines. More complex
versions will also show what
22 data is passed and returned.
Exam tip
Program
Questions involving
hierarchy charts almost
1 Fundamentals of programming
exclusively appear in
Section C, referring to the
Initialise Input Process Output
skeleton program, and
usually involve a ‘fill the
gaps’ style of question.
Make your own hierarchy
Capture
Enter data Validate charts when studying
form
the skeleton code to help
you understand how the
subroutines fit together and
Figure 1.1 A simple hierarchy chart
see past papers for example
of this style of question.
Now test yourself
Revision activity
✚ Open a complex program you have been working on in your lessons and create a
hierarchy chart to show the relationships between each subroutine.
✚ Consider the steps involved in a two-player game such as Rock-Paper-Scissors
or Noughts & Crosses. Create a hierarchy chart to show how the game could be
broken down into subroutines and how those subroutines would be related.
Object-oriented programming
Classes
Object-oriented programming (often referred to as OOP) uses a different
Class The definition of the
approach to programming. attributes and methods of a
The programmer thinks about real-world objects and creates a class to group of similar objects.
describe the attributes and methods for that type of object. For instance, in Attributes The properties
Figure 1.2, the class called Customer has: that an object of that type
✚ the attributes: Name, Address, and Date of birth has, implemented using
✚ the methods: Edit customer and Delete customer. variables.
Methods Processes or
Customer Account actions that an object
of that type can do,
Name
Account number implemented using
Address Attributes subroutines.
Balance
Date of birth
Edit customer Check balance
Methods
Delete customer Add interest
Figure 1.2 Classes containing attributes and methods
23
Encapsulation
Deciding how to structure and organise classes can be difficult, but the main
Encapsulation The
rule is to group together objects with common characteristics (attributes) and
concept of grouping similar
behaviours (methods). Keeping these features together in one class is called
attributes, data, and
encapsulation.
methods together in one
Encapsulation is useful because it means that program code is more modular. object.
This means that the code is easier to debug, can be re-used more easily and Information hiding
teams of programmers can work on individual classes without needing to Controlling access to data
know how other classes are programmed – they only need to know what stored within an object.
methods can be accessed.
Encapsulation is also helpful as it allows for information hiding, in which the
data stored in the attributes can be kept within that object and access to that
data can be controlled.
24
1 Fundamentals of programming
or method.
Access specifier Symbol Attributes Methods
Public An access specifier
public + can be viewed or updated can be called by any that allows that attribute or
by any object of any class object of any class method to be accessed by
private - cannot be viewed or cannot be called by any any other object.
updated by any other other object, regardless Private An access specifier
object, regardless of class of class that protects that attribute
or method from being
protected # can only be viewed or can only be called by this
accessed by any other
updated by this object object or another object
object.
or another object of that of that class, or a subclass
Protected An access
class, or a subclass
specifier that protects that
The convention is to declare attributes as private so that other objects cannot attribute or method from
directly interact or affect the values that are stored. This make it less likely being accessed by other
objects unless they are
that a class written by another programmer could adversely affect the overall
instances of that class or a
program.
subclass.
To allow access to those data, a class should include getters and setters – Getter A function used
public methods that allow other objects to ask an object to return the value of to return the value of an
a specific attribute, or that ask an object to update a value. attribute to another object.
One example might be a game character that has a score and a number of Setter A procedure used to
lives which are both set to private, and uses public methods to allow other allow another object to set
objects to interact with those values: or update the value of an
attribute.
Character = Class
Private:
Revision activity
Score: Int
✚ Using pseudo-code,
Lives: Int describe the class
Public: attributes and methods
required for a virtual pet.
Function GetScore() ✚ Design and build
Function GetLives() an object-oriented
program that uses a
Procedure AddPoints() Calculator class
Procedure LoseALife() with methods such as
Press0, Press1,
Procedure GainExtraLife() PressPlus and
End Class PressEquals.
This means that the same code can be re-used without needing to be copied,
Revision activity
and if the code needs to be changed then it only needs to be changed in the
base class, reducing the risk of errors and making it easier to debug. ✚ Design a base
class, Room, and
In class diagrams, inheritance is showing using a hollow arrow, which always
1 Fundamentals of programming
subclasses Kitchen,
points towards the base class.
LivingRoom and
Bedroom. Consider
Account
the attributes that could
be inherited and those
Current Mortgage
which must be declared
in the subclasses.
✚ Design classes that
Figure 1.4 An inheritance diagram
could be used to model
Figure 1.4 shows a class structure in which two types of account (Current and various forms of public
Mortgage) are subclasses will inherit the attributes and methods from the transport, including
Account base class. buses, taxis and trains.
Exam tip
Exam tip
In AQA Pseudo-code, subclasses are declared by adding the base class name in
parentheses; for example: The terms subclass
Dog = Class (Animal) and child class are
It is rare for the exam to ask students to describe a class using pseudo-code. However, interchangeable and both
when this is the case, then language-specific syntax is accepted; for example: mean the same thing.
Dog = Class extends Animal The terms base class
and parent class are also
interchangeable. It is helpful
Subclasses will have additional properties and methods specific to that type
to either use the terms
of object (for example, a current account might have a withdrawal limit or the
subclass and base class
ability to allow an overdraft, whereas a mortgage account might have a fixed
OR child class and parent
end-date and the ability to allow a payment holiday).
class for consistency, but
Both subclasses will inherit the attributes and methods from the base class both sets of terminology are
(that is, they both have an account number and a balance and both have acceptable.
methods for checking the balance and adding interest).
Job Role
1 Fundamentals of programming
Manager Employee
Composition aggregation
Composition aggregation describes a more dependant relationship in which
the container object is directly made up (composed) of the associated objects.
If the container object is removed or destroyed then so are the associated
objects. In our example the container object Workforce is made up of
managers and employers. Removing Workforce from the model altogether
results in the removal of the employees and managers.
In class diagrams, composition aggregation is shown using a filled diamond,
which always points towards the container class.
Workforce
Manager Employee
Polymorphism
Polymorphism means ‘many forms’. It covers the potential scenario of having Polymorphism Literally
two or more methods with the same name. ‘many forms’ – the ability for
✚ A method to ring(PhoneNumber) would involve dialling that specific two methods with the same
number. name to carry out their
✚ A method to ring(Name) would involve looking up the phone number for actions using different code.
the person you want to ring and then ringing that number. Overriding A method in
a subclass re-defining a
Both methods have the same name, but different parameters. By looking
method inherited from a
at the data type of the value that is passed, the object can identify which
base class.
method to use.
Having methods with the same names but different parameters means that
the same basic goal can be achieved using different steps, or methods, and is
Exam tip
a common feature in object-oriented programming. Look carefully through
the skeleton code for any
Overriding examples of polymorphism.
If there are any then this is a
Overriding is the situation where a base class has a method and a subclass
likely question to appear in
has a method of the same name, but with different steps. The subclass Section C.
method overrides (takes priority over) the method from the base class.
For example, an Account class can have a method CloseAccount that
transfers the remaining balance to the customer.
27
Revision activity
✚ Create flashcards for each piece of key vocabulary in this chapter.
✚ Examine the skeleton program for your Component 1 exam, or a previous skeleton
program, and identify as many examples of instantiation, inheritance, aggregation,
polymorphism and overriding as possible.
1 Fundamentals of programming
classes, which is not true for subclasses.
Changing a base class can cause unexpected side-effects in subclasses,
so using composition rather than inheritance means it is safer to update
program code in the future.
A particular problem with inheritance is that a subclass can’t inherit from two
different classes at once. This means that if a new behaviour is common to
two different classes then it may not be easier to re-use code without copying
it into both classes.
on that concept will appear in Section C and it is possible you will be expected to use relationship symbol. Make
those techniques when writing your own program code for Section D. sure you remember the
following.
✚ Inheritance is shown
Class diagrams using a hollow arrow,
The design of classes can be described using a class diagram, using arrows which always points
and diamonds to describe the relationships towards the base class.
✚ Association aggregation
Simple class diagrams just show the names of classes and the relationships
is shown using a hollow
between them.
diamond, which always
More detailed class diagrams show the attributes and methods within each points towards the
class as well. container class.
✚ Composition
These diagrams show the name of the class in the top section, attributes in aggregation is shown
the middle section and methods in the bottom section, along with access using a filled diamond,
specifiers. which always points
towards the container
Base class or parent class
class.
Account
– AccountNumber: String
– OpeningDate: Date
– CurrentBalance: Currency
– InterestRate: Real
+ GetAccountNumber()
+ GetCurrentBalance()
# AddInterest()
+ SetInterestRate
Revision activity
✚ Create a class diagram
Current Mortgage
that could be used
– PaymentType: String to model a house,
– Overdraft: Boolean – EndDate: Date including a House
Subclasses or container class and
+ SetPaymentType() + GetEndDate() associated classes that
child classes
+ SetOverdraft() + SetEndDate() include Kitchen,
LivingRoom,
+ GetOverdraft() Bedroom and
Garden. Consider the
Figure 1.7 A class diagram showing the design for different types of account
relationship between
Note the way that attributes are described using Identifier: Data Type. each class.
✚ Examine the skeleton
Now test yourself program for your
Component 1 exam,
85 What type of method can be called even if an object of that class has not been or a previous skeleton
instantiated? program, and create a
86 What key word means that a method can be overridden? detailed class diagram
87 What type of method must be overridden? to show attributes and
methods in each class as
88 Identify six things should be included in a detailed class diagram.
well as the relationships
Answers available online between them.
30
Summary
1 Fundamentals of programming
a data type and a value. It is important to choose a behaviours of real-world objects
meaningful identifier ✚ A class contains the attributes (variables) and methods
✚ Named constants are variables whose values cannot (subroutines) associated with that type of object and
be changed while the program is running functions as a blueprint for how objects of that class
✚ Selection is used to decide which block of code to will behave
execute and is implemented using an IF or SWITCH ✚ Objects are instances of a specific class and
statement instantiated by calling their constructor
✚ Iteration is used to repeat a block of code and either ✚ The process of grouping objects with common
uses a count-controlled (FOR) loop if the number of attributes and behaviours together is called
repetitions is known or a condition-controlled (WHILE encapsulation
or DO-WHILE) loop if the number of repetitions is not ✚ Access to an object’s attributes and methods is
known controlled using access specifiers
✚ Arithmetic operators include basic arithmetic, plus ✚ It is common for all attributes to be declared as private,
rounding, truncation and the use of DIV and MOD and for setter and getter methods to be declared as
✚ Relational operators can be combined with Boolean public in order to allow other objects to interact in a
operators to create more complex conditions controlled manner
✚ String handling operations include the basic skills of ✚ Inheritance describes an ‘is a’ relationship. A subclass
finding the length, addressing specific positions and will inherit the attributes and methods of a base class
concatenation (joining) of strings, as well as extracting ✚ Aggregation describes a ‘has a’ relationship. A
substrings, converting to and from the numeric container class will be linked to one or more associated
character codes and converting data types classes
✚ It is important to be able to use random number ✚ In association aggregation, if the container class
generation and exception handling in your is destroyed then the associated classes will be
programming untouched
✚ Exception handling is an important tool when a block of ✚ In composition aggregation, if the container class
code has a chance of failure (for example, opening a file is destroyed then the associated classes will be
that may not exist, or processing user inputs that may destroyed as well.
be in the wrong format) ✚ Polymorphism is the term for using having two or more
✚ Subroutines allow for code to be re-used. Parameters methods with the same identifier in the same class,
describe the data that must be passed to a subroutine but using different parameters to allow the program to
when it is called decide which method to run
✚ Functions are subroutines that return a value. ✚ Overriding is the term for a subclass having a method
Procedures are subroutines that do not return a value with the same identifier as a method in the base class;
✚ Local variables are preferable to global variables the method in the subclass will always take precedence
in most cases as they use less memory, make ✚ There are three design principles to remember:
subroutines more modular and make programs easier ‘Encapsulate what varies’, ‘Favour composition
to read and debug. over inheritance’ and ‘Program to interfaces, not
✚ Stack frames contain the return address, parameters, implementation’
and local variables of a subroutine call while it is ✚ You should not be asked about abstract, virtual and
running static methods but these may appear in the skeleton
✚ A recursive function is a function that calls itself. It code
must include at least one base case, a point at which ✚ Class diagrams should always show the name of the
the function will stop calling itself class, the attributes for that class (including data types
and access modifiers) and the methods for that class
Programming paradigms (including access modifiers)
✚ There are two main programming paradigms to study – ✚ Inheritance is shown using a hollow arrow that points
procedural-oriented programming and object-oriented towards the base class
programming ✚ Association aggregation is shown using a hollow diamond
✚ In procedural-oriented programming the main problem that points towards the container class
is broken down into smaller sub-problems, each of ✚ Composition aggregation is shown using a filled diamond
which is solved using a subroutine that points towards the container class
✚ Hierarchy charts are used to show which subroutines
call other subroutines
31
Exam practice
1 Dave has been asked to write a program as part of a project looking at rainfall. At the end of a week the user of the
program will enter the total rainfall (measured in mm) for each one of the last seven days as a number with one
1 Fundamentals of programming
FUNCTION Palindrome()
OUTPUT "Enter a word or phrase"
Phrase ← INPUT
Result ← PCheck(Phrase)
IF Result = TRUE THEN
OUTPUT "This is a palindrome"
ELSE
OUTPUT "This is not a palindrome"
ENDIF
ENDFUNCTION
FUNCTION PCheck(Phrase)
NumChars = Length(Phrase)
IF NumChars < 2 THEN
RETURN TRUE
ELSEIF Phrase[0] = Phrase[NumChars-1] THEN
RETURN PCheck(Phrase.Substring(1,NumChars-2))
ELSE
RETURN FALSE
ENDFUNCTION
32
3 This class diagram is a partial representation of the relationships between some of the classes in a program for a
garage.
Vehicle
1 Fundamentals of programming
- Registration: String
- Colour: String
- New: Boolean
- Owner: Owner
+ GetDetails()
# ChangeColour()
+ ChangeOwner()
33
Each individual item in the array is referred to using the identifier (or List A data structure similar
variable name) of the array, followed by the index in brackets (usually square to an array, commonly used
in Python in place of an
brackets). Each index position can hold data.
array.
Index [0] [1] [2] [3] [4]
Data 1 3 5 7 11 Exam tip
In most languages (including
Note C#, Delphi/Pascal, Java &
VB.Net) the array index
Arrays are always declared as a fixed size and cannot be changed later in the program. starts at 0, but be very
In an array, all data must be of the same data type. careful when reading
Lists are very similar to arrays, however it is possible to alter the size of a list while the exam questions as some
program is running and it is possible to store data of differing types in the same list. languages and some
scenarios will have the array
In some languages (notably including Python) it is much more common to use a list, index starting at 1.
whereas in others it is much more common to use an array.
You are not expected or required to show your understanding of the difference
between the two, and you should use whichever version is most suitable for your
chosen programming language.
Arrays are an effective solution for storing several values because a FOR loop
can be used to iterate (or loop) over an array.
In this example Numbers is the name of an array and Length(Numbers)
returns the size of the array (the number of items is contains).
FOR i ← 0 TO Length(Numbers)
OUTPUT Numbers[i]
34
ENDFOR
This code will step through the items in the array n times, where n is the size
Making links
of the array. This code would work for all arrays regardless of their size. This
is far more efficient than stepping through several variables one at a time, as One-dimensional arrays
this would require a separate line of code for each variable and the program can be an effective way
Numbers [1]
Numbers
[0] [1] [2] [3]
[0] [1] [2] [3]
[1] 11 13 17 19
[0] 1 3 5 7
Exam tip
[1] 11 13 17 19 Numbers [2]
[2] 23 29 31 37
Arrays can also be defined
[0] [1] [2] [3]
using the first index to find
[3] 41 43 47 51 [2] 23 29 31 37
the column and the second
Numbers [2][2] index to find the item in that
Numbers [3]
column. Always read the
[0] [1] [2] [3] question carefully as any
[3] 41 43 47 51 ambiguities should be made
Numbers [3][1] clear.
Figure 2.1 A two-dimensional array called Numbers
Making links
In the example above the contents of Numbers[0][3] can be found by isolating
row 0 and then finding the item in position 3. One common use for a
two-dimensional array is
A two-dimensional array is useful because it can store more complex data; for
storing a matrix. Matrices
example, the scores for different students or values for different days.
are often used in complex
It is possible to find the size of a two-dimensional array using the Length maths, and can also be used
function (exact syntax varies by programming language). to represent a graph data
structure. This is explored
For an array with indexes defined as [row][column], to find the number of
further later in this chapter.
rows, find the number of one-dimensional arrays the table can be split into:
NumberOfRows ← Length(ArrayName)
Matrix A rectangular, two-
To find the number of columns, find the length of a row in the table: dimensional collection of
NumberOfColumns ← Length(ArrayName[0]) values.
[2] 23 29 31 37
[3] 41 43 47 51
Exam tip
While questions on two-dimensional arrays are quite common, three-dimensional
arrays are generally limited to potential skeleton programs and NEA programming
projects. Examine the skeleton code carefully for any examples of multi-dimensional
arrays.
Revision activity
✚ Create a two-dimensional array called MovieRatings. Populate the array with
film review ratings, with each row representing one review website and each
column representing one film.
✚ Create a menu and write program code that will allow the user to:
✚ find the min, max and mean average review score for each film
✚ find the min, max and mean average review score from each website
✚ find a specific review rating given the name of the film and the review website.
✚ Create a 2-dimensional array to store the game state for a game of noughts and
36 crosses.
Each item in a record can be a different data type, making a record more
complex than an array, but also more flexible.
There are many ways to implement a record, and this is handled differently in
different programming languages. Understanding and recognising records of
data and which fields are being used is the key concept.
One common concept when considering records is the importance of writing
records to a file.
Files are a way of permanently storing data which would otherwise be lost
File A persistent collection
once the program or subroutine has finished executing. of data, saved for access
Text files use a character set (such as ASCII or Unicode) to store the data as and accessible once the
text and typically use a delimiter such as a comma (,) or colon (:) to separate program or subroutine has
the individual items of data. These files are usually saved with a .txt or .csv finished running.
(comma separated value) file extension. Text file A file that uses
A saved file from a game of Noughts and Crosses might be saved like this as a text encoding (such as ASCII
.csv file, where a comma is used to separate each item of data. or Unicode) to store data.
Binary file A file that uses
X binary values to represent
each item of data.
O X
X O
-,X,-,-,O,X,-,X,O
An alternative is to save the game as a binary file. A binary file only stores
binary information, and needs a key to translate binary into particular items
of data. For instance, for the Noughts and Crosses game, using two bits per
cell, the following key could be used:
00 Empty
01 X
10 O
Note
2 Fundamentals of data structures
For A-level it is only necessary to consider sequential file access. That is, reading files
from start to end, in order.
Exam tip
The syntax for writing to and reading from files varies significantly in different
programming languages. It is important to be familiar with file handling routines in
your chosen programming language and to look carefully for any file handling that
takes place in the skeleton program.
Revision activity
✚ Create a two-dimensional array to represent the state of a game of noughts and
crosses. Write program code that will:
✚ save the game state as a text file
✚ load a game state from a text file
✚ save the game state as a binary file
✚ load a game state as a binary file.
✚ Compare the file size of the text and binary files. Try opening both types of file in a
simple text editor (such as Notepad) and compare the contents.
Queues
A queue data structure works in a very similar way to a queue in the real
Common uses for queues include: First In, First Out (FIFO)
✚ buffering (storing data as it arrives until it can be processed) Those items placed into the
queue first will be the first
✚ simulating a card game (cards are drawn from the front and replaced at
ones to be accessed.
the back).
Pointer A value that stores
Making links an address. In the context
of queues this is usually the
Queues are a fundamental part of the breadth first search (BFS) which is explored in index of the front or rear
Chapter 3. item.
FP RP
[0] [1] [2] [3] [4] [5] FP 0
Dave Angelina Faaris RP 2
RP
[0] [1] [2] [3] [4] [5]
Dave Angelina Faaris Kev RP 3
Items are retrieved from the front of the queue by moving each item forward
in the array:
RP
[0] [1] [2] [3] [4] [5]
Angelina Faaris Kev RP 2
This can be inefficient, especially for large queues, as moving each item in the
array takes time. 39
FP RP
[0] [1] [2] [3] [4] [5] FP 1
Dave Angelina Faaris Kev RP 3
Note
In a circular queue there is no need to delete the value from the array, only to move
the pointers. The data that has been dequeued will eventually be overwritten when
the rear pointer comes back around.
When a pointer reaches the end of the array, it wraps around back to the start.
For example, given the following state of a circular queue:
FP RP
[0] [1] [2] [3] [4] [5] FP 2
Dave Angelina Faaris Kev RP 5
When a new item is enqueued, the rear pointer will wrap around to 0.
RP FP
[0] [1] [2] [3] [4] [5] FP 2
Aadya Dave Angelina Faaris Kev RP 0
Note
Exact implementations vary slightly, for example some implementations have the rear
pointer pointing to the first empty space rather than the last full space.
A circular queue is much more efficient that a linear queue when the queue is
large as it avoids the need to move each item each time a value is dequeued.
A circular queue is also a more complex data structure and a linear queue
may be more appropriate for a smaller queue.
FP RP
[0] [1] [2] [3] [4] [5]
Engine Steering Calculate
Warning Input Position
5 4 3
40
FP RP
[0] [1] [2] [3] [4] [5]
Engine Steering Rudder Calculate
Warning Input Input Position
5 4 4 3
Stacks
A stack is a Last In, First Out (LIFO) data structure. Stack A data structure in
Much as with a stack of plates, new items are placed at the top of the stack which items are added to
and items are also removed from the top of the stack. the top and removed from
the top, much like a stack of
Common uses for stacks include: plates.
✚ reversing a list of values
Last In, First Out (LIFO)
✚ performing undo operations
Those items placed into the
✚ as a call stack for keeping track of subroutine calls.
stack most recently will be
A stack can be implemented using a single-dimensional array and a single the first ones to be accessed.
integer variable to point at the top of the stack.
[5] Top 2
[4]
[3]
[2] Change font Top
[1] Make bold
[0] Type
41
The IsFull and IsEmpty actions are necessary because a program will crash if
there is an attempt to push data when the stack is already full or to pop data
from an empty stack.
When a value is pushed onto the stack it is placed at the top position and the
value of the top pointer is incremented.
[5] Top 3
[4]
[3] Delete selection
[2] Change font Top
[1] Make bold
[0] Type
When a value is popped from the stack the value at the top position is
returned and the top pointer is decremented.
[5] Top 2
[4]
[3] Delete selection
[2] Change font Top
[1] Make bold
[0] Type
17 State the acronym used to classify a stack data structure, and state the words this In a stack there is no need
stands for. to delete the value from
18 Describe two potential uses for a stack. the array, only to move the
pointer. The data that has
19 What error could occur when trying to Push an item? State how this situation could
been popped will eventually
be dealt with.
be overwritten when new
20 Describe the difference between Pop and Peek. data is pushed and the top
pointer moves back up.
Answers available online
Revision activity
✚ Create a Stack class in your chosen programming language. Include the following
methods:
✚ IsFull
✚ IsEmpty
✚ Push
✚ Pop
✚ Peek
✚ Take a program that you have written that makes use of subroutines and write down
the state of the call stack each time a new subroutine is called or a value returned.
✚ Repeat the first bullet for a recursive program that you have written.
42
Graphs
A graph is a data structure designed to represent more complex
Graph A data structure
relationships.
Types of graph
Unweighted and undirected graphs
Town A Town B
A simple graph (unweighted and undirected) shows how two or more items
are connected.
Figure 2.3 An unweighted,
undirected graph
Weighted graphs
A weighted graph is used where the connection between the two nodes has a Weighted graph A graph in
cost or value (such as a distance). which each edge has a value
or cost associated with it.
30
Town A Town B Directed graph A graph
some edges can only be
Figure 2.4 A weighted graph traversed in one direction,
shown with an arrow head.
Charles Pauline
Exam tip
Harry Make sure you can identify
the different types of
graph. Be careful with the
Dave
Jack term ‘edge’. This doesn’t
mean the outskirts of the
graph, but the connections
Figure 2.5 A directed graph
between each node.
In a directed graph, not all edges need to be one-directional.
Now test yourself
Disconnected graphs 21 Explain the following terms.
A disconnected graph is one in which two or more vertices are not connected a Weighted graph
to the rest of the graph. b Directed graph
c Disconnected graph
A B
22 State two other terms
for a line or a connector
E
in a graph.
23 What symbol is only used
C
in a directed graph?
D 24 Suggest two possible uses
for a graph data structure.
Figure 2.6 A disconnected graph Answers available
online 43
For a weighted graph, this list also includes the cost of travelling along
each edge.
This is efficient for sparse graphs, where the presence of edges does not need Sparse graph A graph with
to be tested often, because sparse graphs have very few edges and so not few edges.
much storage space is needed. However reading and processing each item in
an adjacency list can be inefficient if the list is large. Adjacency matrix A
method of representing
An adjacency matrix uses a grid to store details of adjacent nodes. a graph using a grid with
For an unweighted graph the adjacency matrix uses a binary number to show values in each cell to show
the presence or lack of an edge. which nodes are connected
to each other.
A B C D E
A B Dense graph A graph with
A 0 1 1 0 0 many edges.
E B 1 0 1 0 1
C 1 1 0 1 0
C D 0 0 1 0 1
D
E 0 1 0 1 0
This is efficient for dense graphs, where the presence of edges needs to be
tested often, because the adjacency matrix is simple to step through. However
a lot of space can be wasted if the graph has few edges.
Undirected graphs will produce an adjacency matrix with a diagonal line of
symmetry.
Directed graphs will produce an adjacency matrix without symmetry, as not
all edges can be traversed in either direction.
44
A B C D E
A B
A 0 1 0 1 0
E B 0 0 0 0 1
Weighted graphs will produce an adjacency matrix that stores the cost of each
edge.
Where nodes are not adjacent the cost of traversing is infinite.
20 A B C D E
A B 25
A ∞ 20 30 ∞ ∞
30 E B 20 ∞ 30 ∞ 25
30 Exam tips
C 30 30 ∞ 35 ∞
40 Make sure you are confident
C 35 D ∞ ∞ 35 ∞ 40 recalling the pros and
D
E ∞ 25 ∞ 40 ∞ cons of adjacency lists and
adjacency matrices, as this
Figure 2.11 An adjacency matrix for a weighted graph is a common question.
The number of edges is the main consideration when deciding whether an The difference between
adjacency list or an adjacency matrix is the most appropriate data structure a graph and a tree is that
for recording the details of a graph. a tree has no cycles. This
question comes up quite
Advantages Disadvantages often.
Adjacency list Good for sparse graphs (few Poor for dense graphs as it
edges) or situations where takes longer to process each
edges don’t need to be tested value.
often as it takes up less
storage space.
Adjacency matrix Good for dense graphs (many Poor for sparse graphs as it
edges) or situations where wastes storage space.
edges do need to be tested
often as it is easier to process
each value.
25 Which representation for a graph, when written down, looks most like a grid? ✚ Create a weighted graph
26 Which representation for a graph is most suitable for a sparse graph? showing the time taken
to travel between five
27 When else would that representation be most suitable?
towns near your home.
28 When would an adjacency matrix not be symmetrical? ✚ Create an adjacency
29 True or false? An adjacency list cannot be used for a weighted graph. matrix and an adjacency
list to represent the
Answers available online graph.
Trees
A tree is a special example of a graph which has no cycles (or loops). Tree A graph which has no
cycles (it is not possible to loop
Trees are always connected (no disconnected nodes) and undirected (edges back around to a previously
can be traversed in both directions). traversed part of the tree).
A rooted tree has one node as the root, or starting point, and all of the edges Rooted tree A tree with a
tend to lead away from the root. Rooted trees are commonly used to represent rooted node, from which all
a hierarchical structure, such as the chapters in this book. They are very edges leading away from
45
commonly used as binary search trees, as described below. that root.
3
4
2 Fundamentals of data structures
Component 1 Component 2
5
1 2 3 4
Programming Data Structures Algorithms Computation 6
Budgie Fish
Rooted Non-rooted
Figure 2.12 A rooted tree to represent chapters and topics in this book Rabbit
A non-rooted tree doesn’t have a clear start point and appears at a glance to
Figure 2.14 A binary search
be more like a graph, though with no cycles.
tree for storing pets in
A binary tree is a rooted tree in which each node has a maximum of two alphabetical order
children.
Cat
Binary trees consist of:
Root the node that is the starting point for the tree Budgie Fish
Branch a node that comes after the root and has one or more children
Leaf a node that does not have any children
Dog Rabbit
Binary search trees are especially useful for storing data in an ordered way
Figure 2.15 A binary search
and can be quickly and easily traversed to provide an ordered list.
tree with the addition of a
When adding data to a binary search tree, each new node is added according node for Dog
to its order.
In the example in Figure 2.14, where pets are stored alphabetically, to insert Binary tree A tree in which
the value Dog we would: each node has a maximum
✚ Compare to the root: Dog comes after Cat so follow the right edge of two children.
✚ Compare to the next node: Dog comes before Fish in the alphabet so we Root A node that has no
follow the left node parent nodes.
✚ If there is no child node in that direction, then we add one:
Branch A node that has a
The order in which the nodes are written will be different depending on the parent node and at least
order in which nodes are added. However the binary search tree will always one child node.
be able to provide a correctly ordered list.
Leaf A node that has no
Note child nodes.
Binary search tree A
Binary trees are also useful for representing equations and can be traversed in such
binary tree used to store
a way as to produce equations in infix notation, Polish notation and reverse Polish
data in order so that it
notation (RPN).
can be quickly and easily
searched.
Hash tables
A hash table is a data structure in which values are found by looking up their
associated key by following a hashing algorithm. Revision activity
Making links
Hashing algorithms are also used for checksums (to check the validity of a file or other
piece of data) and for encryption (hashed passwords are typically stored in databases Revision activity
rather than plaintext passwords). Checksums and other error checking processes, and ✚ Design a simple hashing
encryption, are described in Chapter 5. algorithm for storing the
names of films based
on the length of the film
Now test yourself title.
✚ Implement a hash table,
33 Describe the relationship between a value and its key in a hash table. storing the names
34 What is meant by a collision in a hash table? of films in an array
based on the hashed
35 Describe two steps that must be taken when rehashing.
keys. Display an error
36 Describe three potential uses for a hashing algorithm. message if two films
37 A hashing algorithm for an ID number is written as ‘sum of each digit MOD 6’. generate the same key
Calculate the hashes for each of the following values. and devise an improved
a 7216 hashing algorithm to
b 5891 reduce the number of
c 0275 collisions (for example,
alter the modulo
Answers available online division).
47
Dictionaries
A dictionary is a collection of key–value pairs, in which the value is found by
Dictionary A data
looking up the key.
2 Fundamentals of data structures
One use for a dictionary is information retrieval, for example in frequency Frequency analysis The
analysis (storing the value of how many instances of a word, letter or other process of examining how
key appears) or as a high score table: often something occurs.
A useful tool for trying to
{"Dave" : 23, "Kev" : 37, "Angelina" : 42} break some encryption
Another use for a dictionary is lossless compression where a dictionary of methods.
values is stored and the original file is represented with just the keys, in order. Lossless compression
For instance using the following dictionary: Reducing the size of a file
without the loss of any data.
Key Value
1 ask
2 not
3 what
4 your
5 country
6 can
7 do
8 for
9 you
10 ,
11 .
We can compress the sentence:
"Ask not what your country can do for you, ask what you can
do for your country."
This sentence can be stored as:
1 2 3 4 5 6 7 8 9 10 1 3 6 7 8 4 5 12
Vectors
Vector representation
In mathematics, scalars are simple numbers that only have a size. Vectors on Scalar A single number
the other hand are numbers that have both a magnitude and a direction. used to represent or adjust
Vectors are often used to represent a position. For example, a 2D vector can be the scale of a vector.
used to can be represent a position on a 2D plane. Vector A data structure
used to represent a position
Vectors can be shown in the list representation – when it is represented (for example, a 2D vector
as a list of numbers, such as [3,5]. In this two-dimensional vector the
48 represents a position on a 2D
plane).
Public Credit.
The House again went into a committee on the report of the
Secretary of the Treasury, Mr. Baldwin in the chair.
Mr. Madison's proposition still under consideration.
Mr. Page.—I do not wish to trouble the committee with a formal
argument in favor of the motion offered by my colleague; but I wish
to inquire of the gentlemen in opposition, whether they conceive the
principles upon which it is grounded to be unjust? I observed, that
their replies have generally gone against the practicability of the
measure; but that does not prove to me that it is inequitable. If
there is justice in the case, we must not consider the difficulty of the
attempt. I trust, if it shall be found to stand on the foundation of
immutable justice, that its practicability will be demonstrated.
However, I shall not enter on that ground, but leave it to my
colleague, who has so ably supported it on the other.
I would, however, beg gentlemen to answer these questions, and
show to my mind the injustice of the United States complying with
their engagements made to the first holders of certificates, as far as
the case, and their abilities, will permit. Or where is the justice of
doing more for the assignee than he, or his assignor, expected could
or would be done? Where is the breach of faith in Government, if it
pays its whole debt, with a justice, blended with mercy, resembling
that of Heaven itself, making impartial retribution among the
children of men, on the great day of accounts? Where is the
propriety of branding a measure of this nature with epithets of
infamy? or using such harsh expressions as have issued like a torrent
from a gentleman on the other side of the House? So far am I from
viewing the propositions through such a discolored medium, that I
am induced to believe, if Congress adopt it, they may submit its
rectitude, and stand the decision, of not only a superior order of
beings, but of the Great Judge of the Universe, who is immutable
truth itself.
What will the assignee lose by the measure? He will lose nothing,
but the sanguine expectation lately raised in his mind.
Where is the interference in contracts, when the proposition is to
comply sacredly, as far as the case will admit, with the contract
between the State and its creditors? Is not the assignment of the
certificates confirmed by the nation? Does it not give to the assignee
the very thing stipulated between the assignor and assignee, that is,
whatever sum the Government shall be pleased to pay for the
certificate? And is not the sum now proposed, more than either the
first or last assignee ever contemplated, till within a few days past,
would ever be paid him?
The time is now arrived when justice ought to be done; it is looked
for, with anxious expectation, by all classes of our fellow citizens; it
will not avail us to say, it is impracticable, until experience has
demonstrated it to be so. But the measure we contend for is termed
an ex post facto law, and as such, is declared to be unconstitutional.
Gentlemen torture every thing, in order to produce evidence against
an act of justice. How can it be such an ex post facto law as is
prescribed by the constitution, when that expression is conjunctive
with a bill of attainder? It relates to that only, and can have no
reference to the subject of the proposition before us. The same idea,
which prevents us from an interference on the present occasion, will
prevent us, as was observed by the gentleman from Georgia, from
making a statute of limitation, or from correcting any frauds, which
have been perpetrated on the unsuspicious soldiery. We must not
contemplate the restoration of the starving soldier, with his humble
wife and numerous and naked offspring, to a more eligible situation;
we must not restore confidence to the man of honor who is buried in
abject poverty, because it is addressing a language to the heart,
which the haughtiness of the head disdains to hear; but, in doubtful
cases of justice, the heart is the best director on this subject; happy
will it be for us, if, as I think, they both concur to give their
approbation to the present measure.
Public Credit.
The House again went into a committee on the Secretary of the
Treasury's report, Mr. Baldwin in the chair.
Mr. Madison's proposition still under consideration.
Mr. Stone.—I shall not attempt to show the importance of the subject
before us, as it relates to public credit; or as it will affect our
character as a nation, at home and abroad. These have been
explained; but it is proper for us to consider how far the amendment
may operate to establish a precedent of Continental and State
Legislation, the influence it may have on society, and the rules of
civil conduct between man and man. Every community must
experience that the conduct of the Government will influence the
opinions of the individuals; and the spirit of the individual will
transfuse itself into the Government. This action and reaction
operates more powerfully in a Republican Government, founded on
representation, than on any other.
Our situation is made more important, on the present occasion, by a
disagreement on principles which ought to be fixed and plain; to me
it seems that we differ on the principle of public justice. This may be
unfortunate—let us endeavor to be reconciled. If the true distinction
between natural and civil justice be accurately drawn, we may
annihilate the point in contest. Agreeably to the principle of natural
justice, no contract is perfect unless there be an equivalent; and that
which we call a valuable consideration, on which to ground a
contract, is founded on the idea of an equivalent, and presupposes
it. And, I believe the idea of such a consideration being an
equivalent, is the foundation of the validity of a contract, even in the
English law; and is always carried into effect, wherever the execution
is safe and certain; because I think, whenever it appears in any
court of justice, that the consideration was not an equivalent, that
then the contract is not carried into execution. The execution of the
principle of natural justice then is safe; for instance, £99 19s. 11d. is
not a consideration for £100, but a small sum may be a
consideration for a valuable property; this does not arise from an
infraction of the principle; but because the property may not have a
determinate value in the society; and it would make judges arbitrary,
legal proceedings extremely expensive, and contracts uncertain, if an
extensive discretion as to the value was admitted. But whenever the
consideration is so small and inadequate, as to appear so plainly and
satisfactorily that the judge cannot be mistaken in determining it not
to be an equivalent, there the contract is not valid.
Now, if we have received services from the soldier, and have given
him paper, the question will be, whether that was an equivalent, and
the paper a proper payment; or whether it is only an evidence of the
debt? I take it to be a granted point that it was not a payment, but
an obligation to pay whenever the United States should be able. It
appears to me, then, that it was the duty of the person who received
the paper, to wait a reasonable time; and the duty of the nation to
make actual payment as speedily as possible. If the person who had
received this paper had wantonly parted with it for nothing, I agree
we should have been under no more obligation to pay him the
expressed sum, than if we had paid him money, and he had flung it
away or wasted it; but if, on the contrary, there was a delay in the
execution of the contract, on the part of the Government, which
compelled him to part with it, a compensation is equitable.
The same rule will apply between the original holder, or person who
rendered the service, and present possessor or assignee; for
shortness we will distinguish them by the names of soldier and
speculator. The speculator, when he dealt with the soldier, must,
from the nature of the thing, have induced him to believe that he
gave him an equivalent for his purchase; and it might have been an
inducement to the soldier to sell, to think he had something more
than an equivalent; the speculator thought he had more than an
equivalent, throwing necessity on the one side, and fraud on the
other, out of the question. Then the confidence was equal, perhaps
not a penny between them: I can hardly conceive the exchange took
place on any other terms. You never can allow the confidence of the
speculator to be estimated very highly, perhaps at not more than
one for ten. For if it is admitted, that the speculator had entire
confidence, he was guilty of a palpable fraud, and a violation of the
first principle of justice; it amounted to this, that he gave £10 in
money for £100 bond, which he was certain would be paid. I
believe, if the case stood exactly in this form, no man would hesitate
in deciding its illegality. If a man takes £100 for £10, it is illegal; but
suppose there was a risk, and this risk was considered by the
speculator as little less than ten for one, has he not discovered his
own mistake when he sees he gets an interest of sixty per cent. on
his capital; and that capital tenfold? This contract then ought to be
void on the principle of a mistake; and here you place the speculator
between Scylla and Charybdis. If he really thought the certificates
only worth one for ten, you can give him no credit for his
confidence; and you will admit that he ought to be satisfied with a
reasonable advance on his purchase. But if you give him entire credit
for his confidence in Government, you must give him no credit for
his honesty. If both parties had known of this event, the contract
would never have taken place. If you pay the whole sum, the
speculator ought to take no more than what he gave a fair
equivalent for. Gentlemen who seem afraid of giving to the soldier a
part of his original claim, lest they affront his nobleness of soul,
make no scruple to offer the speculator ten times the sum he is
entitled to, on the principle of natural justice, without any
apprehension that his honor will receive a wound. If the claim of the
soldier was extinguished by receiving two shillings in the pound of
the speculator, upon what principle is it contended that the latter
should receive more than distributive justice? Arguments, proving
that the justice due to the first has been satisfied by what has been
done, apply with greater force to the latter.
It has been doubted, and a question has been agitated, whether we
shall exercise the power of reconsidering these contracts, and
whether a modification is constitutionally in our power? I will not go
into this subject, or any other which ought to be taken for granted. I
shall take it, that we are authorized, and do mean to interfere; you
must act. Do you mean to pay the principal and interest now due? I
believe not. Will you shelter yourself under the plea of necessity?
That is impossible. I dare say, if the United States were sold, they
would at least be worth six hundred millions of dollars; and we have
but eighty millions to provide for. Having, then, the means and
power, I trust you mean to exercise them; and as you exercise them,
you ought to exercise them as justly as possible; then, to do this,
you will, it is said, personify the three parties concerned—the United
States, the original holder, and the speculator. I do not clearly
comprehend the idea of a personified State; perhaps it arises from
my dulness of apprehension. Man, in his natural capacity, is
sometimes obliged to do what is considered unjust; but a State,
when it has power, is not obliged to do what is unjust. The State,
then, in this respect, is doing what an honest man would do, if he
had the power of conducting this business as he thought proper.
The speculator comes to you with his bond, and tells you it is due.
The soldier tells you that he has done services to a considerable
amount, for which he never has been paid; and that those evidences
of the demand which you gave to him, were obtained from him, for
one-tenth part of what they were declared to be worth. The State
says to the speculator, you have made a great deal, and out of a
man who has risked his life, and borne every burthen which human
nature could bear, with the greatest fortitude which the most
virtuous heart is capable of exerting, let him have a part back. The
speculator answers no; here is your bond. Consider again, replies
the State, that the veteran's services, at the expense of his health
and property, at the risk of his life, has saved you and yours; and
not only that, but he is obliged to pay of your demand, more than he
has ever received. What is now his answer? Here is the bond, pay
me my bond. Under these circumstances, supposing the State an
individual, he might, without much infamy to his character, exercise
the power which he has over his own bond, in order to do justice
between the parties. He might say to the speculator, you had the
soldier in your power; you did him injustice; we have you now in our
power, we will do you complete justice, but no more. A private man
could never be injured in his reputation by such conduct: indeed,
according to the result of these circumstances, the hardships of war,
and the breach of contract, have unfortunately inflicted upon the
man, the most meritorious in this community, or perhaps in any
other community, sufferings and miseries—a punishment sufficient
to atone for the guilt of the greatest crimes. This, in the event,
appears to be the situation of the saviors of America.
Mr. Madison said that the opponents of his proposition had imposed
on its friends not only a heavy task, by the number of their
objections, but a delicate one by the nature of some of them. It had
been arranged as an embarrassing measure which ought to be
facilitated, and producing discussions which might end in
disagreeable consequences. However painful it might be to
contradict the wishes of gentlemen whom he respected, he could
promise nothing more, in the present case, than his endeavors to
disappoint their apprehensions. When his judgment could not yield
to the propositions of others, the right to make and support his own,
was a right which he could never suffer to be contested. In
exercising it, he should study to maintain that moderation and
liberality which were due to the greatness of the subject before the
committee. He felt pleasure in acknowledging, that the like spirit
had, in general, directed the arguments on the other side. Free
discussions thus conducted are not only favorable to a right decision,
but to a cheerful acquiescence of the mistaken opponents of it. They
might have the further advantage of recommending the result to the
public, by fully explaining the grounds of it. If the pretensions of a
numerous and meritorious class of citizens be not well founded, or
cannot be complied with, let them see that this is the case, and be
soothed, under their disappointment, with the proof that they have
not been overlooked by their country.
He would proceed now to review the grounds on which the
proposition had been combated; which he should do without either
following those who had wandered from the field of fair argument,
or avoiding those who had kept within its limits.
It could not have escaped the committee, that the gentlemen to
whom he was opposed, had reasoned on this momentous question
as on an ordinary case in a court of law; that they had equally
strained all the maxims that could favor the purchasing, or be
adverse to the original holder; and that they dwelt with equal
pleasure on every circumstance which could brighten the pretensions
of the former, or discredit those of the latter. He had not himself
attempted, nor did he mean to undervalue the pretensions of the
actual holders. In stating them, he had even used as strong terms as
they themselves could have dictated; but beyond a certain point he
could not go. He must renounce every sentiment which he had
hitherto cherished, before his complaisance could admit that America
ought to erect the monuments of her gratitude, not to those who
saved her liberties, but to those who had enriched themselves in her
funds.
All that he wished was, that the claims of the original holders, not
less than those of the actual holders, should be fairly examined and
justly decided. They had been invalidated by nothing yet urged. A
debt was fairly contracted; according to justice and good faith, it
ought to have been paid in gold or silver; a piece of paper only was
substituted. Was this paper equal in value to gold or silver? No. It
was worth, in the market, which the argument for the purchasing
holders makes the criterion, no more than one-eighth or one-
seventh of that value. Was this depreciated paper freely accepted?
No. The Government offered that or nothing. The relation of the
individual to the Government, and the circumstances of the offer,
rendered the acceptance a forced, not a free one. The same degree
of constraint would vitiate a transaction between man and man,
before any Court of Equity on the face of the earth. There are even
cases where consent cannot be pretended; where the property of
the planter or farmer had been taken at the point of the bayonet,
and a certificate presented in the same manner. But why did the
creditors part with their acknowledgment of the debt? In some
instances, from necessity; in others, from a well-founded distrust of
the public. Whether from the one, or the other, they had been
injured; they had suffered loss, through the default of the debtor;
and the debtor cannot, in justice or honor, take advantage of the
default.
Here, then, was a debt acknowledged to have been once due, and
which was never discharged; because the payment was forced and
defective. The balance, consequently, is still due, and is of as sacred
a nature as the claims of the purchasing holder can be; and if both
are not to be paid in the whole, is equally entitled to payment in
part.
He begged gentlemen would not yield too readily to the artificial
niceties of forensic reasoning; that they would consider not the
form, but the substance—not the letter, but the equity—not the bark,
but the pith of the business. It was a great and an extraordinary
case; it ought to be decided on the great and fundamental principles
of justice. He had been animadverted upon, for appealing to the
heart as well as the head; he would be bold, nevertheless, to repeat,
that, in great and unusual questions of morality, the heart is the best
judge.
It had been said, by a member from Massachusetts, that the
proposition was founded on a new principle in Congress. If the
present Congress be meant, that is not strange, for Congress itself is
new; if the former Congress be meant, it is not true, for the principle
is found in an act which had been already cited. After the pay of the
army had, during the war, been nominally and legally discharged in
depreciated paper, the loss was made up to the sufferers.
It had been said, by a member from New York, that this case was
not parallel, there being no third party like the present holders of
certificates. This objection could not be valid. The Government paid
ten dollars' worth in fact, but only one to the soldier. The soldier was
then the original holder. The soldier assigned it to the citizen; the
citizen then became the actual holder. What was the event? The loss
of the original holder was repaired, after the actual holder had been
settled with, according to the highest market value of his paper.
He did not mean, however, to decide on the whole merits of this last
transaction; or to contend for a similitude, in all respects, between
the two kinds of paper. One material difference was, that the bills of
credit, by more frequent transfers, and by dividing the change of
value among a greater number of hands, rendered the effect of less
consequence to individuals, and less sensible to the public mind. But
this difference, whatever force it might give to the claims of the
purchasing holder of certificates, could diminish nothing from the
claims of the original holders who assigned them.
It had been said, by another member from Massachusetts, that the
old Government did every thing in its power. It made requisitions,
used exhortations, and in every respect discharged its duty; but it
was to be remembered, that the debt was not due from the
Government, but the United States. An attorney, with full powers to
form, without the means to fulfil engagements, could never, by his
ineffectual, though honest efforts, exonerate his principal.
He had been repeatedly reminded of the address of Congress in
1783, which rejected a discrimination between original and
purchasing holders. At that period, the certificates to the army, and
citizens at large, had not been issued. The transfers were confined
to loan-office certificates, were not numerous, and had been, in
great part, made with little loss to the original creditor. At present,
the transfers extend to a vast proportion of the whole debt, and the
loss to the original holders has been immense. The injustice which
has taken place has been enormous and flagrant, and makes redress
a great national object. This change of circumstances destroys the
argument from the act of Congress referred to; but if implicit regard
is to be paid to the doctrines of that act, any modification of the
interest of the debt will be as inadmissible as a modification of the
principal.
It had been said, that if the losses of the original creditors are
entitled to reparation, Congress ought to repair those suffered from
paper money—from the ravages of the war, and from the act of
barring claims not produced within a limited time. As to the paper
money, either the case is applicable, or it is not: if not applicable, the
argument fails; if applicable, either the depreciated certificates ought
to be liquidated by a like scale, as was applied to the depreciated
money; or the money, even if the whole mass of it was still in
circulation, ought to be literally redeemed, like the certificates.
Leaving the gentleman to make his own choice of these dilemmas,
he would only add, himself, that if there were no other difference
between the cases, the manifest impossibility of redressing the one,
and the practicability of redressing the other, was a sufficient answer
to the objection. With respect to the towns burnt, and other
devastations of war, it was taught, by the writers on the law of
nations, that they were to be numbered among the inevitable
calamities of mankind. Still, however, a Government owed them
every alleviation which it could conveniently afford; but no authority
could be found that puts on the same footing with those calamities,
such as proceed from a failure to fulfil the direct and express
obligations of the public. The just claims barred by the act of
limitation, were, in his opinion, clearly entitled to redress. That act
was highly objectionable. The public, which was interested in
shortening the term, undertook to decide, that no claim, however
just, should be admitted, if not presented within nine months. The
act made none of the exceptions usual in such acts, not even in
favor of the most distant parts of the Union. In many instances, it
had been absolutely impossible for the persons injured to know of
the regulation. Some of these instances were within his own
knowledge. To limit the duration of a law to a period, within which it
could not possibly be promulged, and then take advantage of the
impossibility, would be imitating the Roman tyrant, who posted up
his edicts so high that they could not be read, and then punished the
people for not obeying them.
It has been said, that if the purchased certificates were funded at
the rate proposed, they would fall in the market, and the holders be
injured. It was pretty certain, that the greater part, at least, would
be gainers. He believed that the highest market price, especially with
the arrears of interest incorporated, well funded at six per cent,
would prevent every loss that could justify complaint.
But foreigners had become purchasers, and ought to be particularly
respected. Foreigners, he remarked, had themselves made a
difference between the value of the foreign and domestic debt; they
would, therefore, the less complain of a difference made by
Government here. It was his opinion that the term stated in the
proposition would yield a greater profit to the foreign purchasers
than they could have got for their money if advanced by them in any
of the funds of Europe.
The proposition had been charged with robbing one set of men to
pay another. If there were robbery in the case, it had been
committed on the original creditors. But, to speak more accurately,
as well as more moderately, the proposition would do no more than
withhold a part from each of two creditors, where both were not to
be paid the whole.
A member from New York has asked whether an original creditor,
who had assigned his certificate, could, in conscience, accept a
reimbursement in the manner proposed? He would not deny that
assignments might have been made with such explanations, or
under such circumstances, as would have that effect; but, in
general, the assignments have been made with reference merely to
the market value, and the uncertainty of the steps that might be
taken by the Government. The bulk of the creditors had assigned
under circumstances from which no scruples could arise. In all cases
where a scruple existed, the benefit of the provision might be
renounced. He would, in turn, ask the gentleman, whether there
was not more room to apprehend that the present holder, who had
got his certificate of a distressed and meritorious fellow-citizen for
one-eighth or one-tenth its ultimate value, might not feel some
remorse in retaining so unconscionable an advantage?
Similar propositions, it was said, had been made and rejected in the
State Legislatures. This was not a fact. The propositions made in the
State Legislatures were not intended to do justice to the injured, but
to seize a profit to the public.
But no petitions for redress had come from the sufferers. Was merit,
then, to be the less regarded, because it was modest? Perhaps,
however, another explanation ought to be given. Many of the
sufferers were poor and uninformed. Those of another description
were so dispersed, that their interests and efforts could not be
brought forward. The case of the purchasing holders was very
different.
The constitutionality of the proposition had been drawn into
question. He asked whether words could be devised that would
place the new Government more precisely in the same relation to
the real creditors with the old? The power was the same; the
obligation was the same. The means only were varied.
An objection had been drawn from the article prohibiting ex post
facto laws. But as ex post facto laws relate to criminal, not civil
cases, the constitution itself requires this definition, by adding to a
like restriction on the States an express one against retrospective
laws of a civil nature.
It had been said, that foreigners had been led to purchase, by their
faith in the article of the constitution relating to the public debts. He
would answer this objection by a single fact: Foreigners had shown,
by the market price in Europe, that they trusted the nature of
foreign debt more under the old Government, than the nature of the
domestic debt under the new Government.
Objections to the measure had been drawn from its supposed
tendency to impede public credit. He thought it, on the contrary,
perfectly consistent with the establishment of public credit. It was in
vain to say, that Government ought never to revise measures once
decided. Great caution on this head ought, no doubt, to be
observed; but there were situations in which, without some
legislative interposition, the first principles of justice, and the very
ends of civil society, would be frustrated. The gentlemen themselves
had been compelled to make exceptions to the general doctrine;
they would probably make more before the business was at an end.
It had been urged, that if Government should interpose in the
present case, as interposition would be authorized in any case
whatever where the stock might fluctuate, the principle would apply
as well to a fall of sixty or seventy per cent. as to a fall of six
hundred or seven hundred per cent. He could not admit this
inference. A distinction was essential between an extreme case, and
a case short of it. The line was difficult to be drawn; but it was no
more incumbent on him than on his opponents to draw it. They
themselves could not deny that a certain extremity of the evil would
have justified the interposition. Suppose that the distress of the
alienating creditors had been ten times as great as it was; that
instead of two, three, and four shillings in the pound, they had
received a farthing only in the pound; and that the certificates lay
now in the hands of the purchasers in that state, or even at a less
value, was there a member who would rise up and say, that the
purchasers ought to be paid the entire nominal sum, and the original
sufferer be entitled to no indemnification whatever?
Gentlemen had triumphed in the want of a precedent to the
measure. No government, it was said, had interposed to redress
fluctuations in its public paper. But where was the government that
had funded its debts under the circumstances of the American debt?
If no government had done so, there could be no precedent either
for or against the measure, because the occasion itself was
unprecedented. And if no similar occasion had before existed in any
country, the precedent to be set would at least be harmless, because
no similar occasion would be likely to happen in this.
If gentlemen persisted, however, in demanding precedents, he was
happy in being able to gratify them with two, which, though not
exactly parallel, were, on that account, of the greater force, since
the interposition of Government had taken place where the
emergency could less require them.
The first was the case of the Canada bills. During the war which
ended in 1763, and which was attended with a revolution of the
Government in Canada, the supplies obtained for the French army in
that province were paid for in bills of exchange and certificates. This
paper depreciated, and was bought up chiefly by British merchants.
The sum and the depreciation were so considerable as to become a
subject of negotiation between France and Great Britain at the
peace. The negotiations produced a particular article, by which it
was agreed by France that the paper ought to be redeemed, and
admitted by Great Britain that it should be redeemed at a liquidated
value. In the year 1766 this article was accordingly carried into effect
by ministers from the two courts, which reduced the paper in the
hands of the British holders, in some instances, as much as seventy-
five per cent. below its nominal value. It was stated, indeed, by the
reporter of the case, that the holders of the paper had themselves
concurred in the liquidation; but it was not probable that the
concurrence was voluntary. If it was voluntary, it shows that they
themselves were sensible of the equity of the sacrifice.
The other case was of still greater weight, as it had no relation to
war or treaty, and took place in the nation which has been held up
as a model with respect to public credit. In the year 1713, the civil
list of Great Britain had fallen into arrears to the amount of
£500,000. The creditors who had furnished supplies to the
Government had, instead of money, received debentures only from
the respective officers. These had depreciated. In that state, they
were assigned in some instances; in others, covenanted to be
assigned. When the Parliament appropriated funds for satisfying
these arrears, they inserted an express provision in the act, that the
creditors who had been obliged, by the default of Government, to
dispose of their paper at a loss, might redeem it from the assignees
by repaying the actual price, with an interest of six per cent., and
that all agreements and covenants to assign should be absolutely
void. Here then was an interposition on the very principle, that a
Government ought to redress the wrongs sustained by its default,
and on an occasion trivial when compared to that under
consideration; yet it does not appear that the public credit of the
nation was injured by it.
The best source of confidence in Government was the apparent
honesty of its views. The proposition could not possibly be ascribed
to any other motive than this, because the public was not to gain a
farthing by it. The next source was an experienced punctuality in the
payments due from the Government. For this support to public
credit, he relied on what had been experienced by a part of the
foreign creditors; on the provision to be made for the residue; and
on the punctuality which, he flattered himself, would be observed in
all future payments of the domestic creditors. He was more
apprehensive of injury to public credit from such modifications of the
interest of the public debt as some gentlemen seemed to have in
view. In these the public would be the gainer, and the plea of
inability the more alarming, because it was so easy to set up, so
difficult to be disproved, and for which, consequently, the
temptations would be so alluring.
Mr. Seney rose and observed, that it was with reluctance he
attempted to express to the committee his ideas upon a question
which had been so fully and ably discussed. However, as it had been
expected that gentlemen would not, in a case of such magnitude, be
content with merely a silent vote, he rose to declare the reasons
upon which his decision was founded. In doing this, he hoped that
he should not use epithets which might be deemed harsh, or
language which would be offensive; that although the sentiments of
other members should differ from his, he wished so far to respect
those sentiments as to treat them with decency.
He considered the proposition of the gentleman from Virginia (Mr.
Madison) was designed to effect two purposes: the one, a
compensation to the original creditors, who, during the late war, in
times of distress, had loaned money, furnished supplies, and
rendered military services; and who had only received satisfaction
therefor in paper of inconsiderable value, forced on them by the
public, and depreciated by their acts. This class of citizens, he
conceived, had a just and equitable claim for the full difference in
value between that paper, when paid, and specie. The other object
of the proposition alluded to, was, he said, to compensate those
creditors who now hold alienated certificates. Each description of
those creditors had, in his opinion, claims on the public. The first
was founded on an original contract between them and the
Government, part of which only had been complied with, and the
residue still remained undischarged. The other was grounded on
having possession of the paper which contained the promise to pay.
It has been contended that the United States have not ability to pay
both. In this case a question arises: What is, upon the whole, most
just and expedient? Some gentlemen contend, that it is incumbent
on us to make full provision for those who hold the assigned
certificates, without any for the original creditors who have alienated
them. Others think, that the misfortune of Government, in this
respect, should not be felt by either class solely, but be borne by
both. That it is more just to adopt a mode of composition, by which
those creditors should mutually share in this misfortune, and be
mutually benefited by a provision within our power to make; with
those his sentiments accorded. He could not be impressed with the
justice or reason of a measure calculated to make a total sacrifice of
one class of creditors, and full payment to the other class. Such a
step could not, in his opinion, be justified in any distinction or
precedence which existed in their claims. When it was considered
that the original creditors furnished money and supplies, and
rendered services essential to the preservation of their country, and
at a time when its liberties were invaded, and every thing which can
be dear to freemen was in jeopardy and at stake, he could not
apprehend that their claims would be deemed inferior to those of
their rivals. In his opinion, these circumstances entitled them to
superior notice. Believing, however, that the amendment under
consideration would, upon the whole, effect more substantial justice
than any other practicable scheme that had been proposed to the
committee, or which he had heard of, his assent would, therefore,
be given to it.
Tuesday, February 19.
Public Credit.
The House again went into a committee on the report of the
Secretary of the Treasury, Mr. Baldwin in the chair.
Mr. Madison's proposition still under consideration.
Mr. Livermore said he was against any discrimination between the
soldier and other public creditor, who held a public security, made
payable to bearer, and consequently transferable, with intent that
they might be sold, if convenience or necessity should require it.
This had been understood by all parties, as well in America as in
foreign countries, and they had been sold accordingly. The
advocates for discrimination have not denied this; they have only
alleged that the low rate at which the poor soldier or other public
creditor had sold his securities was a sufficient reason for Congress
to interfere and set aside the sale. In opposition to this, he
observed, that persons had a right to buy and sell at such prices as
they could mutually agree upon, provided there was no fraud.
A diamond, a horse, or a lot of ground, might be sold too cheap, or
too dear, and so might any other property; but Government could
not interfere without destroying the general system of law and
justice. Esau had sold his birthright for a mess of pottage, and
heaven and earth had confirmed the sale. The distresses of the
army, both officers and soldiers, at the time they received and sold
their securities, had been painted in too strong colors. They were
not so emaciated by sickness and famine as had been represented.
They were crowned with victory, and received with applause by their
fellow-citizens; and although they had been paid in paper, their loss
had been made up by large bounties, and in other emoluments; so
that, in point of property, they were equal to their fellow-citizens
who had borne the burden of taxes under which many are laboring
to this day. Let them be called brave soldiers, patriotic soldiers, but
not poor soldiers. They ought to be governed by the same system of
justice that governs others; but their contracts ought not to be set
aside out of partiality to them. The case quoted from the statute of
Queen Anne is not applicable to this case, inasmuch as Government
had not originally made the debentures therein mentioned
transferable. Neither did the case of the Canada bills apply; for, as
he understood, those bills were paid to British merchants and to
others who had purchased them.
Mr. Madison.—If paper, or the honor of statues or medals can
discharge the debts of justice, payable in gold or silver, we can not
only exonerate ourselves from those due to the original holders, but
from those of the assignees. So far as paper goes, the latter have
received the compensation. If honor can discharge the debt, they
have received civil honors; look around to the officers of every
Government in the Union, and you find them sharing equal honors
with those bestowed on the original creditors. But, sir, the debt due
in gold and silver is not payable either in honor, appointments, or in
paper.
Gentlemen say it will work injustice; but are we not as much bound
to repair the injustice done by the United States? Yet I do not
believe the assertion has been established by any thing that has
been urged in its support. The gentleman from Maryland (Mr. Stone)
acknowledges that there is a moral obligation to compensate the
original holders; how will they get what he admits is their due? He is
willing to make an effort, by applying the resources of the country to
that purpose; but if we are to judge by the sentiments of other
gentlemen who have spoken on this occasion, we have little to
expect from that quarter. Suppose the debt had depreciated to a
mere trifle, and suppose the sale of the Western Territory had
extinguished the certificates, let me ask, whether, if the United
States had thus exonerated themselves from the obligation to the
assignee, whether the claim of the original holder would not still
remain in its full force in a moral view? But believing the point of
justice to be exhausted, I will just add one remark upon the
practicability. The transferred certificates, generally, will show the
names of the original holders, and here there is no difficulty. With
respect to those granted to the heads of either of the five great
departments, the books of the Treasurer of Loans, as well as the
accounts of those departments now in the Treasury, will designate,
with a great degree of accuracy, and this may be followed up by the
usual mode of obtaining evidence; and I believe every security may
be provided against fraud in this case that was provided in the case
of the commissioners who were sent into the respective States for
ascertaining and liquidating the claims of individuals. That there will
be some difficulty I admit, but it is enough for me that it is not
insuperable; and I trust, with the assistance which the cause of
equity and justice will ever obtain from the members of the National
Legislature, they will easily be surmounted.
Public Credit.
The House then resolved itself into a committee on the Report of the
Secretary of the Treasury, Mr. Baldwin in the chair.
Mr. Madison's proposition still under consideration.
Mr. Page.—As the worthy and eloquent member who replied to me
did not answer the questions I put to the committee, I suppose, he
either did not hear them, did not understand me, or could not
answer them. I hope, before the committee decide, they will attempt
at least to resolve them. I asked, where is the injustice of the State's
complying with its engagements made to the first holders of
certificates as far as the case admits? Where is the justice of doing
more for the assignee than he or his assignor expected could or
would be done? Where is the breach of faith in Government, if it
paid its whole debt with justice, blended with mercy? Where is the
interference in contracts, when the proposition is to comply sacredly,
as far as the case will admit, with the contracts between a State and
its creditors? I asked, is not the assignment of certificates confirmed
by the motion? Does it not give to the assignee the very thing
stipulated to be given, that is, whatever sum Government shall be
pleased to pay for the certificates, for that was the condition of the
assignment? And is not the sum now proposed more than either the
first or last holder, till within these few days, supposed would be paid
him? I asked also, ought not an honest assignee to be pleased that
Government intends to do that justice to his assignor which he
ought to do himself, were the whole payment made to him? I asked,
of what is the assignee deprived but of his late sanguine
expectations? I asked, whether the proposition before us does not
rather establish confidence in Government than the contrary? For, sir,
to make use of the comparison which has been often made here
between the State and an obligor on a bond, what could give more
credit to any man's bonds than to find that, though they had
depreciated to half a crown in the pound, he paid the whole twenty
shillings; ten shillings to the assignee, who had given but two
shillings and sixpence, and ten to the obligee who had sold at so
great a loss?
It is true Congress may, consistently with the rules of common law
courts, pay the bearer and take no notice of the creditors; but were
a Court of Equity instituted to decide on the case of certain
speculators, how would they decide? Government, in the most
solemn manner, pledged itself to make compensation to the soldiers,
have they done it? Instead of doing this, certain persons, who took
advantage of their ignorance and their poverty, bought up the
evidence of their debt at one-eighth of the nominal value; and in
some States these very men had drawn what constituted the
principal of the purchase with six per cent. interest in three years.
In what does the case differ between the depreciated paper and the
certificates? Paper money was redeemed at forty for one, as well to
the last as the first holder; the same principle would lead to give the
last holder of the certificate the depreciated value at which he
bought it. But we propose to work no injustice, we give the first
holder, if he is the holder still, the full value stipulated. It would not
be injustice to consider the assignee, as having paid what he
advanced, in consequence of his confidence in Government, on
account of that Government; and that the Government ought to
repay him what he so advanced; having repaid that sum, the
balance ought to go to the credit of the assignee. I am willing, on
this consideration, to call the speculator the friend and supporter of
the Government, who kindly lent us when in need, two shillings and
sixpence in every pound, to advance to the poor soldier. If
certificates are the evidence of the debt, it proves, sir, that the
balance is due to him in whose name it issued. This is the day of
payment, and we must pay accordingly; and here permit me to
remark, in reply to the observation of the gentleman from New
Hampshire, (Mr. Livermore,) that Jacob was punished for his fraud,
but for his faith enjoyed the promise; even so let us regard those
who had so much confidence in us as to advance two shillings and
sixpence to the distressed soldier.
Mr. Heister was in hopes this question would be postponed for the
present, in order to go into a consideration of the ways and means:
when, if it appeared that the United States were incapable of making
full provision, it might be considered, whether one deviation would
not authorize the other? If any gentleman would make a motion to
that effect, he would second him.
The question was now taken on Mr. Madison's proposition for a
composition, and it passed in the negative; yeas 13, nays 36.[35]
On Slavery.
The House again resolved itself into a Committee of the Whole on
the Report of the committee, to whom was referred the memorial of
the people called Quakers, &c., Mr. Benson in the chair.
The question of order was put, when it was determined that Mr.
Tucker's last amendment was not in order.
The report was then taken up by paragraphs. The first proposition
being read,
Mr. White moved that it be struck out. He did this, he said, because
he was against entering into a consideration at this time of the
powers of Congress. He thought it would be time enough for this
when the powers are called in question. He then read the next,
which he said was entirely unnecessary, as it contains nothing more
than what is contained in express terms in the constitution. He
passed on to the third, which he said was equally unnecessary; and
to the fourth, which was provided for by the constitution. He said,
that he should agree to the fifth and sixth, with certain
modifications. Agreeable to this idea, he offered those two in a
different form. He disagreed to the seventh proposition, as
unnecessary and improper. He concluded by observing, that his wish
was to promote the happiness of mankind—and among the rest
those who are the objects of the present consideration—but this he
wished to do in conformity to the principles of justice and with a due
regard to the peace and happiness of others; he would contribute all
in his power to their comfort and well-being while in a state of
slavery; but he was fully of opinion that Congress has no right to
interfere in the business, any further than he proposed by the two
propositions as modified. He did not, however, anticipate the
difficulties from a total prohibition which some gentlemen seem to
apprehend—and if Congress had it in their power to interdict this
business at the present moment, he did not think the essential
interests of the Southern States would suffer. Twenty years ago, he
supposed the idea he now suggested would have caused universal
alarm. Virginia, however, about twelve years since, prohibited the
importation of negroes from Africa, and the consequences
apprehended never were realized; on the contrary, the agriculture of
that State was never in a more flourishing situation.
Mr. Hartley.—I have the honor to be one of the committee on the
memorials, and will, with the leave of this committee, mention some
particulars which took place in the course of the investigation of the
business. He premised that he was sorry that the question of right
had been brought forward yesterday—and was not a little surprised
to hear the cause of slavery advocated in that House, and language
held towards the petitioners which his experience had never shown
to be Parliamentary—he read some memorandums taken in
committee, and had particular reference to a law passed in Grenada,
which he applauded for its humanity, and truly benevolent spirit. He
reprobated the illiberal treatment which the memorialists had
received, and asserted that they were friends to the constitution,
and that on the present occasion they came forward from the most
laudable motives, from a wish to promote the happiness of mankind;
that their conduct, so far from meriting censure, deserved, and
would receive, the applause of the civilized world.
Mr. Brown, in a considerable speech, advocated the motion of Mr.
White. He enlarged on the pernicious consequences that may be
expected to flow from the interference of Congress; he pointed out
the effects which had resulted from the interposition of the Quakers,
by which the prospects of the Southern States in slaves had been
rendered very precarious—and if Congress should adopt the report
as it stands, the consequences would be pernicious in the highest
degree. The negro property will be annihilated. The emancipation of
slaves will be effected in time, it ought to be a gradual business; but
he hoped that Congress would not, to gratify people who never had
been friendly to the independence of America, precipitate the
business to the great injury of the Southern States.
Mr. Burke entered into a very extensive consideration of the subject.
He gave an account of the humane treatment which the slaves of
the Southern States received, their habitations, families, children,
privileges, &c. He then showed that their emancipation would tend
to make them wretched in the highest degree. He animadverted with
great freedom on the past and present conduct of the Quakers. He
denied that they were the friends of freedom; he said, that during
the late war, they were for bringing this country under a foreign
yoke; they descended to the character of spies; they supplied the
enemy with provisions; they were guides and conductors to their
armies; and whenever the American army came into their
neighborhood, they found themselves in an enemy's country. Mr.
Burke was proceeding in this strain, when he was interrupted by
being called to order. A warm altercation ensued, and in the midst of
it, a motion was made that the committee rise. This motion was
negatived, and Mr. Burke added a few more observations on the
injustice of the measure of interference, as it respected the property
of the Southern States.
Mr. Smith (of South Carolina) said he lamented much that this
subject had been brought before the House; that he had deprecated
it from the beginning, because he foresaw that it would produce a
very unpleasant discussion; that it was a subject of a nature to
excite the alarms of the Southern members, who could not view,
without anxiety, any interference in it on the part of Congress. He
remarked, that as they were resolved into a Committee of the Whole
on the powers of Congress respecting slavery and the slave trade, in
consequence of certain memorials from the people called Quakers
and the Pennsylvania Society for the abolition of slavery, the whole
subject, as well as the contents of these memorials, was under
consideration. He should therefore enter into the business at large,
and offer some comments on the contents of the memorial.
The memorial from the Quakers contained, in his opinion, a very
indecent attack on the character of those States which possess
slaves. It reprobates slavery as bringing down reproach on the
Southern States, and expatiates on the detestation due to the
licentious wickedness of the African trade, and the inhuman tyranny
and bloodguiltiness inseparable from it. He could not but consider it
as calculated to fix a stigma of the blackest nature on the State he
had the honor to represent, and to hold its citizens up to public view
as men divested of every principle of honor and humanity.
Considering it in that light, he felt it incumbent on him not only to
refute those atrocious calumnies, but to resent the improper
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
ebookbell.com