You are on page 1of 7

Cambridge University Press

978-1-107-54673-8 – Cambridge International AS and A Level Computer Science


Sylvia Langfield Dave Duddell
Frontmatter
More information

Sylvia Langfield and Dave Duddell

Cambridge International
AS and A level

Computer
Science
Coursebook

© in this web service Cambridge University Press www.cambridge.org


Cambridge University Press
978-1-107-54673-8 – Cambridge International AS and A Level Computer Science
Sylvia Langfield Dave Duddell
Frontmatter
More information

CAMBRIDGE
UNIVERSITY PRESS

University Printing House, Cambridge CB2 8BS, United Kingdom


Cambridge University Press is part of the University of Cambridge.

It furthers the University’s mission by disseminating knowledge in the pursuit of


education, learning and research at the highest international levels of excellence.

www.cambridge.org

Information on this title: education.cambridge.org

© Cambridge University Press 2015

This publication is in copyright. Subject to statutory exception


and to the provisions of relevant collective licensing agreements,
no reproduction of any part may take place without the written
permission of Cambridge University Press.

First published 2015

Printed in the United Kingdom by Latimer Trend

A catalogue record for this publication is available from the British Library

ISBN 978-1-107-54673-8 Paperback

Cambridge University Press has no responsibility for the persistence or accuracy


of URLs for external or third-party internet websites referred to in this publication,
and does not guarantee that any content on such websites is, or will remain,
accurate or appropriate. Information regarding prices, travel timetables, and other
factual information given in this work is correct at the time of first printing but
Cambridge University Press does not guarantee the accuracy of such information
thereafter.
...........................................................................................................................................................................................
NOTICE TO TEACHERS IN THE UK
It is illegal to reproduce any part of this work in material form (including
photocopying and electronic storage) except under the following circumstances:
(i) where you are abiding by a licence granted to your school or institution by the
Copyright Licensing Agency;
(ii) where no such licence exists, or where you wish to exceed the terms of a licence,
and you have gained the written permission of Cambridge University Press;
(iii) where you are allowed to reproduce without permission under the provisions
of Chapter 3 of the Copyright, Designs and Patents Act 1988, which covers, for
example, the reproduction of short passages within certain types of educational
anthology and reproduction for the purposes of setting examination questions.
...........................................................................................................................................................................................

The past paper questions on pages 107-108 and 316 are taken from the 9608 Specimen papers 1 and 3 respectively
and are reproduced with the permission of Cambridge International Examinations.

All other examination-style questions and comments that appear in this book were written by the authors.

© in this web service Cambridge University Press www.cambridge.org


Cambridge University Press
978-1-107-54673-8 – Cambridge International AS and A Level Computer Science
Sylvia Langfield Dave Duddell
Frontmatter
More information

Contents

Contents
Introduction v

PART 1 THEORY FUNDAMENTALS


Chapter 1 Information representation 2
Chapter 2 Communication and Internet technologies 18
Chapter 3 Hardware 36
Chapter 4 Logic gates and logic circuits 49
Chapter 5 Processor fundamentals 59
Chapter 6 Assembly language programming 69
Chapter 7 System software 78
Chapter 8 Data security, privacy and integrity 88
Chapter 9 Ethics and ownership 99
Chapter 10 Database and data modelling 109

PART 2 FUNDAMENTAL PROBLEM- iii


SOLVING AND PROGRAMMING SKILLS
Chapter 11 Algorithm design and problem solving 125
Chapter 12 Stepwise refinement and structure charts 155
Chapter 13 Programming and data representation 176
Chapter 14 Structured programming 212
Chapter 15 Software development 228

PART 3 ADVANCED THEORY


Chapter 16 Data representation 246
Chapter 17 Communication and Internet technologies 258
Chapter 18 Boolean algebra and logic circuits 270
Chapter 19 Processor and computer architecture 282
Chapter 20 System software 287
Chapter 21 Security 303
Chapter 22 Monitoring and control systems 310

© in this web service Cambridge University Press www.cambridge.org


