0% found this document useful (0 votes)
63 views29 pages

AS-9618 Computer Science Notes

The document discusses data representation in computer science, explaining binary, decimal, and hexadecimal systems, along with conversion methods between them. It also covers multimedia storage formats, including bitmap and vector images, sound sampling, and compression techniques. Additionally, it outlines network types and topologies, including WAN, LAN, client-server models, and cloud computing, detailing their benefits and drawbacks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views29 pages

AS-9618 Computer Science Notes

The document discusses data representation in computer science, explaining binary, decimal, and hexadecimal systems, along with conversion methods between them. It also covers multimedia storage formats, including bitmap and vector images, sound sampling, and compression techniques. Additionally, it outlines network types and topologies, including WAN, LAN, client-server models, and cloud computing, detailing their benefits and drawbacks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

COMPUTER SCIENCE CAIE 9618

Chapter 1.1 - Data Representation


Computers process information in 0s and 1s. This is the binary system and is base-2,
because each digit can only have 2 values: 0, 1. Each binary digit is called a bit. A group
of 4 bits is called a nibble and a group of 8 bits is called a byte.
Humans process information mainly in the decimal (sometimes called denary) system,
a base-10 system because each digit can have 10 values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
Since binary is hard to process for humans, sometimes binary output(like error
messages, colour codes, etc) is displayed in hexadecimal because it is easier to read,
debug and output.
Hexadecimal is a base-16 number system because each digit can have 16 values: 0, 1,
2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. Because it takes 4 bits to represent 16 different
numbers in binary, each hexadecimal digit can replace a group of 4 bits (nibble).
Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Hexa-
decimal 0 1 2 3 4 5 6 7 8 9 A B C D E F

When converting from either binary to decimal or from hexadecimal to decimal,


multiply each digit by its place value, and then add each of these numbers together to
get the final number. The place value is the value each digit in the number represents.
0
For decimal, the first digit (the rightmost one) has a place value of 1 (10 ). The second
1 2
digit has a place value of 10 (10 ), the third digit has a place value of 100 (10 ), where
each place value gets multiplied by 10 (because it’s base-10) to get the next digit’s
place value.
0 1 2
For binary, the place values are 1 (2 ), 2 (2 ), 4 (2 ), etc, where each place value gets
multiplied by 2 (because it’s base-2) to get the next digit’s place value.
0 1 2
For hexadecimal, the place values are 1 (16 ), 16 (16 ), 256 (16 ), etc, where each place
value gets multiplied by 16 (because it’s base-16) to get the next digit’s place value.
For example, to convert the binary 1101 to decimal:
3 2 1 0
Place value 8 (i.e. 2 ) 4 (i.e. 2 ) 2 (i.e. 2 ) 1 (i.e. 2 )
Binary digits 1 1 0 1
Digit×place value 8×1=8 4×1=4 2×0=0 1×1=1
8 + 4 + 0 + 1 = 13, so 1101 in decimal is 13.
For example, to convert the hexadecimal 2A3 to decimal:
2 1 0
Place value 256 (i.e. 16 ) 16 (i.e. 16 ) 1 (i.e. 16 )
Hexadecimal digits 2 A 3
Digit×place value 256×2=512 16×10=160 1×3=3
512 + 160 + 3 = 675, so 1101 in decimal is 13.

Links to: Past papers - Syllabus - Textbook Page 1


COMPUTER SCIENCE CAIE 9618
When talking about digits, the most significant digit is the digit with the highest place
value (the leftmost digit), and the least significant digit is the digit with the lowest
place value (the rightmost digit).
When converting from decimal to binary, repeatedly divide the decimal number by 2
(because it is base 2) until the number becomes 0. The first remainder is the first digit
(the rightmost digit), then the second remainder becomes the second digit, the third
remainder becomes the third digit etc.
Decimal number 0 ← 1 ← 3 ← 6 ← 13

Remainder 1 1 0 1 so 13 in binary is 1101

When converting from decimal to hexadecimal, follow the same steps as binary except
divide by 16 (Because it is base 16).
Overflow occurs when the result of calculation is a number that is too large to be
stored in the given number of bits.
Binary Coded Decimal (BCD): used in date/time, calculators, finance because it is
easier to convert to denary. Here each decimal digit is represented by a group of 4
binary bits (a nibble). So the decimal number 25 would be stored as 0010 0101, where
the 0010 represents the 2 and the 0101 represents the 5, and together they make 25. To
convert from BCD to decimal, first separate each nibble and convert to decimal
individually, then combine them in order to make a decimal number.
To store a negative number, convert to two’s complement form. Positive numbers are
not stored using two’s complement form.
Two’s complement: flip all the digits in the number (this is called one’s complement)
and add 1 to the number in binary. Then add a 1 on the leftmost end. This leftmost 1
will help make the number negative when converting back to denary.
To convert from two’s complement directly back into decimal, convert normally except
make the leftmost digit have a negative place value. Eg: in 1000, the 1 would be
multiplied by -8, not 8.
Text(numbers, letters, symbols, spaces, punctuation etc.) are stored using character
sets. In a character set, every character that the computer can use is assigned a unique
binary value. Unicode can use up to 32 bits to store one character while ASCII can only
use 7 bits(extend ASCII can use 8), so Unicode can represent more languages and
characters than ASCII.
10 3
kibibyte(KiB) 1024 bytes (2 bytes) kilobyte(kB) 1000 bytes (10 bytes)

20 6
mebibyte(MiB) 1024 kibibytes (2 bytes) megabyte(MB) 1000 kilobytes (10 bytes)

30 9
gibibyte(GiB) 1024 mebibytes (2 bytes) gigabyte(GB) 1000 megabytes (10 bytes)

40 12
tebibyte(TiB) 1024 gibibytes (2 bytes) terabyte(TB) 1000 gigabytes (10 bytes)

Links to: Past papers - Syllabus - Textbook Page 2


COMPUTER SCIENCE CAIE 9618
Chapter 1.2 - Multimedia
Images can be stored as bitmap(png, jpeg, gif, tiff) or vector(svg,pdf).
Vector is used for less complex images like logos, icons, CAD, animation, and not
complex images like photos, portraits, paintings. This is because vectors store images
as multiple drawing objects which is a shape defined using geometry and can be
edited individually. The drawing objects have properties like line width, line colour,
fill colour, position, shape and are stored in a drawing list which contains information
on how to draw the objects.
The computer interprets these curves and draws them in real time, so they can be
enlarged without a loss in quality. This also allows individual components of the image
to be edited due to being separate shapes, and overall results in a smaller file size.
Bitmap is a 2D grid of pixels (picture elements) that make up an image. Pixels are the
smallest part of an image and have a position and colour. Colour is defined using Red,
Green and Blue values. Below are definitions used in bitmaps.
File header: stores data about the file eg: file type, resolution, bit depth, compression
colour/bit depth: the number of bits per pixels assigned to represent colour
Image resolution: the number of pixels in an image (height of image×width of image)
Screen resolution: the number of pixels a screen can display (height of screen×width
of screen)
Due to bitmaps being made of pixels, when zoomed in, you can see the individual
pixels. To reduce this effect, you can have a higher image resolution, but that increases
the file size. This is why vector is used for images that need to be shown on a large
scale eg: logos.
The file size of a bitmap = colour depth(number of bits per pixel)×image
height×image width(resolution, ie: number of pixels in an image) ÷ 8 (to convert it
from bits to bytes)
Sound is an analogue (data from a physical quantity that is continuous) quantity, so
once it is recorded it is converted to digital(data from binary signals that take discrete
values) signals using an ADC (analogue to digital converter). The sound is recorded by
taking ‘samples’.
Sample: measuring and storing the amplitude of the sound at regular intervals
Sample resolution: the number of bits used to store each sample
Sample rate: the number of samples per second (should be at least twice the highest
frequency recorded in the sound)
Increasing the sample rate increases the accuracy by decreasing the time interval
between samples and reduces the quantization errors.Increasing sample resolution
also increases the quality and accuracy of the sound, but reducing sample resolution
to only the range that humans can hear can help reduce the file size while still retaining
quality. Increasing sample rate or sample resolution will however cause the file size to
increase, making it harder to transfer.

