As Computer Science - Complete Notes
As Computer Science - Complete Notes
Complete Notes
For Details:
Sharjeel Arif: 0333 – 5752253
Office 22- 23, First Floor Al-babar Center, F-8 markaz, Islamabad
Table of Contents
1 Data Representation 1
2 Communication 30
3 Hardware 59
4 Processor Fundamentals 83
8 Databases 146
26 25 24 23 22 21 20
64 32 16 8 4 2 1
1 1 0 0 1 1 0
Denary to Binary:
(131)10 ----> (?)2
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
1 0 0 0 0 0 1 1
Guide:
Step 1:
Turn the 128 bit on as it is the immediate number that's less than 131
Now subtract 128 from 131
131 - 128 = 3
Step 2:
Now turn the 2 bit on as it is the immediate number that's less than 3
Subtract 2 from 3
3-2=1
Step 3:
Now turn the 1 bit on
Subtract 1-1 = 0
Step 4:
Write down the binary
131 = 10000011
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 3
AS Computer Science - 9618 Chapter 1 : Data Representation Instructor: Nadia Arif
Guide:
Make a group of four bits starting from the right hand side
0001 = 1
0011 = 3
1011 = 11 --> B (In hexa decimal any number greater than 9 and less
than 15 is written in alphabets)
A = 10
B = 11
C = 12
D = 13
E = 14
F = 15
So,
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 4
AS Computer Science - 9618 Chapter 1 : Data Representation Instructor: Nadia Arif
100111011 = 13B
Hexa to Binary
(9DC)16 ----> ( ? )2
9 D C
9 13 12
1001 1101 1100
9DC = 100111011100
Decimal to Hexa:
(119)10 ----> (?)16
0111 = 7
0111 = 7
Step 3:
1110111 = 77
Hexadecimal to Decimal:
Method 1:
Step 1:
Write down the binary of each bit separately
B = 11 = 1001
D = 13 = 1101
5 = 0101
Step 2:
convert the binary to decimal
BD5 = 1010 1100 0101
211 210 29 28 27 26 25 24 23 22 21 20
2048 1024 512 256 128 64 32 16 8 4 2 1
1 0 1 0 1 1 0 0 0 1 0 1
BD5 = 2757
Method 2:
256 x 11 = 2,816
13 x 16 = 208
5x1=5
Error codes:
Error codes are often shown as hexadecimal values. These numbers refer
to the memory location of the error and are usually automatically
generated by the computer.
NN – NN – NN – DD – DD – DD
or
NN:NN:NN:DD:DD:DD
where the first half (NN – NN – NN) is the identity number of the
manufacturer of the device and the second half (DD – DD – DD) is
the serial number of the device.
Example 1:
If we now shift the bits in this register one place to the left, we obtain:
128 64 32 16 8 4 2 1
0 0 1 0 1 0 1 0
21 x 2 = 42
Example 2:
If we now shift the bits in this register one place to the right, we
obtain:
128 64 32 16 8 4 2 1
0 1 1 0 0 1 0 0
128 64 32 16 8 4 2 1
0 1 1 1 0 0 0 1
01110001 = 10001110
10001110
+ 1
10001111
-113 = 10001111
Proof:
-128 + 8 + 4 +2 +1 = -113
0000=0 0101=5
0001=1 0110=6
0010=2 0111=7
0011=3 1000=8
0100=4 1001=9
Uses of BCD:
The Unicode consortium was set up in 1991. Version 1.0 was published with
five goals; these were to:
create a universal standard that covered all languages and all
writing systems
produce a more efficient coding system than ASCII » adopt
uniform encoding where each character is encoded as 16-bit or 32-
bit code
create unambiguous encoding where each 16-bit and 32-bit value
always represents the same character
reserve part of the code for private use to enable a user to assign
codes for their own characters and symbols
The number of bits per sample is known as the sampling resolution (also
known as the bit depth).
Sampling rate is the number of sound samples taken per second. This is
measured in hertz (Hz), where 1Hz means ‘one sample per second’.
So how is sampling used to record a sound clip?
the amplitude of the sound wave is first determined at set time
intervals (the sampling rate)
this gives an approximate representation of the sound wave
each sample of the sound wave is then encoded as a series of
binary digits.
Using a higher sampling rate or larger resolution will result in a more
faithful representation of the original sound source. However, the higher
the sampling rate and/or sampling resolution, the greater the file size.
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 16
AS Computer Science - 9618 Chapter 1 : Data Representation Instructor: Nadia Arif
Benefits Drawbacks
larger dynamic range produces larger file size
better sound quality takes longer to transmit/download
music files
less sound distortion requires greater processing power
Frame rate: When recording a video the frame rate refers to the
number of frames recorded per second.
1.2.3 Representation of (bitmap) images
Bitmap images are made up of pixels (picture elements); an image is
made up of a two-dimensional matrix of pixels.
Each pixel can be represented as a binary number, and so a bitmap
image is stored in a computer as a series of binary numbers, so that:
a black and white image only requires 1 bit per pixel – this means
that each pixel can be one of two colours, corresponding to either 1
or 0
if each pixel is represented by 2 bits, then each pixel can be one
of four colours (22 = 4), corresponding to 00, 01, 10, or 11
if each pixel is represented by 3 bits then each pixel can be one of
eight colours (23 = 8), corresponding to 000, 001, 010, 011, 100, 101,
110, 111.
The number of bits used to represent each colour is called the colour
depth. An 8 bit colour depth means that each pixel can be one of 256
colours
Drawback:
The main drawback of using high resolution images is the increase
in file size.
As the number of pixels used to represent the image is increased,
the size of the file will also increase.
This impacts on how many images can be stored on, for example, a
hard drive.
It also impacts on the time to download an image from the
internet or the time to transfer images from device to device.
A certain amount of reduction in resolution of an image is possible
before the loss of quality becomes noticeable.
they do not require large file size since because of the use of pixels
it is made up of simple geometric shapes (which give very accurate
designs), the file size is very
large
because the number of geometric since images are built up pixel
shapes is limited, vector graphics are not by pixel, the final image is
usually very realistic usually very realistic
file formats are usually .svg, .cgm, .odg file formats are usually .jpeg,
.bmp, .png
sample rate (in Hz) × sample resolution (in bits) × length of sample (in
seconds)
Example 1:
Example 2:
Example 3:
An audio CD has a sample rate of 44100 and a sample resolution of
16bits. The music being sampled uses two channels to allow for stereo
recording. Calculate the file size for a 60-minute recording.
Size of file = sample rate (in Hz) × sample resolution (in bits) ×
length of sample (in seconds)
Size of sample = (44100 × 16 × (60 × 60)) = 2540160000bits
Multiply by 2 since there are two channels being used =
5080320000bits
Divide by 8 to find number of bytes = (5080320000)/8 =
635040000
Divide by 1024 × 1024 to convert to MiB = 635 040 000 / 1 048
576 = 605MiB.
Lossy files are smaller than lossless files which is of great benefit when
considering storage and data transfer rate requirements. Common lossy
file compression algorithms are:
MPEG-3 (MP3) and MPEG-4 (MP4)
JPEG.
MP3 files are used for playing music on computers or mobile phones.
This compression technology will reduce the size of a normal music file
by about 90%.
This is done using file compression algorithms that use perceptual music
shaping.
For example:
removal of sounds outside the human ear range
if two sounds are played at the same time, only the louder one can
be heard by the ear, so the softer sound is eliminated. This is
called perceptual music shaping.
MP4 files are slightly different to MP3 files. This format allows the
storage of multimedia files rather than just sound – music, videos,
photos and animation can all be stored in the MP4 format. As with
MP3, this is a lossy file compression format, but it still retains an
acceptable quality of sound and video.
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 26
AS Computer Science - 9618 Chapter 1 : Data Representation Instructor: Nadia Arif
Movies, for example, could be streamed over the internet using the MP4
format without losing any real discernible quality.
JPEG:
When a camera takes a photograph, it produces a raw bitmap file which
can be very large in size. These files are temporary in nature. JPEG is a
lossy file compression algorithm used for bitmap images.
The JPEG file reduction process is based on two key concepts:
human eyes don’t detect differences in colour shades quite as well
as they detect differences in image brightness
by separating pixel colour from brightness, images can be split into
8 × 8 pixel blocks
Coloured images
2.1 - Networking:
servers.
The server dictates which users are able to access which files.
computer.
The model uses central security databases which control access to the shared
resources.
Once a user is logged into the system, they will have access to only those
This model offers the most stable system, for example, if someone deletes a
shared resource from the server, the nightly back-up would restore the
deleted resource
Client-server networks can become bottlenecked if there are several client
Advantages:
Central storage and management of data files, thus enabling other network
users to access files
allowing users to share information without the need for offline devices (such
as a memory stick)
allowing any computer to be configured as the host machine and act as the
file server (note that the server could be a storage device (such as SSD or
HDD) that could also serve as a remote storage device for other computers,
thus allowing them to access this device as if it were a local storage device
attached to their computer).
The company requires its data to be free from accidental loss (in other
Peer-to-peer model:
On a peer-to-peer network, each node joins the network to allow
the provision of services to all other network users; the services available are
Disadvantages:
Peer-to-peer offers little data security since there is no central security
security aspect since this gives them some kind of control. However, there
are no real authentication procedures.
Network Topologies:
bus networks
star networks
mesh networks
hybrid networks
Bus networks
A bus network topology uses a single central cable to which all computers
and devices are connected.
It is easy to expand and requires little cabling.
Data can only travel in one direction; if data is being sent between devices
then other devices cannot transmit.
Bus networks are typically peer-to-peer
Advantages Disadvantages
Even if one node fails, the If the main cable fails, the whole
remainder of the network network goes down.
continues to function. The performance of the network
It is easy to increase the size deteriorates under heavy loading.
of the network by adding The network is not secure since
additional nodes. each packet passes through every
node.
Star networks:
A star network topology uses a central hub/switch and each
computer/device is connected to the hub/switch.
Data going from host to host is directed through the central
hub/switch.
Advantages: Disadvantages:
Data collisions are greatly reduced due The initial installation costs are
to the topology. high.
It is a more secure network since If the central hub/switch fails,
security methods can be applied to the then the whole network goes down.
central node and packets only travel to
nodes with the correct address.
It is easy to improve by simply
installing an upgraded hub.
If one of the connections is broken it
only affects one of the nodes.
Mesh networks:
There are two types of mesh network topologies: routing and flooding.
Routing works by giving the nodes routing logic (in other words, they
act like a router) so that data is directed to its destination by the
shortest route and can be re-routed if one of the nodes in the route
has failed.
Flooding simply sends the data via all the nodes and uses no routing
logic, which can lead to unnecessary loading on the network.
Advantages: Disadvantages:
It is easy to identify where faults on the A large amount of cabling is
network have occurred. needed, which is expensive
and time consuming.
Any broken links in the network do not Set-up and maintenance is
affect the other nodes. difficult and complex.
Good privacy and security, since packets
travel along dedicated routes.
The network is relatively easy to expand.
Hybrid networks:
A hybrid network is a mixture of two or more different topologies
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 40
AS Computer Science - 9618 Chapter 2 : Communication Instructor: Nadia Arif
Hybrid cloud is a combination of private and public clouds. Some data resides
in the private cloud and less sensitive/less commercial data can be accessed
from a public cloud storage provider.
Pros of using cloud storage Cons of using cloud storage
Wireless networking
It is easier to expand networks and is not necessary to connect devices
using cables.
Devices have increased mobility, provided they are within range of the
WAPs.
Increased chance of interference from external sources.
Data is less secure than with wired systems; it is easier to intercept
radio waves and microwaves than cables so it is essential to protect
data transmissions using encryption.
Data transmission rate is slower than wired networks (although it is
improving).
Signals can be stopped by thick walls (in old houses, for example) and
signal strength can vary, or ‘drop out’.
Wired networking
More reliable and stable network (wireless connectivity is often
subjected to interference).
Data transfer rates tend to be faster with no ‘dead spots’.
Tends to be cheaper overall, in spite of the need to buy and install
cable.
Devices are not mobile; they must be close enough to allow for cable
connections.
Lots of wires can lead to tripping hazards, overheating of connections
(potential fire risk) and disconnection of cables during routine office
cleaning.
Hub :
Hubs are hardware devices that can have a number of devices or
computers connected to them.
They are often used to connect a number of devices to form a local
area network (LAN), for example a star network .
A hub’s main task is to take any data packet (a group of data being
transmitted) received at one of its ports and then send the data to
every computer in the network.
Using hubs is not a very secure method of data distribution and is also
wasteful of bandwidth.
Switch :
Switches are similar to hubs, but are more efficient in the way they
distribute the data packet.
As with hubs, they connect a number of devices or computers
together to form a LAN (for example, a star network).
However, unlike a hub, the switch checks the data packet received
and works out its destination address (or addresses) and sends the data
to the appropriate computer(s) only.
This makes using a switch a more secure and efficient way of
distributing data.
Each device or computer on a network has a media access control
(MAC) address which identifies it uniquely.
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 44
AS Computer Science - 9618 Chapter 2 : Communication Instructor: Nadia Arif
Data packets sent to switches will have a MAC address identifying the
source of the data and additional addresses identifying each device
which should receive the data. Note that switches can be wired or
wireless devices.
Repeater:
When signals are sent over long distances, they suffer attenuation or
signal loss.
Repeaters are devices which are added to transmission systems to boost
the signal so it can travel greater distances.
They amplify signals on both analogue (copper cable) and digital (fibre
optic cable) communication links
Bridge:
Bridges are devices that connect one LAN to another LAN that uses
the same protocol (communication rules).
They are often used to connect together different parts of a LAN so
that they can function as a single LAN.
Router:
Routers enable data packets to be routed between the different
networks for example, to join a LAN to a WAN.
The router takes data transmitted in one format from a network
(which is using a particular protocol) and converts the data to a
It also does the reverse and converts data received over the analogue
network into digital data which can be understood by the computer
Routers Gateways
forward packets of data from convert one protocol (or data format)
one network to another; routers to another protocol (format) used in
read each incoming packet of a different network
data and decide where to forward
the packet
can route traffic from one convert data packets from one
network to another network protocol to another; they act as an
entry and exit point to networks
can be used to join LANs translate from one protocol to
together to form a WAN another
(sometimes called brouters) and
also to connect a number of
LANs to the internet
offer additional features such as do not support dynamic routing
dynamic routing (ability to
forward data by different routes)
Network interface card (NIC):
A network interface card (NIC) is needed to allow a device to connect
to a network (such as the internet).
It is usually part of the device hardware and frequently contains the
MAC address generated at the manufacturing stage.
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 47
AS Computer Science - 9618 Chapter 2 : Communication Instructor: Nadia Arif
Ethernet:
Ethernet is a protocol used by many wired LANs.A network using Ethernet
is made up of:
a node (any device on the LAN)
medium (path used by the LAN devices, such as an Ethernet cable)
frame (data is transmitted in frames which are made up of source
address and destination address – the addresses are often the MAC
address).
Collisions:
Ethernet supports broadcast transmission (communications where pieces
of data are sent from sender to receiver) and are used to send
messages to all devices connected to a LAN.
The risk is that two messages using the same data channel could be
sent at the same time, leading to a collision.
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 48
AS Computer Science - 9618 Chapter 2 : Communication Instructor: Nadia Arif
Bit streaming:
Bit streaming is a contiguous sequence of digital bits sent over the
internet or a network that requires a high speed data communication
link (such as fast broadband).
Since bit streaming often involves very large files (such as video) it is
necessary for the files to undergo some data compression before
transmission.
It is also necessary to have some form of buffering to ensure smooth
playback of the media files.
The data transmission rate from the file server (containing the video,
for example) to the buffer must be greater than the rate at which
data is transmitted from buffer to media player.
The larger the buffer, the better the control over the bit rate being
sent to the media player
2.2 - The Internet
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 49
AS Computer Science - 9618 Chapter 2 : Communication Instructor: Nadia Arif
Internet
The internet is a massive network of networks which are made up of
various computers and other electronic devices.
It stands for interconnected network.
The internet makes use of transmission control protocol
(TCP)/internet protocol (IP)
Drawback:
IPv4 system provides insufficient address range.
For example, a user with a medium sized network (class B) might have
284 host machines and their class B licence allows them 216.
This means several of the allocated host IDs will not be used, which is
wasteful.
Solution:
Classless inter-domain routing (CIDR) reduces this problem by
increasing the flexibility of the IPv4 system.
A suffix is used, such as 192.30.250.00/18, which means 18 bits will be
used for the net ID and the last 14 bits will be used for the host ID
IPv6 addressing:
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 53
AS Computer Science - 9618 Chapter 2 : Communication Instructor: Nadia Arif
Note how a colon (:) rather than a decimal point (.) is used here. It has been
designed to allow the internet to grow in terms of number of hosts and the
potential amount of data traffic.
Sub-netting
CIDR is actually based on sub-netting and the two are similar in many
ways.
Sub-netting divides a LAN into two or more smaller networks.
This helps reduce network traffic and can also hide the complexity of
the overall network.
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 54
AS Computer Science - 9618 Chapter 2 : Communication Instructor: Nadia Arif
Public IP addresses are the ones allocated by a user’s ISP to identify the
location of their device. Devices using these IP addresses are accessible from
anybody using the internet. Public IP addresses are used by
DNS servers
network routers
directly-controlled computers.
Path is the web page (if this is omitted then it is the root directory of the
website)
Filename is the item from the web page
The domain name service (DNS) (also known as domain name system) gives
domain names for internet hosts and is a system for finding IP addresses of
a domain name. Domain names eliminate the need for a user to memorise IP
addresses. The DNS process involves converting a host name (such as
www.hoddereducation.co.uk) into an IP address the computer can understand
(such as 107.162.140.19)
Often, DNS servers contain a database of URLs with the matching IP
addresses.
1. The user opens their web browser and types in the URL
(www.hoddereducation.co.uk) and the web browser asks the DNS server
(1) for the IP address of the website.
2. The DNS server can’t find www.hoddereducation.co.uk in its database
or its cache and sends out a request to DNS server (2).
3. DNS server (2) finds the URL and can map it to 107.162.140.19; the IP
address is sent back to DNS server (1) which now puts the IP address
and associated URL into its cache/database.
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 56
AS Computer Science - 9618 Chapter 2 : Communication Instructor: Nadia Arif
Scripting in HTML
JavaScript
JavaScript (unlike HTML) is a programming language which will run on the
client-side.
PHP
PHP is another language which can be embedded within HTML.
However, when PHP is used it is processed on the server-side.
Again, the code will be sandwiched inside HTML and will be stored as a
.php file.
Primary Memory:
Primary memory is the part of computer memory which can be accessed
directly from the CPU. Primary memory allows the processor to access
applications and services temporarily stored in memory locations.
RAM:
RAM refers to the fact that any memory location can be accessed
independent of which memory location was last used. Access time to locate
data is much faster in RAM than in secondary devices.
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 61
AS Computer Science - 9618 Chapter 3 : Hardware Instructor: Nadia Arif
or by the computer
o used to store data, files, part of an application or part of the operating
There are currently two types of RAM technology, dynamic RAM (DRAM) and
static RAM (SRAM).
DRAM SRAM
consists of a number of uses flip-flops to hold each bit of
transistors and capacitors memory
needs to be constantly
ROM:
o non-volatile (the contents are not lost after powering off the computer)
o permanent memory devices (the contents cannot be changed)
o often used to store data which the computer needs to access when
powering up for the first time for example, the basic input/output
system (BIOS).
written to once.
o They are often used in mobile phones and in RFID tags.
RAM ROM
temporary memory device permanent memory device
volatile memory non-volatile memory device
can be written to and read from data stored cannot be altered
used to store data, files, programs, sometimes used to store BIOS and
part of OS currently in use other data needed at start up
can be increased in size to
improve operational speed of a
computer
Embedded systems
Embedded systems involve installing microprocessors into devices to enable
operations to be controlled in a more efficient way. Devices such as cookers,
refrigerators and central heating systems can now all be activated by a web-
enabled device (such as a mobile phone or tablet).
very fast reaction to changing any device that can be accessed over
input (operate in real time) the internet is also open to hackers,
with mass production comes viruses, and so on
reliability due to the difficulty in upgrading and
fault finding, devices are often just
thrown away rather than being
repaired (wasteful)
drive.
Data is stored on the surface in sectors and tracks.
Issue: Latency
Explanation: hard disk drives have very slow data access when compared to, for
example, RAM. Many applications require the read-write heads to constantly seek
for the correct blocks of data; this means a large number of head movements.
The effects of latency then become very significant. Latency is defined as the
time it takes for a specific block of data on a data track to rotate around to
the read-write head.
considerably.
They have no moving parts and all data is retrieved at the same rate.
The most common type of solid state storage devices store data by
chip.
Benefits of SSD:
are more reliable (no moving parts to go wrong)
run much cooler than HDDs (both these points again make them very
to read data from, and write data onto, the surface of a disk.
Both CDs and DVDs use a thin layer of metal alloy or light-sensitive
beam ‘contacts’ the disk surface and follows the spiral track from the
centre outwards.
As with an HDD, a CD/DVD is divided into sectors allowing direct access of
data. Also, as in the case of an HDD, the outer part of the disk runs
faster than the inner part of the disk.
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 67
AS Computer Science - 9618 Chapter 3 : Hardware Instructor: Nadia Arif
The data is stored in ‘pits’ and ‘bumps’ on the spiral track. A red laser is
used to read and write the data.
Inkjet printers
3D Printers:
3D printers use additive manufacturing this is in contrast to the more
traditional method of subtractive manufacturing
The subtractive method would involve carving the statue out of solid stone
(removing the stone not required) until the final item was produced.
Similarly, CNC machining removes metal to form an object; 3D printing
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 70
AS Computer Science - 9618 Chapter 3 : Hardware Instructor: Nadia Arif
would produce the same item by building up the object from layers of
powdered metal.
Speakers:
Digitised sound stored in a file on a computer can be converted into analogue
sound as follows:
The digital data is first passed through a digital to analogue converter
sound.
If the sound is stored in a computer file, it must first pass through a digital
magnetic field in the iron core also varies. This causes the iron core to be
attracted towards the permanent magnet and as the current varies this will
cause the iron core to vibrate.
Since the iron core is attached to a cone (made from paper or thin
The rate at which the DAC can translate the digital output into analogue
voltages is known as the sampling rate.
Microphones:
Microphones are either built into the computer or are external devices connected
through the USB port or through wireless connectivity. The current produced can
either be stored as sound amplified and sent to a loudspeaker, or sent to a
computer for storage.
When sound is created, it causes the air to vibrate.
The electric current is analogue in nature. The electric current output from
the microphone can also be sent to a computer where a sound card converts
the current into a digital signal which can then be stored in the computer.
Screens:
screens use an LCD, backlit with LEDs or the newer organic light emitting diode
(OLED) technology.
Touch screens
Capacitive:
Made up of many layers of glass that act like a capacitor creating electric
Resistive:
Makes use of an upper layer of polyester (a form of plastic) and a bottom
layer of glass.
When the top polyester layer is touched, the top layer and bottom layer
complete a circuit.
Signals are then sent out, which are interpreted by a microprocessor and
the calculations determine the coordinates of where the screen was touched.
Benefits Drawbacks
Relatively inexpensive Screen visibility is poor in strong
technology. sunlight.
Possible to use bare fingers, Does not permit multi-touch capability.
gloved fingers or stylus to carry Screen durability is only fair; it is
out an input operation. vulnerable to scratches and the screen
wears out through time
Virtual headsets:
Video is sent from a computer to the headset
Two feeds are sent to an LCD/OLED display ; lenses placed between the
eyes and the screen allow for focusing and reshaping of the image/video for
each eye, thus giving a 3D effect and adding to the realism.
Most headsets use 110° field of view which is enough to give a pseudo 360°
surround image/video.
A frame rate of 60 to 120 images per second is used to give a true/realistic
image.
As the user moves their head, a series of sensors and/or LEDs measure this
Headsets also use binaural sound so that the speaker output appears to
come from behind, from the side or from a distance, giving very realistic 3D
sound
Some headsets also use infrared sensors to monitor eye movement, which
allows the depth of field on the screen to be more realistic; an example of
this is to make objects in the foreground appear fuzzy when the user’s
eyes indicate they are looking into the distance.
Sensors
Sensors are input devices which read or measure physical properties, such as
temperature, pressure etc
check weight
monitor/control a process where gas pressure is important
acoustic/sound pick up noise levels in a burglar alarm system
detect noise of liquids dripping from a pipe
gas (such as O2 or monitor pollution levels in a river or air
CO2) measure O2 and CO2 levels in a greenhouse
check for CO2 or NO2 leaks in a power station
pH monitor/control acidity/alkalinity levels in soil
monitor pollution in rivers
magnetic field detect changes in in cell phones, CD players, and so on
used in anti-lock braking systems in motor vehicles
A B C P = (A = 1 AND B = Q =( B = 1 AND C = X = P OR
NOT 1) NOT 1) Q
0 0 0 0 0 0
0 0 1 0 0 0
0 1 0 0 1 1
0 1 1 0 0 0
1 0 0 1 0 1
1 0 1 1 0 1
1 1 0 0 1 1
1 1 1 0 0 0
A B C X
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 0
1 0 0 1
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 81
AS Computer Science - 9618 Chapter 3 : Hardware Instructor: Nadia Arif
1 0 1 0
1 1 0 0
1 1 1 1
Step 1: Write down the statement by looking at the truth table
Write the statement only for the rows where the output is 1
Statement for row 5 will be:
A AND NOT B AND NOT C
sequential order.
calculations.
where the instruction can be found is stored in the program counter (PC).
This instruction is then interpreted.
System clock:
A system clock is used to produce timing signals on the control bus to
ensure this vital synchronisation takes place – without the clock the
computer would simply crash.
access.
The CPU takes data and programs held in backing store and puts them
4.1.3 Registers
There are three common buses used in the Von Neumann architecture known as
address bus, data bus and control bus.
Address bus:
The address bus carries addresses throughout the computer system. Between
the CPU and memory the address bus is unidirectional (in other words, bits
can travel in one direction only).
This prevents addresses being carried back to the CPU, which would be
undesirable.
The width of a bus is important.
The wider the bus, the more memory locations which can be directly
addressed at any given time; for example, a bus of width 16 bits can address
216 (65 536) memory locations, whereas a bus width of 32 bits allows 4
294 967 296 memory locations to be simultaneously addressed.
Data bus:
The data bus is bidirectional (in other words, it allows data to be sent in
numerical value.
As with the address bus, the width of the data bus is important: the wider
the bus, the larger the word length that can be transported
Control bus:
The control bus is also bidirectional. It carries signals from the CU to all the
operations.
.By increasing clock speed, the processing speed of the computer is also
increased
Summary:
Increasing bus width (data and address buses) increases the performance and
speed of a computer system
Increasing clock speed usually increases the speed of a computer
a computer’s performance can be changed by altering bus width, clock
speed and use of multi-core CPUs
use of cache memories can also speed up a processor’s performance.
USB ports
The Universal Serial Bus (USB) is an asynchronous serial data transmission
method.
The screens have a faster refresh rate (such as 120Hz or 120 frames a
second).
The range of colours is extremely large.
VGA supports 640 × 480 pixel resolution on a television or monitor screen. It can
also handle a refresh rate of up to 60Hz (60 frames a second) provided there are
only 16 different colours being used. If the pixel density is reduced to 200 × 320,
then it can support up to 256 colours.
Fetch:
The next instruction is fetched from the memory address currently stored
in the program counter (PC) and is then stored in the current instruction
register (CIR).
The PC is then incremented (increased by 1) so that the next instruction
can be processed.
This is decoded so that each instruction can be interpreted in the next part
of the cycle.
Execute :
The processor passes the decoded instruction as a set of control signals to
Double brackets are used in the third line because it is not MAR contents being
copied into MDR but it is the data stored at the address shown in MAR that is
being copied to MDR.
Interrupt Handling:
There are many different reasons for an interrupt to be generated. Some
examples are:
a fatal error in a program
a hardware fault
user interaction
a timer signal.
A special register called the interrupt register is used in the fetch-execute cycle.
While the CPU is in the middle of carrying out this cycle, an interrupt could
occur, which will cause one of the bits in the interrupt register to change its
status.
Once the interrupt signal is received, the processor either carries on with what it
was doing or stops to service the device/program that generated the interrupt.
The computer needs to identify the interrupt type and also establish the level of
interrupt priority.
Important Definitions:
Opcode: defines the action associated with the instruction
Operand: defines any data needed by the instruction
Machine code instruction: a binary code with a defined number of bits that
comprises an opcode and, most often, one operand
Assembly language: a low-level language related to machine code where opcodes
are written as mnemonics and there is a character representation for an operand
Assembler: a program used to translate an assembly language program into
machine code
Directive: an instruction to the assembler program
There are two types of assembler: single pass assemblers and two pass assemblers.
Pass 1
Read the assembly language program one line at a time.
Ignore anything not required, such as comments.
Allocate a memory address for the line of code.
Check the opcode is in the instruction set.
Add any new labels to the symbol table with the address, if known.
Place address of labelled instruction in the symbol table.
Pass 2
Read the assembly language program one line at a time.
Generate object code, including opcode and operand, from the symbol table
generated in Pass 1.
Save or execute the program.
Compare instructions:
Logical shift – bits shifted out of the register are replaced with zeros.
For example, an 8-bit register containing the binary value 10101111 shifted left
logically three places would become 01111000.
Cyclic shift – no bits are lost during a shift. Bits shifted out of one end of the
register are introduced at the other end of the register.
For example, an 8-bit register containing the binary value 10101111 shifted left
cyclically three places would become 01111101.
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 104
AS Computer Science - 9618 Chapter 4 : Processor Fundamentals Instructor: Nadia Arif
Cyclic shift: the bit that is removed from one end by the shift is added to
the other end.
Bit Masking:
Each bit can represent an individual flag.
by altering the bits, flags could be operated upon.
Bit manipulation operations:
Masking: an operation that defines which bits you want to keep
Advantages:
direct communication with the computer
not restricted to a number of pre-determined options.
Memory management
This can be broken down into three parts: memory optimisation, memory
organisation and memory protection.
Memory optimisation
a. Memory optimisation is used to determine how computer memory
is allocated and deallocated when a number of applications are
running simultaneously.
b. It also determines where they are stored in memory.
c. It must, therefore, keep track of all allocated memory and free
memory available for use by applications.
Memory organisation
Memory organisation determines how much memory is allocated to an
application, and how the memory can be split up in the most
appropriate or efficient manner. This can be done with the use of
a. a single (contiguous) allocation, where all of the memory is made
available to a single application. This is used by MS-DOS and by
embedded systems
b. partitioned allocation, where the memory is split up into contiguous
partitions (or blocks) and memory management then allocates a
partition (which can vary in size) to an application
c. paged memory, which is similar to partitioned allocation, but each
partition is of a fixed size. This is used by virtual memory systems
d. segmented memory, which is different because memory blocks are
not contiguous – each segment of memory will be a logical
grouping of data
Memory protection
Memory protection ensures that two competing applications cannot
use the same memory locations at the same time. If this was not
done, data could be lost, applications could produce incorrect results,
there could be security issues, or the computer may crash.
Security management:
Security management is another part of a typical operating system. The
function of security management is to ensure the integrity, confidentiality
and availability of data.
This can be achieved by
carrying out operating system updates as and when they become
available
ensuring that antivirus software (and other security software) is
always upto-date
communicating with, for example, a firewall to check all traffic to and
from the computer
making use of privileges to prevent users entering ‘private areas’ on a
computer which permits multi-user activity (this is done by setting up
user accounts and making use of passwords and user IDs). This helps
to ensure the privacy of data
maintaining access rights for all users
offering the ability for the recovery of data (and system restore)
when it has been lost or corrupted
helping to prevent illegal intrusion to the computer system (also
ensuring the privacy of data)
Process management
A process is a program which is being run on a computer. Process
management involves the allocation of resources and permits the sharing
and exchange of data, thus allowing all processes to be fully synchronised
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 113
AS Computer Science - 9618 Chapter 5 : System Software Instructor: Nadia Arif
Hardware management
Hardware management involves all input and output peripheral devices. The
functions of hardware management include
communicating with all input and output devices using device drivers
translating data from a file (defined by the operating system) into a
format that the input/output device can understand using device
drivers
ensuring each hardware resource has a priority so that it can be used
and released as required. The management of input/output devices is
essentially the control and management of queues and buffers. For
example, when printing out a document, the printer management
locates and loads the printer driver into memory
sends data to a printer buffer ready for printing
sends data to a printer queue (if the printer is busy or the print job
has a low priority) before sending to the printer buffer
sends various control commands to the printer throughout the
printing process
receives and handles error messages and interrupts from the printer
File management
The main tasks of file management include
defining the file naming conventions which can be used
(filename.docx, where the extension can be .bat, .htm, .dbf, .txt, .xls,
and so on)
performing specific tasks, such as create, open, close, delete, rename,
copy, move
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 114
AS Computer Science - 9618 Chapter 5 : System Software Instructor: Nadia Arif
When carrying out full formatting using NTFS, all disk sectors are filled
with zeros; these zeros are read back, thus testing the sector, but any
data already stored there will be lost. So, it is important to remember that
reformatting an HDD which has already been used will result in loss of data
during the formatting procedure.
Disk formatters also have checking tools, which are non-destructive tests
that can be carried out on each sector. If any bad sector errors are
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 115
AS Computer Science - 9618 Chapter 5 : System Software Instructor: Nadia Arif
discovered, the sectors will be flagged as ‘bad’ and the file tracking records
will be reorganised – this is done by replacing the bad sectors with new
unused sectors, effectively repairing the faulty disk
Virus checkers
Running antivirus software in the background on a computer will constantly
check for virus attacks
Defragmentation software:
Rearranges blocks of individual files (on the HDD) so they are
contiguous // moves the free space together
Accessing each file is faster because there is no need to search for
the next fragment / block of the file so less head movement is
needed
A disk defragmenter will rearrange the blocks of data to store files in
contiguous sectors wherever possible; however, if the disk drive is almost
full, defragmentation may not work.
Back-up software
allow a schedule for backing up files to be made
only carry out a back-up procedure if there have been any changes
made to a file.
Windows environment offers the following facilities using the back-up
utility:
The ability to restore data, files or the computer from the back-up
(useful if there has been a problem and files have been lost and need
to be recovered).
The ability to create a restore point (this restores a computer to its
state at some point in the past; this can be very useful if a very
important file has been deleted and cannot be recovered by any of
the other utilities).
Options of where to save back-up files; this can be set up from the
utility to ensure files are automatically backed up to a chosen device.
Assemblers
Programs written in assembly language are translated into machine
code by an assembler program.
Assemblers either store the program directly in main memory,
ready for execution, as it is translated, or they store the translated
program on a storage medium to be used later.
If stored for later use, then a loader program is also needed to load
the stored translated program into main memory before it can be
executed
Compilers and interpreters
Programs written in a high-level language can be either
translated into machine code by a compiler program, or directly
executed line-by-line using an interpreter program.
Compilers usually store the translated program (object program)
on a storage medium ready to be executed later.
A loader program is needed to load the stored translated program
into main memory before it can be executed.
Compiler Interpreter
The end user only needs the The end user will need to purchase a
executable code, therefore, the end compiler or an interpreter to translate
user benefits as there is no need to the source code before it is used.
purchase a compiler to translate
the program before it is used.
The developer keeps hold of the The developer relinquishes control of
source code, so it cannot be altered the source code, making it more
or extended by the end user, difficult to charge for upgrades and
therefore, the developer benefits as alterations. Since end users can view
they can charge for upgrades and the source code, they could
alterations. potentially use the developer’s
intellectual property.
Compiled programs take a shorter An interpreted program can take
time to execute as translation has longer to execute than the same
already been completed and the program when compiled, since each
machine code generated may have line of the source code needs to be
been optimised by the compiler. translated before it is executed every
time the program is run.
Compiled programs have no syntax Interpreted programs may still contain
or semantic errors. syntax or semantic errors if any part
of the program has not been fully
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 122
AS Computer Science - 9618 Chapter 5 : System Software Instructor: Nadia Arif
Auto-documenter
Most IDEs usually provide an auto-documenter to explain the function and
purpose of programming code.
Digital signatures
Anti Virus Software
Anti Spyware software
Encryption
Biometrics (Fingerprint scan, Retina Scan)
Hacking:
Malicious Hacking: illegal access to a computer system without
Malware:
Viruses: Programs or program code that can replicate and/or
copy themselves with the intention of deleting or corrupting
files or causing the computer to malfunction.
Worms: A type of stand-alone virus that can replicate
themselves with the intention of spreading to other
computers; they often use networks to search out computers
with weak security.
Trojan Horses: Malicious programs often disguised as legitimate
software. They replace all or part of the legitimate software
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 128
AS Computer Science - 9618 Chapter 6 : Security, Privacy & Data Integrity Instructor: Nadia Arif
action, unlike phishing). The creator of the malicious code can gain
personal data such as bank details from users
Protection against pharming: It is possible to mitigate the risk
of pharming by
using antivirus software, which can detect unauthorised
hacking
by accidental data loss caused through hardware issues.
6.2.1 Validation:
Validation is a method of checking if entered data is reasonable , but it cannot
check if data is correct or accurate. For example, if somebody accidentally
enters their age as 62 instead of 26, it is reasonable but not accurate or
correct. Validation is carried out by computer software; the most common types
are shown in the table below:
uniqueness checks that each choosing the user name choosing the
check entered value is MAXIMUS222 in a website name
unique social networking site Aristooo.com
but the user name which is not
already exists already used
6.2.2 Verification:
Verification is a way of preventing errors when data is entered manually (using
a keyboard, for example) or when data is transferred from one computer to
another.
Verification during data entry When data is manually entered into a
computer it needs to undergo verification to ensure there are no errors.
There are three ways of doing this:
double entry
Parity checks
A parity check is another method to check whether data
has been changed or corrupted following transmission from
one device or medium to another.
the sender.
Software is protected by copyright laws in much the same way as music CDs,
videos and articles from magazines and books are protected. When software is
purchased, there are certain rules that must be obeyed:
It is illegal to make a software copy and sell it or give it away.
Software cannot be used on a network or used on multiple computers
without a multi-use licence.
It is illegal to use coding from copyrighted software in your own software
– and then pass this software on or sell it as your own – without the
permission of the copyright holder.
It is illegal to rent out a software package without permission to do so.
It is illegal to use the name of copyrighted software on other software
without agreement to do so.
Users cannot
add source code from another piece of software unless this is also
described as free software or open source software
use the source code to produce software which copies existing software
which is subject to copyright laws
adapt the source code in such a way that it infringes copyright laws
protecting other software
use the source code to produce software which is deemed offensive by
third parties.
Freeware:
Freeware is software a user can download from the internet free of
charge. Once it has been downloaded, there are no fees associated with
using the software (examples include: Adobe Reader, Skype and some
media players). Unlike free software, freeware is subject to copyright
laws and users are often requested to tick a box to say they understand
and agree to the terms and conditions governing the software. This
means that a user is not allowed to study or modify the source code in
any way.
Shareware:
Shareware allows users to try out some software free of charge for a
trial period. At the end of the trial period, the author of the software
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 143
AS Computer Science - 9618 Chapter 7 : Ethics & Ownership Instructor: Nadia Arif
will request that you pay a fee if you wish to continue using it. Once
the fee is paid, a user is registered with the originator of the software
and free updates and help are then provided. Often, the trial version of
the software is missing some of the features found in the full version,
and these do not become available until the fee is paid. This type of
software is protected by copyright laws and users must not use the
source code in any of their own software without permission.
Transport:
Some taxi companies are already looking at the introduction of
autonomous (driverless) cars. A customer can call up the taxi using
an app on their mobile phone, which also automatically handles the
payment. Information about the taxi (such as its location and
estimated arrival time) would be sent to the mobile phone until the
driverless taxi arrives at the exact pick-up point. There would not be
any people anywhere in the chain, with AI systems taking total
control. Some car manufacturers are on the brink of actually
supplying autonomous vehicles (cars, buses and trucks). This would be
much more efficient but would put many drivers out of a job.
using access rights to manage the actions authorised users can take,
for example, users could read/write/delete, or read only, or append
only
using access rights to manage the parts of the database they have
access to, for example, the provisions of different views of the data
for different users to allow only certain users access to some tables
automatic creation and scheduling of regular back-ups
encryption of the data stored » automatic creation of an audit trail
or activity log to record the actions taken by users of the database.
8.3 Data Definition Language (DDL) and Data Manipulation Language (DML)
This query will show, in alphabetical order of second name, the first
and second names of all students in class 7A:
This query will show the teacher’s name and the subject taught:
If the values for all the columns are not known, then the table
columns need to be specified before the values are inserted:
These statements will delete the specified row(s) from the Student
table
DELETE FROM Student WHERE StudentID = 'S1301'
+ addition
- subtraction
* multiplication
/ divide
& concatenation
<--- assignment
= Equal to
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 168
AS Computer Science - 9618 Chapter 9 : Algorithm design & Problem solving Instructor: Nadia Arif
Integer 4
Real 4.3
Character "a"
String "Hamza"
Boolean True OR False
Pseudocode Statements:
To Input a value
INPUT StudentName
Selection Statements:
IF/ELSE
CASE/ENDCASE
CASE OF Direction
"N": Y ← Y + 1
"S": Y ← Y – 1
"E": X ← X + 1
"W": X ← X – 1
OTHERWISE : OUTPUT "Error"
ENDCASE
Iteration:
FOR LOOP (Count Controlled Loop)
WHILE LOOP (Pre Conditioned Loop)
REPEAT LOOP (Post Conditioned loop)
Total ← 0
FOR Counter ← 1 TO 10
OUTPUT "Enter a number "
INPUT Number
Total ← Total + Number
NEXT Counter
OUTPUT "The total is ", Total
REPEAT
OUTPUT "Please enter a positive number "
INPUT Number
UNTIL Number > 0
Number ← 0
WHILE Number >= 0
DO
OUTPUT "Please enter a negative number "
INPUT Number
ENDWHILE
Stepwise refinement:
When an algorithm is written to solve a more complex problem,
decomposition is used to break the problem down into smaller and more
manageable parts. These parts then need to be written as a series of steps
where each step can be written as a statement in a high-level
programming language, this process is called stepwise refinement.
Identifier Table:
keep track of any identifiers used during the program along with its
description and data type
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 173
AS Computer Science - 9618 Chapter 9 : Algorithm design & Problem solving Instructor: Nadia Arif
TYPE TbookRecord
DECLARE title : STRING
DECLARE author : STRING
DECLARE publisher : STRING
DECLARE noPages : INTEGER
DECLARE fiction : BOOLEAN
ENDTYPE
10.2 ARRAYS
An array is a data structure containing several elements of the same data
type
10.2.1 1D Arrays
10.2.2 2D arrays
found ← FALSE
index ← lowerBound
REPEAT
IF item = myList[index]
THEN
found ← TRUE
ENDIF
index ← index + 1
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 188
AS Computer Science - 9618 Chapter 10 & 11 : Data types & Structures Instructor: Nadia Arif
IF found
THEN
OUTPUT "Item found"
ELSE
OUTPUT "Item not found"
ENDIF
Pseudocode:
upperBound ← 8
lowerBound ← 0
top ← upperBound
top ← top -1
UNTIL (NOT swap) OR (top = 0)
PROCEDURE Sort()
DECLARE Temp : INTEGER
DECLARE NoSwaps : BOOLEAN
DECLARE Boundary, Row, Col : INTEGER
Boundary ← 999
REPEAT
NoSwaps ← TRUE
FOR Row ← 1 TO Boundary
IF Result[Row, 2] > Result[Row + 1, 2]
THEN
FOR Col ← 1 TO 2
Temp ← Result [Row, Col]
Result [Row, Col] ← Result [Row + 1, Col]
Result [Row + 1, Col] ← Temp
NEXT Col
NoSwaps ← FALSE
ENDIF
NEXT Row
Boundary ← Boundary - 1
UNTIL NoSwaps = TRUE
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 191
AS Computer Science - 9618 Chapter 10 & 11 : Data types & Structures Instructor: Nadia Arif
ENDPROCEDURE
10.3: Files
EOF(<file Identifier>)
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 192
AS Computer Science - 9618 Chapter 10 & 11 : Data types & Structures Instructor: Nadia Arif
This pseudocode shows how the file myText.txt could be written to and
read from:
REPEAT
OUTPUT "Please enter a line of text"
INPUT textLn
REPEAT
READFILE, textLn
OUTPUT textLn
UNTIL EOF(myFile)
CLOSEFILE(myFile)
size ← LENGTH(inputPassword)
IF size = LENGTH(storedPassword)
THEN
IF (LEFT(inputPassword, 1) = LEFT(storedPassword, 1)) AND
(RIGHT(inputPassword, 1) = RIGHT(storedPassword, 1))
THEN
OUTPUT "Password entered has correct first and last
letters"
ELSE
OUTPUT "Password entered is incorrect"
ENDIF
ELSE
OUTPUT "Password entered is incorrect"
ENDIF
10.5 Abstract Data Types:
Stack:
a list containing several items operating on the last in, first out
(LIFO) principle.
Items can be added to the stack (push) and removed from the
stack (pop).
The first item added to a stack is the last item to be removed from
the stack.
Queue:
a list containing several items operating on the first in, first out
(FIFO) principle.
Items can be added to the queue (enqueue) and removed from the
queue (dequeue).
The first item added to a queue is the first item to be removed from
the queue.
The value of the frontPointer changes after dequeue but the value
of the rearPointer changes after enqueuer
Linked list :
a list containing several items in which each item in the list points
to the next item in the list.
In a linked list a new item is always added to the start of the list.
Important definitions:
Parameter – a variable applied to a procedure or function that allows
one to pass in a value for the procedure to use.
By value – a method of passing a parameter to a procedure in which
the value of the variable cannot be changed by the procedure.
By reference – a method of passing a parameter to a procedure in
which the value of the variable can be changed by the procedure.
Header (procedure or function) – the first statement in the
definition of a procedure or function, which contains its name, any
parameters passed to it, and, for a function, the type of the return
value.
Argument – the value passed to a procedure or function.
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 201
AS Computer Science - 9618 Chapter 10 & 11 : Data types & Structures Instructor: Nadia Arif
10.6.1 Procedure:
10.6.2 Functions:
Purpose:
A program that has been developed may require alterations at any time in
order to deal with new circumstances or new errors that have been found,
so the stages are referred to as a lifecycle as this continues until the
program is no longer used.
Analysis:
a process of investigation, leading to the specification of what a
program is required to do
Design:
it uses the program specification from the analysis stage to show
how the program should be developed.
Coding
The program or set of programs is written using a suitable
programming language.
Testing
The program is run many times with different sets of test data,
to test that it does everything it is supposed to do in the way set
out in the program design.
Maintenance
The program is maintained throughout its life, to ensure it
continues to work effectively. This involves dealing with any
problems that arise during use, including correcting any errors that
come to light, improving the functionality of the program, or
adapting the program to meet new requirements.
The arrows going down represent the fact that the results from one stage
are input into the next stage. The arrows leading back up to an earlier
stage reflect the fact that often more work is required at an earlier stage
to complete the current stage
An iterative life cycle model does not attempt to start with a full
specification of requirements. Instead, development starts with the
implementation of a small subset of the program requirements. Repeated
(iterative) reviews to identify further requirements eventually result in the
complete system
In the RAD model, the modules are developed in parallel as prototypes and
are integrated to make the complete product for faster product delivery.
Sharjeel Arif: 0333 5752253 Copyright ©Learningscapes Academy 214
AS Computer Science - 9618 Chapter 12 : Software Development Instructor: Nadia Arif
Structure charts:
A structure chart is a modelling tool used in program design to decompose
a problem into a set of sub-tasks. The structure chart shows the
hierarchy or structure of the different modules and how they connect and
interact with each other.
As the program is being developed the following types of testing are used:
White-box testing is the detailed testing of how each procedure
works. This involves testing the structure and logic of every path
through a program module.
Black-box testing tests a module’s inputs and outputs.
Integration testing is the testing of any separately written modules
to ensure that they work together, during the testing phase of the
program development lifecycle. If any of the modules have not been
written yet, this can include stub testing, which makes use of
dummy modules for testing purposes.
The following information sets out how pseudocode will appear within the examined components and is
provided to allow you to give learners familiarity before the exam.
1.2 Indentation
Lines are indented (usually by three spaces) to indicate that they are contained within a statement in a
previous line. In cases where line numbering is used, this indentation may be omitted. Every effort will be
made to make sure that code statements are not longer than a line of text unless this is absolutely
necessary. Where necessary, continuation lines will be aligned to maximise readability.
1.3 Case
Keywords are in upper-case, e.g. IF, REPEAT, PROCEDURE. (Different keywords are explained in
later sections of this guide.)
Identifiers are in mixed case (sometimes referred to as camelCase or Pascal case) with upper-case letters
indicating the beginning of new words, for example NumberOfPlayers.
Meta-variables – symbols in the pseudocode that should be substituted by other symbols are enclosed in
angled brackets < > (as in Backus-Naur Form). This is also used in this guide.
Example – meta-variables
REPEAT
<statement(s)>
UNTIL <condition>
Line numbers are consecutive, unless numbers are skipped to indicate that part of the code is missing. This
will also be clearly stated.
Each line representing a statement is numbered. However, when a statement runs over one line of text, the
continuation lines are not numbered.
2
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
1.5 Comments
Comments are preceded by two forward slashes //. The comment continues until the end of the line. For
multi-line comments, each line is preceded by //.
Normally the comment is on a separate line before, and at the same level of indentation as, the code it refers
to. Occasionally, however, a short comment that refers to a single line may be at the end of the line to which
it refers.
Example – comments
// this procedure swaps
// values of X and Y
PROCEDURE SWAP(BYREF X : INTEGER, Y : INTEGER)
Temp ← X // temporarily store X
X ←Y
Y ← Temp
ENDPROCEDURE
3
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
2.2. Literals
Literals of the above data types are written as follows:
Always written with at least one digit on either side of the decimal point, zeros being
• Real
added if necessary, e.g. 4.7, 0.3, -4.0, 0.0
• Char A single character delimited by single quotes e.g. ꞌxꞌ, ꞌCꞌ, ꞌ@ꞌ
Delimited by double quotes. A string may contain no characters (i.e. the empty string)
• String
e.g. "This is a string", ""
This will normally be written in the format dd/mm/yyyy. However, it is good practice to
• Date state explicitly that this value is of data type DATE and to explain the format (as the
convention for representing dates varies across the world).
2.3. Identifiers
Identifiers (the names given to variables, constants, procedures and functions) are in mixed case. They can
only contain letters (A–Z, a–z), digits (0–9) and the underscore character ( _ ). They must start with a letter and
not a digit. Accented letters should not be used.
It is good practice to use identifier names that describe the variable, procedure or function they refer to. Single
letters may be used where these are conventional (such as i and j when dealing with array indices, or X and
Y when dealing with coordinates) as these are made clear by the convention.
Identifiers should be considered case insensitive, for example, Countdown and CountDown should not
be used as separate variables.
4
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
2.5. Constants
It is good practice to use constants if this makes the pseudocode more readable, as an identifier is more
meaningful in many cases than a literal. It also makes the pseudocode easier to update if the value of the
constant changes.
Constants are normally declared at the beginning of a piece of pseudocode (unless it is desirable to restrict
the scope of the constant).
Constants are declared by stating the identifier and the literal value in the following format:
Only literals can be used as the value of a constant. A variable, another constant or an expression must
never be used.
2.6. Assignments
The assignment operator is ← .
<identifier> ← <value>
The identifier must refer to a variable (this can be an individual element in a data structure such as an array or
a user defined data type). The value may be any expression that evaluates to a value of the same data type
as the variable.
Example – assignments
Counter ← 0
Counter ← Counter + 1
TotalToPay ← NumberOfHours * HourlyRate
5
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
3. Arrays
Syllabus requirements
The Cambridge International AS & A Level syllabus (9618) requires candidates to understand and
use both one-dimensional and two-dimensional arrays.
Arrays can be used in assignment statements (provided they have same size and data type). The following is
therefore allowed:
A statement should not refer to a group of array elements individually. For example, the following
construction should not be used.
6
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
Instead, an appropriate loop structure is used to assign the elements individually. For example:
7
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
Syllabus requirements
The AS & A Level (9618) syllabus requires candidates to understand that data structures that are not
available in a particular programming language need to be constructed from the data structures that
are built-in within the language. User-defined data types need to be defined. The syllabus requires
candidates to use and define non-composite data types such as enumerated and pointer and
composite data types such as record, set, class/object. Abstract Data Types (ADTs) stack, queue,
linked list, dictionary and binary tree are also defined as composite data types.
A user-defined non-composite data type with a list of possible values is called an enumerated data type.
The enumerated type should be declared as follows:
The ^ shows that the variable is a pointer and the data type indicates the type of the data
stored in the memory location.
Declaration of a variable of pointer type does not require the ^ (caret) symbol to be used.
8
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
Composite data type
A composite data type is a collection of data that can consist of different data types, grouped under one
identifier. The composite type should be declared as follows:
TYPE <identifier1>
DECLARE <identifier2> : <data type>
TECLARE <identifier3> : <data type>
...
ENDTYPE
TYPE Student
DECLARE LastName : STRING
DECLARE FirstName : STRING
DECLARE DateOfBirth : DATE
DECLARE YearGroup : INTEGER
DECLARE FormGroup : CHAR
ENDTYPE
9
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
Variables of a user-defined data type can be assigned to each other. Individual data items are accessed
using dot notation.
Pupil1.LastName ← "Johnson"
Pupil1.Firstname ← "Leroy"
Pupil1.DateOfBirth ← 02/01/2005
Pupil1.YearGroup ← 6
Pupil1.FormGroup ← ꞌAꞌ
Pupil2 ← Pupil1
FOR Index ← 1 TO 30
Form[Index].YearGroup ← Form[Index].YearGroup + 1
NEXT Index
ThisSeason ← Spring
MyPointer ← ^ThisSeason
NextSeason ← MyPointer^ + 1
// access the value stored at the memory address
10
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
5. Common operations
INPUT <identifier>
The identifier should be a variable (that may be an individual element of a data structure such as an array, or
a custom data type).
OUTPUT <value(s)>
Several values, separated by commas, can be output using the same command.
+ Addition
- Subtraction
* Multiplication
/ Division (The resulting value should be of data type REAL, even if the operands are integers.)
DIV Integer division: Used to find the quotient (integer number before the decimal point) after division.
MOD or Modulus: The remainder that is left over when one number is divided by another.
Multiplication and division have higher precedence over addition and subtraction (this is the normal
mathematical convention). However, it is good practice to make the order of operations in complex
expressions explicit by using parentheses.
In complex expressions it is advisable to use parentheses to make the order of operations explicit.
11
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
In complex expressions it is advisable to use parentheses to make the order of operations explicit.
Syllabus requirements
The AS & A Level (9618) syllabus specifically requires candidates to know string manipulation
functions in their chosen programming language. Pseudocode string manipulation functions will
always be provided in examinations. Some basic string manipulation functions are given here.
Each function returns an error if the function call is not properly formed.
12
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
Example: "Summer" & " " & "Pudding" produces "Summer Pudding"
Where string operations (such as concatenation, searching and splitting) are used in a programming
language, these should be explained clearly, as they vary considerably between systems.
Where functions in programming languages are used to format numbers as strings for output, their use should
also be explained.
13
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
6. Selection
6.1. IF statements
IF statements may or may not have an ELSE clause.
IF <condition> THEN
<statement(s)>
ENDIF
IF <condition> THEN
<statement(s)>
ELSE
<statement(s)>
ENDIF
Note, due to space constraints, the THEN and ELSE clauses may only be indented by two spaces rather than
three. (They are, in a sense, a continuation of the IF statement rather than separate statements).
14
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
CASE OF <identifier>
<value 1> : <statement1>
<statement2>
...
<value 2> : <statement1>
<statement2>
...
...
ENDCASE
CASE OF <identifier>
<value 1> : <statement1>
<statement2>
...
<value 2> : <statement1>
<statement2>
...
OTHERWISE : <statement1>
<statement2>
...
ENDCASE
Note that the CASE clauses are tested in sequence. When a case that applies is found, its statement is
executed and the CASE statement is complete. Control is passed to the statement after the ENDCASE. Any
remaining cases are not tested.
If present, an OTHERWISE clause must be the last case. Its statement will be executed if none of the
preceding cases apply.
15
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
7. Iteration (repetition)
The identifier must be a variable of data type INTEGER, and the values should be expressions that evaluate
to integers.
The variable is assigned each of the integer values from value1 to value2 inclusive, running the statements
inside the FOR loop after each assignment. If value1 = value2 the statements will be executed once, and if
value1 > value2 the statements will not be executed.
It is good practice to repeat the identifier after NEXT, particularly with nested FOR loops.
The increment must be an expression that evaluates to an integer. In this case the identifier will be
assigned the values from value1 in successive increments of increment until it reaches value2. If it goes
past value2, the loop terminates. The increment can be negative.
REPEAT
<statement(s)>
UNTIL <condition>
The statements in the loop will be executed at least once. The condition is tested after the statements are
executed and if it evaluates to TRUE the loop terminates, otherwise the statements are executed again.
WHILE <condition>
<statement(s)>
ENDWHILE
The condition is tested before the statements, and the statements will only be executed if the condition
evaluates to TRUE. After the statements have been executed the condition is tested again. The loop
terminates when the condition evaluates to FALSE.
The statements will not be executed if, on the first test, the condition evaluates to FALSE.
17
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
Syllabus requirements
The definition and use of procedures and functions is explicitly required in the AS & A Level (9618)
syllabus. Any pseudocode functions used in an examination will be defined.
PROCEDURE <identifier>
<statement(s)>
ENDPROCEDURE
The <identifier> is the identifier used to call the procedure. Where used, param1, param2 etc. are
identifiers for the parameters of the procedure. These will be used as variables in the statements of the
procedure.
CALL <identifier>
When parameters are used, Value1, Value2... must be of the correct data type and in the same
sequence as in the definition of the procedure.
Unless otherwise stated, it should be assumed that parameters are passed by value. (See section 8.3).
18
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
The keyword RETURN is used as one of the statements within the body of the function to specify the value to
be returned. Normally, this will be the last statement in the function definition, however, if the RETURN
statement is in the body of the function its execution is immediate and any subsequent lines of code are
omitted.
Because a function returns a value that is used when the function is called, function calls are not complete
program statements. The keyword CALL should not be used when calling a function. Functions should only
be called as part of an expression. When the RETURN statement is executed, the value returned replaces the
function call in the expression and the expression is then evaluated.
19
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
If the method for passing parameters is not specified, passing by value is assumed. How this should
be called and how it operates has already been explained in Section 8.1.
20
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
9. File handling
A file must be opened in a specified mode before any file operations are attempted. This is written
as follows:
The file identifier may be a literal string containing the file names, or a variable of type STRING that has been
assigned the file name.
Data is read from the file (after the file has been opened in READ mode) using the READFILE command as
follows:
The variable should be of data type STRING. When the command is executed, the next line of
text in the file is read and assigned to the variable.
The function EOF is used to test whether there are any more lines to be read from a given file. It is called as
follows:
EOF(<file identifier>)
This function returns TRUE if there are no more lines to read (or if an empty file has been opened in READ
mode) and FALSE otherwise.
Data is written into the file (after the file has been opened in WRITE or APPEND mode) using the
WRITEFILE command as follows:
Files should be closed when they are no longer needed using the CLOSEFILE command as follows:
21
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
Random files are opened using the RANDOM file mode as follows:
As with text files, the file identifier will normally be the name of the file.
The address should be an expression that evaluates to an integer which indicates the location of a record to
be read or written. This is usually the number of records from the beginning of the file. It is good practice to
explain how the addresses are computed.
The command GETRECORD should be used to read the record at the file pointer:
When this command is executed, the record that is read is assigned to the variable which must be of
the appropriate data type for that record (usually a user-defined type).
The command PUTRECORD is used to write a record into the file at the file pointer:
When this command is executed, the data in the variable is inserted into the record at the file pointer. Any
data that was previously at this location will be replaced.
22
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
NewPupil.LastName ← "Johnson"
NewPupil.Firstname ← "Leroy"
NewPupil.DateOfBirth ← 02/01/2005
NewPupil.YearGroup ← 6
NewPupil.FormGroup ← ꞌAꞌ
SEEK "StudentFile.Dat", 10
PUTRECORD "StudentFile.Dat", NewPupil
CLOSEFILE "StudentFile.dat"
23
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
Example code:
Player.SetAttempts(5)
OUTPUT Player.GetAttempts()
CLASS Pet
PRIVATE Name : STRING
PUBLIC PROCEDURE NEW(GivenName : STRING)
Name ← GivenName
ENDPROCEDURE
ENDCLASS
Inheritance is denoted by the INHERITS keyword; superclass/parent class methods will be called using the
keyword SUPER, for example:
For example:
24
Pseudocode Guide for Teachers Cambridge International AS & A Level Computer Science (9618)
-, 11 GETRECORD, 22
←, 5 IF, 14
*, 11 INHERITS, 24
/, 11 INPUT, 11
//, 3 INT, 13
+, 11 INTEGER, 4
<, 11 LCASE, 12
<=, 11 LENGTH, 12
<>, 11 MID, 12
=, 11 MOD, 11
>, 11 NEXT, 16
>=, 11 NEW, 23
^ (caret), 8 NOT, 12
&, 13 OPENFILE, 21
AND, 12 OR, 12
APPEND, 21 OTHERWISE, 15
ARRAY, 6 OUTPUT, 11
BOOLEAN, 4 PROCEDURE, 18
BYREF, 20 PRIVATE, 24
BYVAL, 20 PUBLIC, 24
CALL, 18 PUTRECORD, 22
CASE OF, 14 RAND, 13
CHAR, 4 RANDOM (files), 22
CLASS, 24 READ, 21
CLOSEFILE, 21 READFILE, 21
CONSTANT, 5 REAL, 4
DATE, 4 REPEAT, 16
DECLARE, 5 RETURN, 19
DIV, 11 RETURNS, 19
ELSE, 14 RIGHT, 12
ENDCASE, 15 SEEK, 22
ENDCLASS, 24 STEP, 16
ENDFUNCTION, 19 STRING, 4
ENDIF, 14 SUPER, 24
ENDPROCEDURE, 18 THEN, 14
ENDTYPE, 9 TRUE, 4
ENDWHILE, 17 TYPE, 8
EOF, 21 UCASE, 12
FALSE, 4 UNTIL, 16
FOR ... TO, 16 WHILE, 17
FOR (file handling), 21 WRITE, 21
FUNCTION, 19 WRITEFILE, 21
25
Cambridge Assessment International Education
The Triangle Building, Shaftesbury Road, Cambridge, CB2 8EA, United Kingdom
t: +44 1223 553554
e: info@cambridgeinternational.org www.cambridgeinternational.org