Cambridge University Press
978-1-107-54673-8 – Cambridge International AS and A Level Computer Science
Sylvia Langfield Dave Duddell
Frontmatter
More information

Cambridge International AS and A level Computer Science

PART 4 FURTHER PROBLEM-SOLVING


AND PROGRAMMING SKILLS
Chapter 23 Computational thinking and problem-solving 317
Chapter 24 Algorithm design methods 337
Chapter 25 Recursion 347
Chapter 26 Further programming 356
Chapter 27 Object-oriented programming (OOP) 368
Chapter 28 Low level programming 394
Chapter 29 Declarative programming 405
Chapter 30 Software development 420

Glossary 430
Index 434
Acknowledgements 442

iv

© in this web service Cambridge University Press www.cambridge.org


Cambridge University Press
978-1-107-54673-8 – Cambridge International AS and A Level Computer Science
Sylvia Langfield Dave Duddell
Frontmatter
More information

Introduction

Introduction
This full-colour, illustrated textbook has been written by experienced authors specifically for
the Cambridge International AS and A Level Computer Science syllabus (9608).
The presentation of the chapters in this book reflects the content of the syllabus:
• The book is divided into four parts, each of which is closely matched to the corresponding
part of the syllabus.
• Each chapter defines a set of learning objectives which closely match the learning
objectives set out in the syllabus.
• The syllabus defines two assessment objectives: A01 Knowledge with understanding and
A02 Skills. Papers 1 and 3 have a major focus on A01 and Papers 2 and 4 have a major
focus on A02. The chapters in Parts 1 and 3 have been written with emphasis on the
promotion of knowledge and understanding. The chapters in Parts 2 and 4 have been
written with an emphasis on skill development.
The chapters in Parts 1 and 3 have a narrative. We would encourage students to read the
whole chapter first before going back to revisit the individual sections.
The chapters in Parts 2 and 4 contain many more tasks. We would encourage students to
approach these chapters step-by-step. Whenever a task is presented, this should be carried
out before progressing further.
In particular, Chapter 11 (Algorithm design and problem-solving) may be worked through in
v
parallel with Chapter 13 (Programming and data representation). For example, Task 13.03
is based on Worked Example 11.03. After studying this worked example, students may wish
to cover the first part of Chapter 13 and write the program for Task 13.03. This will give the
student the opportunity to test their understanding of an algorithm by implementing it in
their chosen programming language. Then further study of Chapter 11 is recommended
before attempting further tasks in Chapter 13.

© in this web service Cambridge University Press www.cambridge.org


Cambridge University Press
978-1-107-54673-8 – Cambridge International AS and A Level Computer Science
Sylvia Langfield Dave Duddell
Frontmatter
More information

Cambridge International AS and A level Computer Science

How to use this book: a guided tour


Chapter – each chapter begins with Key Term – clear and
a short list of the learning objectives straightforward explanations of
and concepts that are explained in it. the most important terms in each
2
chapter.
Chapter 1
Information Representation KEY TERMS

Byte: a group of eight bits treated as a single unit


Learning objectives
By the end of this chapter you should be able to:
■ ■ show understanding of how sound is represented and
systems encoded
■ show understanding of, and be able to represent, ■ show understanding of the characteristics of video streams
character data in its internal binary form ■ show understanding of how digital data can be
■ show understanding of how data for a bitmapped or compressed.
vector graphic image is encoded

Task – exercises
for the student to Question – questions
test their skills. for the student to test
their knowledge and
TASK 1.01
Convert the denary number 374 into a hexadecimal number.
understanding.
Convert the hexadecimal number 3A2C to a denary number.

Discussion Point – discussion points Question:


Construct a partial drawing list for the graphic shown in figure 1.06. You can take
intended for class discussion. measurements from the image and use the bottom left corner of the box as the origin of a
coordinate system. You can invent your own format for the drawing list.
vi

Discussion Point
What is the two’s complement of the binary value 1000? Are you surprised by this?

Extension Question – extended questions for


consideration of more advanced aspects or topics
Extension Question: beyond the immediate scope of the Cambridge
Graphic files can be stored in a number of formats. For example, JPEG, GIF, PNG and TIFF are
just a few of the possibilities. What compression techniques, if any, do these use? International AS and A Level syllabus.