Links to: Past papers - Syllabus - Textbook Page 3


COMPUTER SCIENCE CAIE 9618
Chapter 1.3 - Compression
Compression is a type of coding technique that reduces the size of a file for eg:
transmitting it over the internet.
There are 2 types of compression, lossy (Which compresses more but loses data
permanently) and lossless (which compresses less but preserves the original file)
Lossy compression: data is permanently removed from the file to make it smaller, eg:
reducing image resolution, reducing colour depth, reducing sample resolution,
reducing sample rate, etc. These changes are all irreversible and the original file
cannot be reconstructed. Should be used for bitmaps, videos, sound files. Shouldn’t be
used on text files because it might get corrupted.
Lossless compression: data is encoded in such a way that no data is lost. Repeated
patterns in the data can be indexed and replaced with numerical values to reduce
duplicates. These changes are reversible and are used when the initial quality of the
file must be preserved eg: text files, vector graphics.
Run length encoding(RLE): a type of lossless compression for bitmaps that identifies
the same data repeated in a row. The algorithm replaces this sequence of data by a
copy of the data and the number of times it occurs. Eg: instead of AAAAA we get A5.
This may not work on an image where most/all of the bits are different, as there won't
be many sequences of the same colour. This can increase the file size, because R, G, B,
becomes R1, G1, B1, and data is added to the file.

When sending data, there are multiple factors to be determined before data can be
sent over a connection.
Data transmission direction
Simplex transmission: data can only be sent in one direction
Half-duplex transmission: data can be sent in both directions, but only one direction
at a time.
Full-duplex transmission: data can be sent in both directions at the same time.
Data transmission method
Serial: the data is sent one bit at a time over a single channel/wire.
Parallel: the data is sent multiple bits at a time over multiple channels/wires.
Data transmission synchronisation:
Synchronous: the sender and receiver sync their internal clocks before sending the
data in a continuous stream. The bits are separated according to the timing signals
and rearranged back into bytes.
Asynchronous: the data is sent in discrete packets, with control bits (start bit/stop bit)
to indicate when the data packet starts and ends.

Links to: Past papers - Syllabus - Textbook Page 4


COMPUTER SCIENCE CAIE 9618
Chapter 2.1 - Networks including the internet
WAN: Wide Area Network is a network type that covers a large geographical area. It
can cover cities and even continents and can be used in organisations to privately
transfer messages, files and actions between branches.
LAN: Local Area Network is a network type that covers a small geographical area. It
can cover a single room or building and allows multiple computers to access the same
files and external devices (printers, scanners). It is privately owned
Client-server: data and apps are stored on a server (web server), and to access it, a
client(a computer/web browser) will request the server to access data(eg a database or
some files), an application (maybe a website) or a service (online transactions, etc).
The web server will process the request and send the output to the client.
Thin-client: the client sends the input to the server, which runs the application and
sends the output back to the client.
Thick-client: The application is still run on the server, but the client processes most of
the data,(before/after the data is sent to the server).
Peer-to-peer: this is where each of the computers on the network store some of the
files, and can act as clients to request data from other computers. They can also act as
servers and provide data stored on them to other clients(other computers on the
network).
● Benefits: each computer has equal status because data is distributed when the
computers communicate. Each computer manages its own security
● Drawbacks: no central management of files/software/security/backups. it
requires all computers to be switched on to access data.
Cloud computing: accessing files/software/services that are stored on a remote server
using the internet. This allows you to access the same files/applications on any device,
regardless of the storage size or processing power of the device (because they are
stored/run on the server). There are private and public clouds.
● Benefits: it can be accessed anywhere with Internet access. Files can be easily
shared and multiple people can work on the same file at once. There is better
security, automatic backups, and less software & hardware requirements.
● Drawbacks: it is reliant on the cloud service provider for backups and security,
and the data becomes inaccessible if the server shuts down or if there is no
internet connection
Private cloud: Computing services offered either over the Internet or a private internal
network. Private clouds are dedicated and personalised to the organisation, and only
select users (eg: employees) have access to it.
Public cloud: Computing services offered by 3rd party providers over the public
Internet. Public is available to anyone with the appropriate software / login details
Network topologies: the configuration of a network that defines how the various
devices on the network are connected. The nodes (sometimes called end-systems), are
devices like computers, servers and printers and are the end points of data transfer.

Links to: Past papers - Syllabus - Textbook Page 5


COMPUTER SCIENCE CAIE 9618
A hybrid network is a network that consists of multiple networks that may use
different topologies.

Bus network: all nodes are connected to a single


shared cable, with a terminator at each end. Data
is sent between computers along the main cable
(the backbone), so all computers receive the data
packets, regardless of the intended receiver.
It uses two-way communication.
It is suited for small networks and becomes slow
in large networks. It’s easy to install and add
more nodes. The network won’t go down if one
node fails but will go down if the main cable fails.
Star network: all nodes are connected to a
central hub, all data packets are transferred
through the hub. Each node has its own two-way
connection to the hub.
More secure as only the intended receiver gets
the message. Easy to add more devices. The
network won’t go down if one node fails but will
go down if the central hub fails. Devices can use
different protocols. Performance is dependent on
the capacity of the hub.
Mesh network: all nodes are connected to at
least 1 other node. Computers act as relays to
pass data packets to its destination. Dedicated
connection and better security
This method is extremely inefficient and uses a
lot of wire(expensive), so is used to connect
individual LANs together instead of computers

Transmission medium for the connections in a network can be wired or wireless. Both
experience a decrease in signal strength across a distance (attenuation).
Wired: has higher bandwidth and is more reliable and secure than wireless.
Copper cable: carries data as electrical signals and can be coaxial or twisted pair. It is
harder to damage.
Fibre optic: uses a bundle of plastic thread to transmit digital data using light. It is
easier to damage.

bandwidth/speed/price/range/security attenuation/interference
Copper cable lower higher
Fibre optic higher lower

Links to: Past papers - Syllabus - Textbook Page 6


COMPUTER SCIENCE CAIE 9618
Wireless: provides freedom of movement and easier expansion of the network but the
communication is broadcast to all devices so is less secure.
Satellite: a communication device in orbit (space) that receives and transmits data
Radio waves: carries data using electromagnetic waves. Used in satellites & wifi
Microwaves: carries data using electromagnetic waves. Used across long distances
(e.g: phone calls). It is expensive, laggy and slow.

bandwidth/speed/attenuation/range Penetration power


Microwave higher lower
Radio wave lower higher
Network devices:
Switch: a central device connected to the other devices to transfer data packets. It
uses MAC addresses to make sure only the intended device receives the data packets.
Server: processes outgoing requests and incoming traffic and acts as a firewall/proxy.
Network Interface Card(NIC): a hardware device that interfaces with a wireless
network using an antenna. It encodes/decodes the data. It provides the MAC address.
Wireless Access Points(WAP): hardware device that allows the central device to
communicate with nodes on the network using radio waves.
Bridge: connects two or more LANs with the same protocol together. Can form a WAN
Repeater: device that amplifies incoming signals so they can travel longer distances.
Router: sends/receives data packets from the internet, forwards the packets to the
intended receiver using the IP address and by calculating the most efficient route. Has
a routing table of IP/MAC addresses and acts as a gateway and firewall. Can connect
devices with different protocols.
Ethernet: a protocol used to connect devices over a LAN, uses wired technology.
Sender and receiver nodes use MAC addresses for identification and all data is
transmitted over the same cable. Uses CSMA/CD to prevent collisions. Data is
transmitted in frames with a source and destination IP addresses and error checking .
Collisions occur when two or more devices try to send data along the same main cable,
causing the data packets to ‘collide’ and get corrupted.
Carrier Sense Multiple Access/Collision Detection (CSMA/CD): A computer that
wants to send data first checks the communication channel and only sends data if the
channel is free. If the channel is being used, it waits a random time before trying again.
If a collision is detected while transmitting, it sends a jamming signal and stops
transmitting. All computers will now wait a random time before trying again.
Bit streaming: data that is sent over the internet is turned into a series of bits for
compression and decoding purposes. Can be on-demand or real-time bit streaming.
On-demand: the data is continuously downloaded to the device in a buffer and is then
played from the buffer at the user's convenience, which empties the buffer so it can
store the next streamed data. This requires a high broadband connection. Can
play/pause/rewind/fast-forward because the data is stored on a server. E.g: youtube.

Links to: Past papers - Syllabus - Textbook Page 7


COMPUTER SCIENCE CAIE 9618
Real-time: the data is transferred to the device as it is being generated and encoded in
real time. Cannot play/pause/rewind/fast-forward because the data is live streamed.

Internet: an infrastructure made of a global connection of networks. Uses IP protocol.


World Wide Web(www): web pages and content accessed using the internet. Web
pages are written in HTML and it uses HTTP protocol to transfer.
Modem: devices used to connect digital network signals to analogue before
transferring and converting them back to digital on the receiving end.
Public Switched Telephone Network (PSTN): analogue network that uses modems
to carry digital signals.
Dedicated lines: a PSTN communication line that is leased out to an organisation.
Only the organisation can use the connection.
Cell phone network: mobile phones send data to a wireless cell tower that provides
an internet connection (mobile data).

IP address: an address that uniquely identifies a device connected to the internet. It is


used by devices to identify each other and communicate on the internet.
Static IP addresses: assigned by the ISP and are not changed when a computer leaves
and rejoins a network.
Dynamic IP addresses: assigned by the network OS and are different every time the
computer leaves and rejoins a network.
Public IP addresses: assigned by the ISP, can be accessed by anyone and is needed to
access the internet.
Private IP addresses: assigned by a router, cannot be accessed by anyone and is used
to communicate within the network.
IPv4: 4 bytes (32 bits) long, displayed as 4 decimal numbers separated by periods (“.”).
IPv6: 16 bytes (128 bits) long, displayed as 8 sets of 4 digit hexadecimal numbers,
separated by colons (“:”).
IP addresses are split into NetID and HostID. The NetID is the first part of the address
and it identifies a network. The HostID is the second part of the address and it
identifies a device on the network from the NetID. The number of bits assigned to
represent HostID and NetID depend on the requirements of the network.

Subnetting: when an organisation with multiple LANs connects the LANs to one
server, which acts as the network, and the NetID is split to identify each individual LAN
and the devices on them. This reduces congestion as data is split between segments,
improves security because a device can't access all segments, and allows for easier
extension of the network due to more IP addresses available.

The URL (Uniform Resource Locator) is typed in the web browser. The URL contains the
domain name, which is sent to a DNS (Domain Name Server), which has a database of
domain names and their corresponding IP address. If the IP address is found, it sends
the IP address to the web browser. Otherwise, the request is forwarded to another DNS

Links to: Past papers - Syllabus - Textbook Page 8


COMPUTER SCIENCE CAIE 9618
Chapter 3.1 - Computers and their components
Embedded systems are built into the device and cannot easily be changed by the user.
They consist of dedicated hardware and software designed for a specific function
Laser printer: a revolving drum is charged and a laser draws over the drum and
discharges the parts to be printed. The drum is coated with oppositely-charged
toner(powdered ink) and is rolled over charged paper before the paper is fused.
3D printer: a design is made in CAD (computer aided design) and is loaded to the
printer. The design is split into layers and printed by a 3D printer nozzle. The design is
then left to cure.
Microphone: there is a diaphragm which vibrates with sound. This causes a magnet to
move and produce an electric signal.
Speaker: electrical current in a coil creates an electromagnetic field which is
repelled/attracted to a permanent magnet. The magnetic field changes based on the
current/audio signal. This causes vibration in a diaphragm and produces sound.
Resistive touchscreen: consists of 2 charged plates, when the screen is touched the
plates are pushed together and complete a circuit and the coordinates of touch are
calculated.
Capacitive touchscreen: consists of layers of material that store charge, when the
screen is touched the charge is transferred to the finger and the coordinates of the
touch are calculated using sensors on the edge of the screen.
VR headset: consists of 2 eye-pieces that display paired images from a controlling
system.
Buffer: acts as temporary storage to store data before being used by the receiving
device. It allows devices to operate at different speeds.
Memory is data that can be directly accessed by the processor. Any data to be
operated on or processed must be moved from storage to memory.
Random Access Memory (RAM): volatile memory that can be read from and written
to, it is used to store programs/data currently in use.
Static RAM (SRAM): uses flip/flops and multiple transistors. It is more expensive but
doesn’t need to be refreshed and therefore has lower power consumption. It has lower
storage density and is faster,and is therefore used in caches.
Dynamic RAM (DRAM): uses a transistor and a capacitor. It is less expensive but needs
to be constantly refreshed and therefore has higher power consumption. It has higher
storage density but is slower, and is therefore used in main memory.
Read Only Memory (ROM): non-volatile memory that can only be read from and not
written to. It stores data that mustn't be changed and will retain the data even if the
device doesn’t have power. It stores: Boot-up instructions, system software, BIOS, etc.
In normal ROM chips, the manufacturer loads the data onto the chip and to change the
data, the whole chip needs to be swapped out. Other types of ROM exist to provide
more flexibility regarding the data stored in ROM.

Links to: Past papers - Syllabus - Textbook Page 9


COMPUTER SCIENCE CAIE 9618
Programmable ROM (PROM): the manufacturer produces blank chips that can only
be written to once, but it allows the programmers to test the ROM program using
samples before fully committing.
Erasable Programmable ROM (EPROM): the chip can be erased using UV light, but it
requires the ROM chip to be removed from the circuit. To rewrite the data, all previous
data must be erased.
Electronic Erasable Programmable ROM (EEPROM): the chip can be erased using
electrical technology and it doesn’t require the chip to be removed. It can rewrite data
without fully erasing the previous data.
Solid State Drive (SSD): flash memory, no moving parts, faster access time, data is
read from and written to in blocks. Eg: flash memory, USB sticks
Hard Disk Drive (HDD): data is stored on multiple platters which can be magnetised.
The platters spin on a spindle and are read by a read/write head that moves across the
surface. The platters are divided into tracks, sectors and blocks. It has more longevity
and can perform more read/write operations, and it is cheaper per unit data.
Hard disk formatter: software that prepares a hard disk for initial use by checking for
errors and clearing existing data. It also partitions the disk into logical drives and sets
up the file system.
Hard disk defragmenter: software that reorganises the hard disk’s contents by
moving split files so they are contiguous and creating larger areas of free space. It
makes files faster to access because there is no need to search for the next fragment of
a file, reducing read head movement.
Optical storage: data is stored on discs (e.g: CD, DVD, Blu-Ray). A drive motor spins the
discs, a laser beam is shone on the disc to read/write and stores data on the disc in pits
and lands. The disc surface has a reflective metal layer that reflects light to be encoded
as bits.
Control system: can produce an action based on the circumstances.
Monitoring system: can only notify/alarm based on circumstances.
Feedback: it allows the system to automatically adjust conditions by enabling system
output to affect subsequent system input. It ensures that the system operates within
the given criteria.
A system will have sensors (input devices), a (micro)processor and actuators (output
devices).
Examples of sensors: pH, temperature, humidity, pressure, motion, light, proximity, etc
Examples of actuators: motor, alarm, printer, valve, etc.
The sensor sends data to the microprocessor, where the data is converted from
analogue to digital using an ADC and the microprocessor checks the input values
against stored values. If the data are out of range, the microprocessor sends a signal to
cause an output/action. The output/action is done by an actuator. The whole process
is continuous.