Worked Example – step-by-step examples


Tip – quick notes to highlight
of solving problems or implementing specific
key facts and important
techniques.
points.

! TIP
Converting a negative number expressed in two’s complement form to the
corresponding denary number.
For multiples of bytes, the terminology used has recently changed. Traditionally, computer
scientists have used the terminology kilobyte, megabyte, gigabyte etc. in a way that conflicted Consider the two’s complement binary number 10110001.
with the definition of these prefixes established by the International System of Units (SI).
Following the SI convention, one kilobyte would represent 1000 bytes. Computer scientists Method 1. Convert to the corresponding positive binary number then find the denary
have used one kilobyte to represent 1024 bytes. There have been a number of variations on value
how this was written, for example Kbyte, KB or kB but the basic contradiction remained. In
Converting to two’s complement leaves unchanged the 1 in the least significant bit
order to resolve this unsatisfactory situation, the International Electrotechnical Commission
(IEC) in 1998 proposed a new set of definitions for such quantities. 1024 bytes is now identified
position then changes all of the remaining bits to produce 01001111.
as one kibibyte where the kibi can be considered as representing kilobinary. This proposal has
been accepted by other international standards bodies.

© in this web service Cambridge University Press www.cambridge.org


Extension Question 1.01
Graphic files can be stored in a number of formats. For example, JPEG, GIF, PNG and TIFF are
just a few ofPress
Cambridge University the possibilities. What compression techniques, if any, do these use?
978-1-107-54673-8 – Cambridge International AS and A Level Computer Science
If the image coding for a video is to be compressed, one approach is to tackle the spatial
Sylvia Langfield Dave Duddell
Frontmatterredundancy in individual frames using techniques applicable to an image file. However, this
is unlikely to be an efficient technique because, in general, one frame is very similar to the
More information
preceding one. It will be more effective to tackle this temporal redundancy by changing the
frame by frame coding to one which mainly records differences between adjacent frames.
A video contains images and sound but these do not go to the same part of any receiving and
displaying system. Clearly the audio and visual parts of a video must be handled independently
but in a way that guarantees synchronisation. The solution to this is to package the audio and
visual components in what is known as a multimedia container format. This concept is currently
being developed by several different organisations or companies. The use is not restricted to
one video file and one sound file. Rather, one multimedia container file will have many audio
Summary
and video streams plus other streams, perhaps for subtitles or chapter headings.
● A binary code or a binary number can be documented as a hexadecimal number.
● Internal coding of signed integers is usually based on a two’s complement representation.
● BCD is a convenient coding scheme for single denary digits.
● ASCII and Unicode are standardised coding schemes for text characters.

Summary
An image can be stored either in a vector graphic file or in a bitmap file.

An ADC works by sampling a continuous waveform.


● A binary code compression


● Lossless or a binary allows
number can befile
an original documented as by
to be recovered a hexadecimal
a decoder; lossynumber.
compression
16 irretrievably loses some information.
● Internal coding of signed integers is usually based on a two’s complement representation.
● BCD is a convenient coding scheme for single denary digits.
● ASCII and Unicode are standardised coding schemes for text characters.
● An image can be stored either in a vector graphic file or in a bitmap file.
● An ADC works by sampling a continuous waveform.
● Lossless
Summary compression
Checklist allows
– at the endanoforiginal
each file to be recovered by a decoder; lossy compression
chapter
irretrievably loses some information.
to review what the student has learned.

vii
Exam-style Questions
1 A file contains binary coding. The following are two successive bytes in the file:

10010101 00110011

a One possibility for the information stored is that the two bytes together represent one unsigned integer binary
number.

i Give the denary number corresponding to this. Show your working. [2]
ii Give the hexadecimal number corresponding to this. Show your working. [2]

b Give one example of when a hexadecimal representation is used. [1]

Exam-style Questions – Exam-style questions


for the student to test their skills, knowledge and
understanding at the end of each chapter

© in this web service Cambridge University Press www.cambridge.org

You might also like