Links to: Past papers - Syllabus - Textbook Page 10


COMPUTER SCIENCE CAIE 9618
Chapter 3.2 - Logic gates & logic circuits
All logic gates take two binary inputs (except NOT, which takes one input) and gives a
single binary output based on logic calculations.
NOT gate: outputs 1 when the input is 0 & outputs 0 when the input is 1
AND gate: only outputs 0 when both inputs are 1. Otherwise outputs 1
NAND (NOT+AND) gate: only outputs 1 when both inputs are 0. Otherwise outputs 0
OR gate: only outputs 1 when at least one input is 1. Otherwise outputs 0
NOR (NOT+OR) gate: only outputs 0 when at least one input is 1. Otherwise outputs 1
XOR GATE: only outputs 1 if one input is 1 and the other input is 0. Otherwise outputs 0
When drawing logic circuits, a junction
is marked by a dot where the wire splits.
Junctions are used to split a signal
along two or more wires.

An overlap is marked by a ‘hump’, so


that when wires cross they aren’t
confused with junctions.

Links to: Past papers - Syllabus - Textbook Page 11


COMPUTER SCIENCE CAIE 9618
Chapter 4.1 - Central Processing Unit (CPU) architecture
The Von Neumann model describes a computer where data and instructions are stored
in the same memory space/in main memory.
Registers are small storage components with fast access times. General purpose
registers don’t store any specific data and can instead store data to be used in
upcoming calculations, or as a temporary/intermediate value, etc. Special purpose
registers have names and set labels for the data they store. These are:
Program Counter (PC): stores the address of the next instruction to be fetched
Memory Data Register (MDR): stores the data that has been read from/will be written
to memory.
Memory Address Register (MAR): stores the address in memory that will be read
from/written to.
Accumulator (ACC): functions as a general purpose register.
Index Register (IX): stores a value that is added to an address to get another address
Current Instruction Register(CIR): stores the value of the instruction being executed
Status register (SR): stores flags that are set by the CPU
Parts of the Von Neumann model:
Arithmetic and Logic Unit (ALU): carries out calculations and logical operations
Control Unit (CU): manages the flow of data and interactions between the
components and the processor using an internal clock and a system clock. The internal
clock generates timing signals which are sent using the control bus to synchronise
components in the CPU and the system clock generates timing signals for the
components outside the CPU.
Immediate Access Store (IAS): components that are directly addressable by the
processor. It stores all the data currently in use and is volatile.
Address bus: unidirectional bus that carries an address from the processor.
Data bus: bidirectional bus that carries data between input and output devices,
memory, and the processor.
Control bus: bidirectional bus that carries timing signals between the control unit and
components. Can carry read, write, timing and interrupt signals.
The Fetch-Decode-Execute cycle (F-E cycle):
1. The PC holds the address of the next instruction to be executed
2. The address is sent to the MAR using the address bus
3. The MDR fetches the instruction from the address in MDR using the data bus
4. The instruction is copied from the MAR to the CIR using the data bus
5. The CU decodes the instruction’s opcode
6. The instruction is executed
7. The PC is incremented to point to the next instruction
In register transfer notation:
1. MAR ← [PC]
2. MDR ← [[MAR]]
3. CIR ← [MAR]
4. PC ← [PC] + 1

Links to: Past papers - Syllabus - Textbook Page 12


COMPUTER SCIENCE CAIE 9618
In register transfer notation, where square brackets “[]” are used to get the value from
the address inside the brackets. Here register names(like MAR, MDR, PC) are treated
like addresses, so [MDR] will get the data stored in the MDR. [[MAR]] will get the data
stored at the address that is stored in the MAR. arrows “←” are used to copy the data
on the right of the arrow and store it in the address on the left of the arrow.
Factors affecting performance of the computer system:
Number of cores: each core can process one instruction per clock pulse, so having
more cores means the sequence of instructions can be split between them, decreasing
the time taken to complete a task. Because the cores are independent processing can
be done in parallel
Clock speed: since one instruction is executed per clock pulse, increasing clock speed
increases the number of instructions that can be executed per second.
Bus width: the number of bits each bus can transfer at a time, increasing it allows
more data to be transferred per cycle (only affects data and address bus).
Cache memory size: fast access memory that stores frequently used instructions,
higher cache size means more instructions can be accessed faster.
Word length: the number of bytes that can be handled as one unit by the processor.
Usually 16, 32, & 64 bits long. Longer word length allows more data to be processed.
Connections to peripheral devices:
Universal Serial Bus (USB): industry standard for connection, so all computers will
have the port and because it is plug-and-play it doesn’t need drivers. It is backwards
compatible, and has fast data transfer for large files. It provides power and allows
devices to be charged while connected to the computer. Uses serial transmission & can
be synchronous or asynchronous. USB-3 is full duplex & older versions are half duplex
High Definition Multimedia Interface(HDMI): high quality video & audio data transfer
Video Graphics Array (VGA): high quality video data transfer only (no audio)
Interrupts: signals sent from a device/process that requests the attention of the
processor. A special-purpose interrupt register is used to detect interrupts. When a
bit/flag is set in the register, it indicates an interrupt and the interrupt handling process
begins.
Interrupts send a signal from a device to seek the attention of the processor. It allows
for multitasking, fair use of the processor/memory/peripherals, and allows all
programs to finish executing. Examples: stack overflow, hardware fault, user input.
Interrupt Service handling Routine (ISR): a program that is loaded into the program
counter when an interrupt is detected, and finishes executing once the interrupt has
been serviced.
Interrupts are detected at the start/end of each F-E cycle and the priority of the
interrupt is checked. If the interrupt is a higher priority than the current process, the
current process is stopped and stored on a stack. The type of interrupt is identified and
the appropriate ISR is called. Once the ISR is finished, check for any interrupts of higher
priority, otherwise load the data from the stack and continue with the next F-E cycle.

Links to: Past papers - Syllabus - Textbook Page 13


COMPUTER SCIENCE CAIE 9618
Chapter 4.2 - Assembly language
Computers only process instructions in machine code (binary). A machine code
instruction consists of an opcode (the action eg: add, load, write) and optionally, an
operand (values that are needed for the instruction eg: an address, a value, etc), all
written in binary. These instructions can vary from processor to processor.
Machine code instructions are written in assembly language. Operands that are
numbers have a symbol before the number to indicate which number system is being
used. Denary uses ‘#’, Binary uses ‘B’, and Hexadecimal uses ‘&’. There are conditional
and unconditional, input/output, compare, arithmetic, and data movement opcodes
Since the instructions need to be in machine code, an assembler is used to translate
assembly language into machine code (.exe file). The program before translation is
called the source code and the prograg after translation is called the object code.
Assemblers translate the source code in 2 passes:
1. The first pass reads the program one line at a time, it removes comments and
white space, it creates the symbols table and adds labels to it(defining any
symbolic addresses/variables used), and checks that all opcodes are in the
processor’s instruction set.
2. The second pass reads the code one line at a time and generates the object code
In assembly language, when data is loaded into the accumulator, there are different
ways of loading the data from the operand, each with their own opcode.
immediate addressing (LDM): the operand is the data to be loaded
Direct addressing (LDD): the operand is a memory address that holds the data to be
loaded
Indirect addressing (LDI): the operand is a memory address that stores a memory
address that stores the data to be loaded
Indexed addressing (LDX): the operand is a memory address and it is added to the
value in the index register (IX) to get the new address that stores the data to be loaded
Relative addressing: the operand is a number that represents an offset value from the
current address to get the new address that stores the data to be loaded
In assembly, operations can be performed on binary bits. These include:
Logical shift (LSL/LSR): all bits are shifted left/right, and zeros are set where the bits
used to be
Cyclic shift: all bits are shifted left/right, and bits that are shifted out of one end
reappear on the other end
Arithmetic shift: using logical shifts to multiply/divide signed integers by 2.
All logical operations (AND, OR, NOT, etc) can be applied to binary numbers to
manipulate bits and can be used in a control/monitoring system.
Bit masking (controlling the value of certain bits) operations:
XOR 11111111 will toggle/flip all bits (turn 1s into 0s and 0s into 1s)
OR 11111111 will set all bits to 1
AND 00000000 will set all bits to 0
AND 11111011 will set the only third bit to 0 (here the bit of interest is the third bit)
OR 00010000 will set only the fifth bit to 1 (here the bit of interest is the fifth bit)

Links to: Past papers - Syllabus - Textbook Page 14


COMPUTER SCIENCE CAIE 9618
Chapter 5.1 - Operating Systems
The operating system handles memory, peripherals, file, security, interrupt, and
process management, and checks for errors. It creates/renames files/folders. It creates
accounts/passwords and updates the firewall.
Memory management: it assigns RAM into blocks and dynamically allocates blocks
for programs and reclaims unused blocks.
Process management: It schedules processes and manages the resources for the
processes, like allocating memory. It allows processes to share data and prevents
interference. It allows multitasking by handling interrupts and using priorities.
Peripheral management: it installs device drivers to allow communication between
the peripheral device and the computer. It sends/receives data from input/output
devices, handles interrupts, and uses buffers.
Utility software is software that is provided by the operating system and runs only
when the user decides to perform some helpful action. e.g: defragmentation software,
disk formatter, file compression, disk repair software, virus checker, back-up software.
Virus checker: scans for malicious self-replicating program code and quarantines and
deletes it. It schedules virus scans and regularly updates virus definitions.
Backup software: creates copies of disk contents automatically/on schedule and can
be used to restore data. It allows the user to choose what is backed up and may
encrypt the data.
Disk repair software: it marks areas of the disk that have errors/become corrupt so
that they can be repaired/ avoided.
When writing code, certain functions are used over again like average, cosine, etc.
Library routines: a set of pre-written subroutines that can be called in a program after
being imported.
They speed up development time because they are already tested and error free. They
can perform actions that the programmer doesn’t know how to implement like
encryption or maths. They also update automatically.
However, when compiled, every program that uses routines must have their own copy.
This increases the storage space required and the memory used by the program. This
can be avoided using a DLL.
Dynamic Linked Libraries (DLL): a collection of compiled library routines that are
stored separate from the ‘.exe’ file. It links to the main program during execution and is
only loaded into memory when required at runtime. Multiple programs can use the
same DLL at the same time and the DLL can be updated.
Chapter 5.1 - Language Translators
Assemblers translate low level languages (assembly language) into object code.
Compilers and interpreters translate high level languages (Python, Java, C, etc) into
object code.

Links to: Past papers - Syllabus - Textbook Page 15


COMPUTER SCIENCE CAIE 9618
Compiler: translates the high-level program at once and creates an executable
machine code file. If errors exist in the code, it will go through the whole program and
output a list of all errors, and will not produce object code.
Interpreter: reads, translates, and executes the high-level program one line at a time
and does not create an executable machine code file. If it encounters an error, it
reports the error and stops interpreting. It requires the source code to be available
every time the program is run.
An interpreter is better for debugging and developing an incomplete program because
the developer can make real time changes, and can test the program even when
incomplete, allowing small parts of the program to be tested and avoiding
independent errors. A compiler would take longer to compile the whole program and
wouldn’t run if there were errors.
A compiler is better for testing and distributing a complete program so that the
customer/user can’t access/edit/sell the code, whereas an interpreter would require
the customer to have a copy of the source code to be interpreted each time to run the
game. The developer can also test the program multiple times without having to
recompile each time. The compiled machine code can also be optimised for different
hardware specifications.
Some programs like Java are partially compiled and partially interpreted. The partially
compiled code can be run on different platforms because the code is optimised for the
CPU when interpreted at runtime.
Integrated Development Environment (IDE) is a software used to write programs that
come with features to make programming easier, these are:
Context sensitive prompts: suggests the code to add and automatically completes
statements as the code is written.
Dynamic syntax checks: checks the syntax of a line after it has been typed and
highlights syntax errors where found.
Prettyprint: keywords/ command words are colour coded automatically.
Expand/collapse code blocks: allows the programmer to cofocus on a single section
of code and navigate the code quicker.
Automatic indentation: allows the programmer to see the different code sections.
Single-stepping: debugging by running the code one line at a time so values can be
checked.
Breakpoints: debugging by stopping the code at a specific line to check the current
values.
In code, if a program doesn’t compile, it is due to a syntax error, which is an error
caused by incorrect formatting/structure of the code according to the programming
language.
If a program compiles but doesn’t work as expected, it is a logical error. Logical errors
are the fault of the programmer and because of that, they will not be detected by the
compiler/interpreter.
Links to: Past papers - Syllabus - Textbook Page 16
COMPUTER SCIENCE CAIE 9618
Chapter 6.1 - Data Security
Data security: protecting data from loss and corruption
Data integrity: ensuring data is accurate and consistent
Data privacy: ensures data can only be accessed by authorised users
Security of data and a computer system ensures that data isn’t lost, deleted, corrupted,
stolen, or accessed by unauthorised users.
Threats to computer (malware) and data (being amended):
Malware: malicious software designed to cause damage to a computer system
Virus: malware that is downloaded without the user’s knowledge and runs in the
background, replicating itself to fill the hard disk and crash the computer, along with
corrupting files.
Spyware/keylogger: malware that is downloaded without the user’s knowledge and
runs in the background. It records the users keystrokes and sends it to a third party to
be analysed to find eg: passwords. It doesn’t damage the device or its data.
Hacker: someone who gains unauthorised access to a computer system with
malicious intent to download malware, corrupt files, steal data, etc.
Phishing: a fake email containing a link or attachment that directs the user to a fake
website that is designed to collect personal data and use it illegally.
Pharming: malware that modifies DNS entries to redirect the user to a fake website
that is designed to collect personal data and use it illegally.
Security measures:
User accounts & password: requiring authentication and a strong password to
prevent unauthorised access.
Biometrics: patterns in face, voice, retinas and fingerprints are used to identify a
person and grant access. It cannot easily be faked and is unique to each person.
Digital signature: used to securely send documents. The sender hashes the document
to produce a ‘digest’ which is encrypted to create the digital signature. The receiver
decrypts the signature to get the digest and rehashes the document and compares the
digests. If they are the same the document is authentic.
Antivirus: automatically updates a stored database of known viruses. scans the
computer for viruses and checks against its database, and quarantines and deletes
them. It compares downloads against its database and prevents the download if a
virus is detected.
Antispyware: automatically updates a stored database of known spyware. scans the
computer for spyware and checks against its database, and quarantines and deletes
them. It compares downloads against its database and prevents the download if a
spyware is detected.
Firewall: monitors incoming and outgoing traffic and checks them against a criteria
set by the user and blocks all traffic that doesn’t meet the criteria. Can whitelist /
blacklist IP addresses and prevents unauthorised access.
Access rights: the administrator has different accounts with different access rights
each, allowing them to access different elements. Specific views can be assigned to
only the administrator that allow them to see confidential information.

Links to: Past papers - Syllabus - Textbook Page 17


COMPUTER SCIENCE CAIE 9618
Encryption: encoding data so that it is meaningless if intercepted. Plaintext (the
unencrypted data) is converted to ciphertext/cyphertext (the encrypted data) using a
cipher key. The cipher key is used by the receiving end to decode the data.

Chapter 6.2 - Data Integrity


Data validation ensures that the data is reasonable/sensible while data verification
ensures that the data is entered as intended. Both are required for data integrity.
Validation checks:
Presence check: checks if some data is entered
Length check: checks if data entered is of a certain length, e.g: 8 characters long
Range check: checks if data entered is within a certain range, e.g: 50 <= height <= 250
Format check: checks if data entered follows a pattern, e.g: dd/mm/yyyy
Limit check: checks if data entered is less than a certain value, e.g: age < 100
Type check: checks the datatype of the entered data, e.g: integer
Existence check: checks if the file that is submitted exists
Verification checks on data entry:
Double entry: data is entered twice and checked by the system to see if they match
Visual check: data is entered is checked with the original document by the human
Verification checks during data transfer:
Checksum: a checksum is a value calculated from the data before transmission, and it
is sent along with the data. The receiving device recalculates the checksum and
compares the two checksums. If they are the same then no error has occurred, if they
are different an error has occurred and the data is re-sent.
Parity check: parity bit is the most significant bit and it sets the total number of 1s in a
byte to be either be even or odd, depending on the parity used. The type of parity
(even or odd) is agreed upon by the sender and receiving devices beforehand. A parity
byte is added at the end of a block of data, where each bit sets the parity for the other
bits in that bit position in the byte. In other words, the parity bits set the parity for the
rows and the parity byte sets the parity for the columns.

Links to: Past papers - Syllabus - Textbook Page 18


COMPUTER SCIENCE CAIE 9618
Chapter 7.1 - Ethics and ownership
Ethics are a system of moral principles to guide decision making. The British Computer
Society (BCS) and the Institute of Electrical and Electronic Engineers (IEEE) have
created a code of ethics.
● Ensure product meets requirements and is delivered within the budget and
deadline. The product is well documented and error-free.
● Be fair and supportive to colleagues and fully credit any work done by other
members of the team.
● Keep the clients personal information private, keep the client informed on
development and delays.
● The IEEE has 8 key principles in its ethics: Colleagues, self, profession,
client-and-employer, product, judgement, management, and public.
Copyright: a formal recognition of ownership of a created idea or work.
There are different licences for software that define how it is sold and used, these are:
Commercial licence: the software is copyrighted and sold for a fee, which gives the
creator income and prevents against the program being edited or stolen.
Shareware licence: the software is copyrighted and free for a trial period with limited
features, then users must pay for it. This prevents the program being edited or stolen
and lets more people experience it and become more likely to buy it.
Free software foundation licence / Open-source Initiative licence: the source code
is distributed with the software. This allows users to customise the code, collaborate,
find bugs and add new features.
Artificial intelligence (AI) improves speed in doing tasks, which reduces cost (Economic
impact), but it can cause unemployment(social impact), and training & running an AI
requires electricity which produces CO2 emissions(environmental impact)
Artificial Intelligence (AI): it stores the rules and past decisions and it is trained by
doing the task over and over again. It will look at the possible moves and analyse the
pattern of past choices to choose the best option. It can learn from previous mistakes.
face tracking: monitors every image taken and matches features to a person. The
system identifies direction of movement and uses this to follow the person. Can make
errors, cause delays, and is an invasion of privacy. However, It can help catch criminals
and board people faster at airports.
speech recognition: identifies key words spoken and matches this against a database
to generate the most likely sentence.
Self driving cars: the AI detects its position on the road and in traffic and follows a
route while avoiding collisions.
Gaming: it can model characters in a video game to allow characters to react
according to the players movements.

Links to: Past papers - Syllabus - Textbook Page 19


COMPUTER SCIENCE CAIE 9618
Chapter 8.1 - Database concepts
There are two types of databases, flat-file databases and relational databases.
Flat-file uses a single table without relationships and can cause problems with data
integrity.
Relational databases have multiple tables and relationships between these tables.
They are better than flat file databases because they have:
● Reduced data redundancy
● Allows for program-data independence
● Allows for queries
● Improved data integrity
● Improved data privacy
Entity: anything that data can be stored about
Record(Tuple): a row in a table
Field(Attribute): a column in a table
Primary key: a field that uniquely identifies a record
Candidate key: a field that could be chosen as primary key
Secondary key: a field that was not chosen as primary key
Composite primary key: two or more fields that together form the primary key
Foreign key: a field in one table that links to the primary key in another table
Indexing: using another table to make searching for data faster.
Redundancy: when data is repeated in a database.
Referential integrity: using a foreign key to prevent data that doesn’t exist in the
referenced table from being entered. Every foreign key has a corresponding primary
key. Prevents records from being modified incorrectly.
Normalisation is a design technique for creating and designing tables. There are 3
different normal forms:
First Normal Form (1NF): no repeating fields/records, atomic values, & a primary key
Second Normal Form (2NF): 1NF + all attributes must be dependent on the primary
key (partial dependency).
Third Normal Form (3NF): 2NF + all attributes must not be dependent on non-key
attributes (transitive dependency).
There are 3 types of relationships between tables in a database:
● one-to-one(1:1), is when only one element in a table links to one element in
another table.
● one-to-many(1:m), is when one element in a table links to multiple elements in
another table.
● many-to-many(m:m), is when multiple elements in a table link to multiple
elements in another table.
using the connection symbols shown, connect tables having the same field names and
basing the connection type on the description of the tables when drawing an ER (entity
relationship) diagram.

Links to: Past papers - Syllabus - Textbook Page 20


COMPUTER SCIENCE CAIE 9618
Chapter 8.2 - Database Management System (DBMS)
Database management software (DBMS) is a software that controls access to the
database.
Developer interface: software tools provided by a DBMS for creating tables
Query processor: software tools to create and execute queries written in SQL
Query: used to select data from a database based on certain conditions
Data dictionary: stores metadata about the database eg: table names, relationships…
Data integrity: ensures data is consistent using validation rules
Data security: keeping data safe through backups and access rights.
Logical schema: the overview of a database that models the situation, and is not
specific to any DBMS. Can use an E-R diagram.

Chapter 8.3 - DDL and DML


Data Definition Language (DDL) is used to create and modify the database structure
Data Manipulation Language (DML) is used to create queries and maintain the data
Both use the industry standard, Structured Query Language (SQL), which always ends
each program in a semicolon ‘;’.
DDL keywords:
CREATE DATABASE name; Creates a database called “name”

CREATE TABLE name (...); Creates a table called “name”

field DATATYPE, Declares “field” of type DATATYPE

field DATATYPE NOT NULL, for a primary key/non-null field

ALTER TABLE name (ADD field DATATYPE…) ; Edits the table “name” & adds “field”

PRIMARY KEY (fieldname) Sets fieldname as the primary key

FOREIGN KEY (field1) REFERENCES table(field2) Links “field1” to “field2” in “table”

DDL datatypes:
CHAR(n) An alphanumeric string of fixed length of n characters

VARCHAR(n) An alphanumeric string of maximum n characters

BOOLEAN Either TRUE or FALSE

INTEGER A positive/negative whole number

REAL A positive or negative decimal number

DATE A date

TIME A time

Links to: Past papers - Syllabus - Textbook Page 21


COMPUTER SCIENCE CAIE 9618
DML keywords for queries
SELECT field1, field2... FROM table; Selects only ‘field1’ & ‘field2’ from table
SELECT field1 AS name ...; Renames ‘field1’ as ‘name’ in the query
SELECT ... FROM ... WHERE condition; Selects records that satisfy ‘condition’
...WHERE condition1 AND condition2 Multiple conditions using AND/OR/NOT
SELECT ... FROM ... ORDER BY field ASC; Orders the data in ascending order
SELECT ... FROM ... ORDER BY field DESC; Orders the data in descending order
SELECT ... FROM ... GROUP BY field ASC; Groups the data in ascending order
SELECT ... FROM ... GROUP BY field DESC; Groups the data in descending order
SELECT...FROM table1 Temporarily links ‘field1’ from ‘table1’ as
INNER JOIN table2 ON table1.field1 = table2.field2; .foreign key to ‘field2’ from ‘table2’.
…WHERE table1.field1 = table2.field2; Temporarily links ‘field1’ from ‘table1’ as
.foreign key to ‘field2’ from ‘table2’.
SELECT COUNT(field) FROM table; Counts the number of records in ‘field’
SELECT SUM(field) FROM table; Totals the values ‘field’(must be INTEGER)
SELECT AVG(field) FROM table; Averages the values ‘field’(must be INTEGER)

A query will create and display a table that meets certain criteria. These operations can
be joined together to create complex queries.
Dates are expressed as #dd/mm/yyyy#
The ‘condition’ can be used to specify what type of data to find. Multiple conditions
can be combined using AND and OR keywords.
Conditions can use equality symbols (<, >, <=, >=, <>, =) to search fields containing
numbers (e.g: integer, date, time). Conditions can use = “word” to check if the value in
the field is exactly equal to “word”, this only works for non-numeric fields.
To search non-numeric fields for parts of a value, wildcards must be used.
field1 = “%a” will select records where the value in ‘field1’ ends in ‘a’
field1 = “a%” will select records where the value in ‘field1’ starts with ‘a’
field1 = “%a%” will select records where the value in ‘field1’ contains ‘a’
The ‘%’ symbol acts as a placeholder for any letters or numbers.
DML keywords for maintaining data

INSERT INTO table VALUES(value1,value2,value3...); Adds ‘value1’, ‘value2’, ‘value3’... to the table
DELETE FROM table WHERE condition; Deletes records that satisfy conditions
UPDATE table Replaces the values in ‘field1’ and ‘field2’
SET field1 = value1, field2 = value2... with value1 and value2 in all records where
WHERE condition; the condition is met.

Links to: Past papers - Syllabus - Textbook Page 22


COMPUTER SCIENCE CAIE 9618
Practical
Pseudocode
When a variable is declared, the datatype of the variable must also be specified.
Datatype refers to the kind of data stored in the variable and how the program will
treat it in calculations, assignment, etc. The pseudocode datatypes are:
A single alphanumeric
CHAR BOOL only two values, TRUE and FALSE
character, e.g: ‘1’, ‘a’, ‘#’, ‘D’
Multiple alphanumeric A set of multiple variables of the
STRING ARRAY
characters, e.g: “word”, “A1” same datatype under one name
REAL A decimal number, e.g: 1.13, -0.7 FILE A .txt file that stores data as strings
INTEGER A whole number, e.g: -5, 299, 0 DATE A date, e.g: 01/01/2001

A record structure is a user defined datatype that holds a set of variables of different
datatypes under one identifier. Records structures are defined as:
TYPE RecordName
DECLARE Variable1 : DATATYPE
DECLARE Variable2 : DATATYPE

ENDTYPE
To access the variables in a record, use: RecordName.Variable1, RecordName.Variable2
All variables must be declared before being used. Format: DECLARE name : DATATYPE
To declare a constant value (i.e one that will not change): CONSTANT name = value
Note how an equal sign is used instead of an arrow, and no datatype is specified.
● Assigning values is done using arrows. e.g: Count ← 0
● Input values using the INPUT keyword. e.g: INPUT Name
● Output strings using string formatting e.g: OUTPUT “Hello ”& Name
Functions and Procedures are sections of code that can be ‘called’ during the program.
When they are called, the section of code where the function/procedure is defined is
run. Functions/Procedures have to be defined first before being used.
To call a procedure, use the ‘CALL’ keyword: CALL name()
Functions ‘return’ a value, which means that once they are done executing, the
function call gets replaced with that value. e.g: Answer←root(9) becomes Answer←3
Procedures are like functions except they don’t return a value, but instead output a
message or perform some calculation.
Functions/Procedures can take parameters, which are values or variables that are
written inside the brackets during the function call. They can take 0, 1 or more
parameters, as long as the parameters are included in the function’s/procedure’s
definitions.
These parameters can be used in the procedure for calculations. When the procedure is
called, the parameter is assigned the value in the corresponding position(i.e: the first
parameter is assigned the first value, the second parameter is assigned the second
value, etc).
Links to: Past papers - Syllabus - Textbook Page 23
COMPUTER SCIENCE CAIE 9618
Defining a procedure
PROCEDURE name(parameter1: DATATYPE, parameter2: DATATYPE...)
Procedure definition
ENDPROCEDURE
These parameters can be used in the procedure for calculations. When the procedure is
called, the parameter is assigned the value in the corresponding position(i.e: the first
parameter is assigned the first value, the second parameter is assigned the second
value, etc).
However, since only the value is copied to the parameter and not the actual variable
itself, we cannot actually edit any variables passed as parameters.
To solve this, use the BYREF keyword to allow you to edit the variables that is passed as
the parameter. e.g: FirstName: STRING, BYREF…
Defining a function
FUNCTION name(parameter1: DATATYPE, parameter2:DATATYPE...)RETURNS DATATYPE
Function definition (must include a return statement)
ENDFUNCTION
The function works similar to the procedure, except it returns a value. The datatype of
the return value must be specified in the function header after the ‘RETURNS’ keyword.
To return a value or variable during a function’s definition, use the RETURN keyword.
e.g: RETURN Total. Once a value is returned, the function stops, because it fulfils its use
Selection and iteration statements
IF condition1 THEN Executes ‘statements1’ if ‘condition1’ is true. Multiple conditions
statements1 can be there using AND/OR/NOT.
ELSE IF condition2 THEN The ELSE IF checks if ‘condition2’ is true in case ‘condition1’
statements2 isn’t. There can be multiple ELSE IF statements.
ELSE If both aren’t true then the ELSE executes. The ELSE IF and ELSE
statements3
ENDIF statements are optional.

CASE OF variable Used as an alternative to nested IFs, it checks if the value of


1: statements1 ‘variable’ is equal to 1,2 or 3, and executes ‘statements1’,
2: statements2 ‘statements2’, and ‘statements3’ accordingly.
3: statements3 If the value of ‘variable’ is none of those values, it will default
OTHERWISE statements4 and execute ‘statements4’. This can be used to check the values
ENDCASE of a variable faster than IF statements
FOR count ← a TO b This declares an INTEGER variable ‘count’, sets it to ‘a’ (a
statements number) and executes ‘statements’ in a loop until count equals
NEXT count ‘b’. This is a count-controlled loop
WHILE condition DO This executes ‘statements’ in a loop as long as ‘condition’ is true.
statements The loop may not run if ‘condition’ isn’t true.
ENDWHILE This is a precondition loop
REPEAT This executes ‘statements’ in a loop as long as ‘condition’ is
statements false. The loop will run once even if ‘condition’ is true.
UNTIL condition This is a postcondition loop

Links to: Past papers - Syllabus - Textbook Page 24


COMPUTER SCIENCE CAIE 9618
Arrays
An array is a group of multiple variables of the same type under one name. Arrays have
elements, and each element in the array has an index which can be used to access the
element. To declare a 1D array:
DECLARE name : ARRAY[a : b] OF DATATYPE
This creates an array called ‘name’ with elements whose index starts at ‘a’ and ends at
‘b’ inclusive. All elements in this array have the same datatype.
To access an element of an array:
Name[index]
Where ‘Name’ is the name of the array and ‘index’ is the index of the element.
‘Name[index]’ can now be treated as a variable, which means it can be assigned,
reassigned, input, output, used for calculations and comparisons, etc.
2D arrays are a type of array that stores values in a grid with rows and columns.
To declare a 2D array:
DECLARE name : ARRAY[a : b, c : d] OF DATATYPE
This creates a 2D array called ‘name’ with rows that start at index ‘a’ and ends at index
‘b’, and columns that start at index ‘c’ and end at index ‘d’. To access an element in a 2D
array:
Name[row,column]
Where ‘row’ is the row number and ‘column’ is the column number of the data
Files
Files are useful because they can contain persistent data, which will be there even
when the program has stopped running. Files can be read from and written to. Files
must be opened for a specific use and then closed before the program stops running.

OPENFILE filename FOR READ Allows the file ‘filename’ to be read from only

READFILE filename stringname Copies a line of text from ‘filename’ and stores it
in the string variable ‘stringname’

OPENFILE filename FOR WRITE Allows the file ‘filename’ to be written to only

OPENFILE filename FOR APPEND Allows the file ‘filename’ to be appended to only

WRITEFILE filename stringname Copies the string variable ‘stringname’ and


writes it in the next line in the file ‘filename’

CLOSEFILE filename Closes the file ‘filename’

Writing to a file will overwrite the existing file, meaning that whatever data was in the
file is now erased, and the writing of the file will begin from the start. Reading and
writing from files counts as input and output statements respectively.

Links to: Past papers - Syllabus - Textbook Page 25


COMPUTER SCIENCE CAIE 9618
If a file is opened for writing and it doesn’t already exist, a new file will be created.
e.g: OPENFILE Books FOR WRITE creates a new file called ‘Books’
Appending to a file will go to the end of the file and start adding the text there, which
means that the original data in the file is still intact.
While reading a file, you will eventually read the last line. To prevent the code from
running after reaching this point, use the EOF(filename) function. The EOF function
returns true when the end of the file has been reached and false otherwise.
Important algorithms:
Bubble sort

Linear search

Links to: Past papers - Syllabus - Textbook Page 26


COMPUTER SCIENCE CAIE 9618
Flowchart symbols:
Symbol Definition
Start and End: the program must always start at the Start
block and end on the End block.

Assignment: used to set the values of variables


e.g: Count ← Count + 1
Input and Output: these blocks are for input/output.
e.g: INPUT Num, OUTPUT “the count is” + Count
Decision: Conditional statement that has two labelled
outcomes, Yes & No. It’s in the format: Is condition ?
e.g: Is Num > 5 ?
Procedure / Function: used to call a function.
e.g: Answer ← isPrime(Num)

Abstract data types(ADT):


These are generalised program concepts that define how data is stored and linked in
memory. Pointers are data that contain an address in memory, so following a pointer
will lead to data stored at the address specified by the pointer. A null pointer is a
pointer that doesn't point to anything.
Stack: items are added (pushed) to the top of the stack and items are removed
(popped) from the top of the stack. The TopOfStack pointer points to the newest item
on the stack. It is where the next item will be pushed/popped, and has a value of -1
when the stack is empty. The BaseOfStack pointer points to the oldest item on the
stack. This pointer usually will not move.
Queue: items are added at the end of the queue and items are removed from the front
of the queue. This works on a first-in-first-out (FIFO) basis. The FrontOfQueue pointer
points to the oldest item, which is the next item to be removed. The EndOfQueue
pointer points to the newest item, and is where the next item will be added. This
pointer has a value of -1 when the queue is empty. In a circular queue, when the
pointers reach the end of the memory block, it will wrap around to the other end of the
memory block and continue normally.
Linked List: this is similar to an array, except the individual list items are stored in
separate places in memory, and one list item points to the next item in a list. Each list
item is made up of nodes, where each node consists of data and a pointer. Each node
will point to the next node, with the last node’s pointer being a null pointer. There is a
start pointer, which is a variable that points to the first node in the list.
To add a new node in the middle of a list, make the new node point to where the
previous node was pointing, and make the previous node point to the new node. This
is much easier than inserting an item in an array, which is why a linked list is used.

Links to: Past papers - Syllabus - Textbook Page 27


COMPUTER SCIENCE CAIE 9618
There are 5 different stages in the program development life cycle: Analysis, design,
coding, testing and maintenance. The project requirements are identified in the
analysis stage, a structured chart is used in the design stage, and documentation is
produced during the coding and testing stages.
There are 3 types of maintenance. Perfective maintenance continues to improve the
program even though there are no bugs. Adaptive maintenance accommodates a new
change in the requirements/technology of the project. Corrective maintenance is used
to remove bugs that weren’t found in testing.
There are different ways the development team can approach the order of these
stages:
Waterfall: here, each stage of the program is completed before moving on to the next,
and can return to previous stages to make changes. This is easier to estimate a
timeframe and provides documentation, but is slower and takes longer to get a
working model.
Rapid Application Development (RAD): here, the modules are developed in parallel
without planning to produce prototypes that are gradually improved. This is more
flexible and has high client involvement, producing the product faster but without a
solid estimate or proper documentation.
Iterative: the project is divided into modules and a working prototype of one of the
modules is built first, then more modules are added on. This is best suited for large
projects and allows for flexibility and involvement of the client.
A structure chart shows the different modules (functions/procedures) in a program and
the relationships and variables passed between them. Non-boolean parameters are
represented by an arrow with a white circle

and boolean parameters are represented by an arrow with a black circle

A parameter is passed to a function by value

A parameter is returned from a function

A parameter is passed to a function by reference

A loop

A decision

Links to: Past papers - Syllabus - Textbook Page 28


COMPUTER SCIENCE CAIE 9618
State diagrams
Finite State Machine(FSM): a machine with a fixed set of possible states and a set of
inputs that change the state and a set of possible outputs.
Only an input can change the state, and if an output is associated with an input, this is
written next to the input with a bar ‘|’ to separate them. There is also a start point that
shows the default state of the machine.
Example:

Errors and testing


Syntax error: an error caused by incorrect formatting/structure of the code according
to the programming language.
Logical error: Program does not perform as expected
Run-time error: program executes an invalid instruction,e.g:divide by 0, out of bounds
Program testing methods:
Dry-run: the programmer manually/mentally runs the program
Stub testing: it’s carried out before the modules are written. A dummy module
simulates the function and outputs a message to show the function call was successful
Integration testing: the modules that have been tested separately and are slowly
added and integrated into one program and are tested as a whole.
Acceptance testing: to see to what degree the program meets the requirements
Alpha testing: first testing done of the final project, done by internal members
Beta testing: done after alpha testing by selected real customers
White box: internal code can be viewed, so each line and path can be tested
Black box: when the internal code is unknown, so it's tested to meet the requirements
Walkthrough: the program code is known, and all paths are tested
Types of test data:
Normal: data that meets the criteria and should be accepted
Abnormal data: data that doesn’t meet the criteria and should be rejected
Extreme/boundary: data that is at the upper and lower limits of the acceptable range
and should be accepted.

Links to: Past papers - Syllabus - Textbook Page 29

You might also like