0% found this document useful (0 votes)
7 views

CAIE-A2 Level-Computer Science - Theory

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)
7 views

CAIE-A2 Level-Computer Science - Theory

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/ 27

ZNOTES.

ORG

UPDATED TO 2023-2025 SYLLABUS

CAIE A2 LEVEL
COMPUTER SCIENCE
SUMMARIZED NOTES ON THE THEORY SYLLABUS
Prepared for Viduranga for personal use only.
CAIE A2 LEVEL COMPUTER SCIENCE

Non-Composite User-Defined Data Types


1. Data Representation
Non-composite user-defined data types don’t involve a
reference to another type. When a programmer uses a
1.1. User-Defined Data Types simple built-in type, the only requirement is for an identifier
A user-defined data type is a data type designed by the to be named with a defined type. They must be explicitly
programmer. When object-oriented programming is not defined before an identifier can be created, unlike built-in
data types, which include string, integer, real, etc…
being used, a programmer may choose to utilize user-
defined data types for a large program as their use can
reduce errors in the program and make it more
understandable. It also has less restriction and allows for
inevitable user definition.
The use of built-in data types is the same for any
program. However, there can't be a built-in record type
because each different problem will need an individual
definition of a record. 2 types of user-defined data types:

Composite User-Defined Data Types


Composite user-defined data types have a definition
referencing at least one other type.

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE

Enumerated Data type: is a non-composite user-


defined data type. It is a list of possible data values. The
values defined here have an implied order of values to
allow comparisons. Therefore, value2 is greater than
value1(they're not string values and can't be quoted).
This allows for comparisons to be made. It is also
countable, thus finite values.

TYPE <Datatype> = (<value1>,<value2>,<value3>…)

DECLARE <identifier> : <datatype>

e.g.
TYPE Season = (Summer,Winter,Autumn,Spring) // No Use the diagram to state the current values of the following
Su
expressions.
it
IPointer: 4402 // This is the address that IPointer is pointing
DECLARE ThisSeason : Season
to.
DECLARE NextSeason : Season IPointer^: 33 //This is the value stored at the address (4402)
the IPointer is pointing to.
ThisSeason <-- Autum
@MyInt1: 3427 //This is the address of MyInt1
NextSeason <-- ThisSeason + 1 // NextSeason is se
IPointer^ = MyInt2 : TRUE //This compares the value of
MyInt2 to the value stored at the address (4402)
Pointer Data Type: used to reframe a memory location. Write pseudocode statements that will achieve the
It may be used to construct dynamically varying data following.
structures. The pointer definition has to relate to the
type of the variable being pointed to(it doesn’t hold a 1. Place the address of MyInt2 in the IPointer.
value but a reference/address to data). In type IPointer <-- @MyInt2
declaration, ^ shows that the TYPE being declared is a 2. Assign the value 33 to the variable MyInt1.
Pointer, and is the data type found at the memory MyInt1<-- 33
location, e.g. STRING. 3. Copy the value of MyInt2 into the memory
location currently pointed at by the IPointer.
TYPE <PointerName> = ^<Typename> IPointer^ <-- MyInt2

// Declaring a pointer variable 1.2. File Organisation and Access


DECLARE <FirstPointer> : <PointerName>
Contents in any file are stored using a defined binary code
<assignment value> ← <FirstPointer>^ // This acce that allows the file to be used as intended. But, for storing
which Int data to be used by a computer program, there are only two
as derefe defined file types: text or binary.

SecondPointer <-- @<identifier> //This stores the


SecondPointer
SecondPointer^ <-- MyVariable //This stores the v
memory location c

e.g

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE
Sequential files are records ordered and suited for long-
A text file contains data stored according to a defined term data storage and thus are considered an alternative to
character code defined by ASCII or Unicode. A text file a database. A key field is required to order a sequential file
can be created using a text editor. for which the values are unique and sequential—this way, it
A binary file is a file designed for storing data to be used can be easily accessed.
by a computer program(0's and 1's). It stores data in its
internal representation(an integer value might be stored A sequential database file is more efficient than a text file
in 2 bytes in 2's complement representation to represent due to data integrity, privacy and less data redundancy. A
a negative number), and this file is created using a change in one file would update any other files affected.
specific program. Its organisation is based on records (a Primary keys from the DBMS(database management
collection of fields containing data values). file → records system) must be unique but not ordered, unlike the key
→ fields → values field from the sequential files, which must be ordered
and unique.
Methods of File Organisation and Access A particular record is found by sequentially reading the
key field's value until the required value is found. New
Proper file organisation is crucial as it determines access records must be added to the file in the correct place.
methods, efficiency, flexibility, and storage devices.
Advantages of sequential file organisation
Serial files: contains records that have no defined order. A
text file may be a serial file with repeating lines defined by The sorting makes it easy to access records but does not
an end-of-line character(s). Records are stored, one after remove the need to access other records as the search
another, in the order they were added to the file. New looks for particular records.
records are added at the end of the file. The binary search technique can reduce record search
time by half the time.
There's no end of record character. A record in a serial
file must have a defined format to allow data to be input File Access
and output correctly. To access a specific record, it has to
go through every record until found. Records in this type of file are searched using the Sequential
Serial file organisation is frequently utilised for Access and Direct Access methods.
temporarily storing transaction files that will eventually
be moved to more permanent storage. Retrieving records using Sequential Access:
Successively read the value In the key field until the
Advantages of serial file organisation required key is found or the key field of the current
record being checked is greater than the key field
The task at hand is straightforward. searched for. (This would mean the required record
The cost is low. is not in the file).
The rest of the file does not need to be searched as the
Disadvantages of serial file organisation
records are sorted on ascending key field values. This
It becomes difficult to access because you must access method is efficient when every record in the file needs to
all proceeding records before retrieving the one being be processed.
searched.
It cannot support modern high-speed requirements for Retrieving records using Direct Access:
quick record access. This method finds the required record without reading
File access: Records in this file type are searched using other records in the file. This allows the retrieval of
Sequential Access. Successively read record by record records more quickly. An index of all the key fields is kept
until the required data is found or the whole file has and used to look up the address of the file location
been searched, and the required data is not found, thus where the required record is stored.
prolonging the process. Uses: This method is efficient when an individual record in the
Batch processing file needs to be processed.
Backing up data on magnetic tape
Banks record transactions involving customer accounts To edit/delete data:
every time there is a transaction.

Sequential Files

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE

Create a new version of the file. Data is copied from the The value in the key field is submitted to the hashing
old file to the new file until the record is reached, which algorithm, which then provides the same value for the
needs editing or deleting. position in the file that was provided when the algorithm
For deleting, reading and copying the old file, continue was used at the time of data input. It goes to that hashed
from the next record. If a record has been edited, the position and through another short linear search
new version is written to the new file and the remaining because of collisions in the hashed positions—fastest
records are copied to the new file. access.

Random Files To edit/delete data:


Records are stored randomly in the file but are accessed Only create a new file if the current file is full. A deleted
directly. The location for each record is found using a record can have a flag set so that the record is skipped
Hashing Algorithm on the record's key field. Magnetic over in a subsequent reading process. This allows it to be
and optical disks use random file organisation. overwritten.

Advantages of random file organisation Uses:


Quick retrieval of records. Most suited for when a program needs a file in which
The records may vary in size. individual data items might be read, updated or deleted.

Direct Access Files Factors that Determine the File Organisation to


Use
File access: Records in this file type are searched using the
Direct Access method. A hashing algorithm is used on the How often do transactions occur, and how often does
key field to calculate the address of the file location where a one need to add data?
given record is stored. How often does it need to be accessed, edited, or
Direct access/random access files: access isn't defined by deleted?
a sequential reading of the file(random). It's well suited for
larger files, which take longer to access sequentially. Data in
direct access files are stored in an identifiable record, which
1.3. Floating-Point Numbers,
could be found by involving initial direct access to a nearby Representation, and Manipulation
record followed by a limited serial search.

The choice of the position must be calculated using data


in the record so the same calculation can be carried out
when there's a search for the data. One method is the
hashing algorithm, which takes the key field as an input
and outputs a value for the record's position relative to
the file's start. To access, the key is hashed to a specific
location.
This algorithm also considers the potential maximum
length of the file, which is the number of records the file
will store.
e.g., If the key field is numeric, divide by a suitable large
number and use the remainder to find a position. But we
won't have unique positions. The next position in the file
is used if a hash position is calculated that duplicates one
already calculated by a different key. This is why a search
will involve direct access, possibly followed by a limited
serial search. That's why it's considered partly sequential
and partly serial.
File access:

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE

The Real Number: A number that contains a fractional


part.
Floating-point Representation: The approximate
representation of a real number using binary digits.
Format: Number = ±Mantissa × BaseExponent
Mantissa: The non-zero part of the number.
Exponent: The power to which the base is raised to
in order to accurately represent the number.
Base: The number of values the number systems allows
a digit to take. 2 in the case of floating-point
representation.
The floating point representation stores a value for the
mantissa and the exponent. Converting a denary value expressed as a real number into a
Some bits are used for the significant/mantissa, +-M. The floating point binary representation: Most fractional parts do
remaining bits are for the exponent, E. The radix, R, is not convert to a precise representation as binary fractional
not stored in the representation as it has an implied parts represent a half, a quarter, an eighth…(even). Other
value of 2(representing 0 and 1s). than .5, there are no different values unless the ones above
If a real number was stored using 8 bits: four bits for the can be converted accurately. So you convert by multiplying
mantissa and four bits for the exponent, each using two by two and recording the whole number part.
complement representations. The exponent is stored as For example, 8.63, 0.63 * 2 = 1.26; therefore, .1 -> 0.26 * 2 =
a signed integer. The mantissa has to be stored as a fixed 0.52 and .10 -> 0.52 * 2 = 1.04 and .101, and you keep going
point real value. until the required bits are achieved.
The binary point can be in the beginning after the first The method for converting a positive value is:
bit(immediately after the sign bit) or before the last bit. 1. Convert the whole number part
The former produces smaller spacing between the values 2. Add the sign bit 0
that can be represented and is more preferred. It also 3. Convert the fractional part. You start by combining the
has a greater range than the fixed representation. two parts, giving the exponent value zero. Shift the binary
points by shifting the decimal to the beginning, providing a
higher exponent value. Depending on the number of bits,
add extra 0's at the mantissa's end and the exponent's
beginning.
4. Adjust the position of the binary point and change the
exponent accordingly to achieve a normalised form.
Therefore: 8.75 -> 1000 -> 01000 -> .11 -> 010000.11 ->
0.100011(mantissa) -> 0100011000 0100(10 for M, and 4 for
E).

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE

For negatives, use 2's complement. Saves space by storing many numbers using the smallest
When implementing the floating point representation, a bytes possible.
decision must be made regarding the number of bits to Normalization reduces the representation of leading
use and how many for the mantissa and exponent. zeros or ones.
Usually, the choice for the total number of bits will be Maximizing the precision or accuracy of the number for
provided as an option when the program is written. the given number of bits.
However, the floating point processor will determine the Allows for the precise storage of both very large and very
split between the two parts. small numbers.
If there were a choice, it's convenient to note that Avoids the possibility of many numbers having multiple
increasing the number of bits for the mantissa would representations.
give better precision but leave fewer bits for the
exponent, thus reducing the range of possible values and Precision vs Range.
vice versa. For maximum precision, it is necessary to
normalise a floating point number. Increasing the number of bits for mantissa increases the
Optimum precision will only be made once full use is precision of the number.
made of the bits in the mantissa, therefore using the The number range can be increased by increasing the
largest possible magnitude for the value the mantissa number of bits for exponent.
represents. Precision and range will always be a trade-off between
Also, the two most significant bits must differ—0 1 for the mantissa and exponent size.
positives and 10 for negatives.
They both equal two, but the second one with the higher
bits in the mantissa is the most precise.
0.125 * 2^4 = 2 0 001 0100
0.5 * 2^2 = 2 0 100 0010

-For negatives.

0.25 * 2^4 = -4 1 110 0100


1.0 * 2^2 = -4 1 000 0010
When the number is represented with the highest
magnitude for the mantissa, the two most significant bits
are different. Thus, a number is in a normalised
representation. How a number could be normalised: for
a positive number, the bits in the mantissa are shifted Problems with Using Floating Point Numbers
left until the most significant bits are 0, followed by 1.
For each shift left, the value of the exponent is reduced
by 1. The same shifting process is used for a negative
number until the most significant bits are 1, followed by
0. In this case, no attention is paid to the fact that bits
are falling off the most significant end of the mantissa.
Thus, normalisation shifts bits to the left until the two
most significant bits differ.

Why are Floating Point numbers represented in


normalised form?

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE

1. The conversion of real denary values to binary mainly TCP/IP Suite


needs a degree of approximation followed by
restricting the number of bits used to store the A layered model (stack) with 4 layers; Application.
mantissa. These rounding errors can become transport, internet and data link. The Suite uses a set of
significant after multiple calculations. The only way to protocols for the transmission of data in these layers like
prevent a severe problem is to increase the precision TCP (Transport Control Protocol) and IP (Internet
by using more bits for the mantissa. Programming Protocol).
languages, therefore, offer options to work in TCP maintains connection between two nodes and
double/quadruple precision. ensures delivery of data between the two nodes.
2. The highest value represented is 112; thus, it is a IP provides rules of exchange for packets and decides
limited range. This produces an overflow condition. If the route for sending packets.
a result value is smaller than one that can be stored,
there would be an underflow error condition. This
very small number can be turned into zero, but there
are several risks, like multiplication or division of this
value.
3. There is an inability to store the number 0 using
normalised floating point numbers. This is because
the mantissa can either be 0.1 or 1.0.

For example, one use of floating point numbers is in


extended mathematical procedures involving repeated
calculations like weather forecasting, which uses the
mathematical model of the atmosphere.
Application Layer:
2. Communication and The application layer provides user services.
Internet Technologies Encodes data in an appropriate format when sending a
message
Performs the action requested by the user when
2.1. Protocols receiving a message

A protocol sets the rules of the communication. Protocols Transport Layer:


allows for devices to communicate across different
Handles packets.
platforms. If two devices attempted to communicate while
Converts the data received from the application layer
using different protocols, the communication would fail.
into individual packets when sending a message.
TCP/IP is the dominant protocol suite for internet usage. Adds packet headers and then sends these packets to
There are the main types of protocols:
the internet layer.
HTTP and HTTPS (Hypertext Transfer Protocol): Used Controls the flows of packets and handles packet loss or
to transfer webpages from server to client. HTTPS is corruption.
more secure. When receiving a message it reads the header and
FTP (File Transfer Protocol): Used for sending and determines which application layer the data must be
receiving files over the network between two devices. sent to, then strips the header and forwards it
POP3 (Post Office Protocol): Used for receiving emails.
Internet Layer:
IMAP (Internet Message Access Protocol): Also used
for receiving emails. The email client retrieves the emails Handles the transmission of data using IP addresses.
from the mail server. Identifies the intended network and host and then
SMTP (Simple Mail Transfer Protocol): Used for transmits the packets through the data link layer.
sending emails Routes each packet independently through the best
route available
IP Addresses, of the sender and receiver, and checksum
are added when sending messages
When receiving a message it reassembles the fragments,
strips the IP header and sends it to the transport layer

(Data) Link Layer:

Converts the electrical data into analog signals and sends


it, allowing the upper layers access to the physical
medium.
Formats data into frames for transmission and maps IP
addresses to MAC (hardware) addresses.
Copyright Ensures correct network protocols are followed.
WWW.ZNOTES.ORG © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
Verifies the checksum when receiving a message and
then sends it to the internet layer
CAIE A2 LEVEL COMPUTER SCIENCE

Peer-to-peer File Sharing Data is split into multiple packets and each packet a
route is calculated for each packet.
BitTorrent uses Peer-To-Peet file sharing model. Each packet contain a header, which has a source IP
A BitTorrent client software is made available to the address and destination IP address, and a payload.
public. Calculates the most efficient path for each packet.
Swarm: All connected peer computers that have all or Used when sending large files that don’t need to be live
parts of file being downloaded/uploaded. streamed or when it is necessary to be able to overcome
Tracker: A central server that stores information on faulty lines by rerouting like emails, text messages,
which computers have which files and which parts of sending documents, etc.
those files. It also shares the IP addresses of computers Harder to intercept as new route is used each time.
to allow them to connect to each other. Packets need to be reassembled.
Seed: is the peer computer that uploads the file that is If there’s a missing packet, a request is sent to retransmit
being downloaded. the data.

If a user wishes to join this network, they need to use a Role of Router:
BitTorrent client to load the torrent descriptor file. When a
user wishes to download a file, pieces of this file are Examines the header and finds the destination IP
downloaded and uploaded at the same time. When a user address.
has even a single piece of a file they become a seed. To be Decides the best route for the packet, with the help of
able to download this file, a complete copy needs to exist on the information from the routing table, and sends it
one of the peer computers. towards the next hop.

2.2. Circuit Switching, Packet Switching 2.3. Comparison


Circuit Switching Packet Switching
Circuit Switching
Data segmented into
Nature Dedicated channel
packets
Dedicated circuit is selected before the communication
starts and is used to send all the data through this route. Requires pre-established
Setup No prior setup needed
channel
- Uses the whole bandwidth.
Data Message gets split into
Releases circuit once the communication ends. handling
Message remains intact
packets
Used for live video broadcasts or calling
Path recalculated each
Data arrives in order so it doesn’t need to be Transmission Single Path
time
reassembled. Order In order May need reassembly
Whole bandwidth is available.
Layer (Data) Link Layer Network Layer
Data can’t get lost.
Makes full use of Bandwidth can be
Less secure as it only uses one route. Bandwidth
bandwidth shared
No alternative route in case of failure.
Error Communication ends Allows packets to be
Bandwidth can’t be shared. handling incase of an error resent
Complexity Simple More complex
Packet Switching

3. Hardware and Virtual


Machines
3.1. Processors
Complex Instruction Set Computer (CISC)

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE

Many different instruction formats which means that Used extensively in RISC processor-based systems to
different instructions can take a different number of reduce the time taken to run processes
clock cycles to be executed. Allows several instructions to be executed
Programmable CU. simultaneously therefore increasing the rate at which the
Uses few registers. CPU processes instructions.
Relies a lot on cache memory rather than RAM. Each instruction is divided into 5 parts:
Cache isn’t split between data and instructions. 1. Instruction Fetch (IF)
2. Instruction Decode (ID)
Reduced Instruction Set Computer (RISC) 3. Operand Fetch (OF)
4. Instruction Execute (IE)
Instructions executed in a single clock cycle as the 5. Write Back (WB)
instructions are simple and have a fixed length. During each clock cycle, each subtask is completed.
Hardwired CU. For example, when one instruction is being decoded,
Makes use of many registers. another one is being fetched in the same cycle.
Doesn’t rely on cache as much compared to RAM. No two instructions can execute the same subtask in the
Cache split between data and instructions. same cycle; only one instruction can be decoded at a
time.
Comparison
Interrupt handling
RISC CISC
Instruction complexity Simple Complex As soon as the interrupt is detected, the current
Instruction Length Fixed Variable processes are paused and moved into registers
Instruction Amount Few Many The ISR (Interrupt Service Routine) is loaded onto the
Instruction Formats Few Many pipeline and is executed.
Can be pipelined Yes No When the interrupt has been serviced, the paused
Addressing modes Few Many processes are resumed by bringing them back from the
Circuit Complexity Less complex Complex registers to the pipeline
Register use High Low RISC processors allow for providing efficient pipelining.
Memory reliance Relies on RAM Relies on cache
Pipelining is instruction-level parallelism. Its underlying
principle is that the fetch-decode execute cycle can be
Is cache split Yes No
separated into several stages.
Control unit Hardwired Programmable

Pipelining 3.2. Parallel Processing


Single Instruction Stream Single Data Stream
(SISD)
A single processor executes the instruction set using a
single data set.
One processor, one memory unit and one control unit
that execute instructions sequentially.
Does not support parallel processing. Used for
microprocessors in appliances.
Does not support pipelining as there is only one
processor

Single Instruction Stream Multiple Data Stream


(SIMD)

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE
Pros Cons
Parallel computers with many processors execute the Performance of the guest
same instruction set using different data sets and do so Multiple operating systems can might not be accurate if it were
sequentially. be run on the same device. to be run individually as there
Can take advantage of pipelining. is a greater load on the host.
Commonly used to process 3D graphics. Cannot emulate certain
A virtual machine can crash hardware as the hardware may
Multiple Instruction Stream Single Data Stream without affecting the host. have been developer after the
virtual machine.
(MISD)
Virtual machine may be
Can run legacy software by
Parallel computers with many processors execute affected by the weakness of
running it on the guest OS.
the host.
different instructions using the same data set.
Can test software for different
Used to sort large quantities of data. platforms on the same device Greater maintenance cost as
without needing to purchase you have to maintain host and
Multiple Instruction Stream Multiple Data Stream hardware for the second guest OS.
(MIMD) system.
Register use High
Many processors execute different instructions using Memory reliance Relies on RAM
different data sets.
All processors work independently.
Commonly used in parallel computer systems. 4. Hardware and Virtual
Massively Parallel Computers Machines
A large number of computer processors that are connected
together simultaneously performing a set of coordinated 4.1. Logic Gates & Circuit Design
instructions. As the computers are connected together, they
communicate over the network by sending messages. Logic Gates: A component of a logical circuit that can
One hardware issue faced by these computers is that perform a Boolean operation (logical function).
processors need to communicate with each other to be able
AND Gate: A.B = X
to transfer data between them. One software issue faced by
these computers is that there needs to be an algorithm that A B X
splits the data between them for efficient processing. 0 0 0
When an app is being made for these computers, it needs to 0 1 0
be able to split the code to allow for simultaneous execution 1 0 0
rather than sequential.
1 1 1

3.3. Virtual Machines


The emulation of a different computer’s hardware and/or
software using a host device is known as running a virtual
machine.
Guest: The emulated OS is known as the guest.
Host: The original OS

OR Gate: A + B = X

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE
A B Output
0 0 0
0 1 1
1 0 1
1 1 1

NOR Gate: A + B = X ​

A B Output
0 0 1
0 1 0
1 0 0
NOT Gate: A = X 1 1 0

A Output
0 1
1 0

XOR Gate: A.B + A.B = X

A B Output
0 0 0
NAND Gate: A.B = X 0 1 1
1 0 1
A B Output
1 1 0
0 0 1
0 1 1
1 0 1
1 1 0

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE

Double Complement: A = A
Identity Law
1.A = A
0+A = A
Null Law
0.A = 0
1+A = 1
Idempotent Law
A.A = A
A+A=A
Inverse Law
A.A = 0
Logic circuits: A circuit that performs logical operations
A+A = 1
on symbols.
Commutative Law
Sequential circuit: a circuit whose output depends on
the input and previous output values. E.g.: - Flip-flops A.B = B.A
(Section 3.3.4) A+B = B+A
Combinational circuit: a circuit whose output is Associative
dependent only on the input values (A.B).C = A.(B.C)
Half-Adder: A logic circuit that adds two bits together (A + B) + C = A + (B + C)
and outputs their sum. Distributive Law
A + B.C = (A + B).(A + C)
A. (B + C ) = A.B + A.C
Adsorption
A. (A + B ) = A
A + A.B = A
De Morgan’s Law
(A.B ) = A + B
(A + B) = A.B ​

{example}
Input Output
A B S C
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1

4.2. Boolean Algebra


4.3. Karnaugh Maps

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE

Karnaugh maps: a method of obtaining a Boolean


algebra expression from a truth table involving the
Benefits of using Karnaugh Maps:
Minimises the number of Boolean expressions.
Minimises the number of Logic Gates used, thus
providing a more efficient circuit.
Methodology
Try to look for trends in the output, thus predicting
the presence of a term in the final expression
Draw out a Karnaugh Map by filling in the truth table
values into the table
Column labeling follows the Gray coding sequence
Select groups of ‘1’ bits in even quantities (2, 4, 6,
etc.); if not possible, then consider a single input as a
group
Note: Karnaugh Maps wrap around columns
Within each group, only the values that remain
constant are retained

Examples

4.4. Flip-Flops
Flip flops can store a single bit of data as 0 or 1
Computers use bits to store data.
Flip-flops can be used to store bits of data.
Memory can be created from flip-flops.

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE

SR Flip Flops Paging:


Process split into pages, memory split into frames
All pages loaded into memory at once

Virtual memory:
No need for all pages to be in memory
CPU address space is thus larger than physical space
Addresses resolved by the memory management
unit
Benefits
Not all of the program has to be in memory at
once
Large programs can be run with or without large
physical memory
JK Flip Flops Process
All pages on the disk initially
JK flip flops are an improvement over SR flip flops. One/more loaded into memory when process
Invalid input combinations are eliminated in JK flip flops. ‘ready’
All four combinations of input values (J and K) are valid in Pages replaced from disk when needed
JK flip-flops. This can be done with a FIFO queue or usage-
JK flip flops use a clock pulse for synchronization to statistics-based algorithm
ensure proper functioning. Disk thrashing: Perpetual loading/unloading of pages
Advantages of JK flip flops include the validity of all input due to a page from disk immediately requiring the page
combinations, avoidance of unstable states, and it replaced.
increased stability compared to SR flip flops.
5.2. OS Structure
An OS has to be structured to provide a platform for
resource management and facilities for users. The logical
structure provides 2 modes of operation:
1. The user mode is the one available for the user or an
application program.
2. Privileged/kernel mode has the sole access to parts
of the memory and to certain system functions that
the user mode can’t access.

5.3. Translation Software


5. System Software Lexical analysis: The process of converting a sequence
of characters to a sequence of tokens.
Tokens: Strings with an assigned meaning
5.1. Purposes of an Operating System Syntax analysis: The process of double-checking the
(OS) code for grammar mistakes (syntax errors).
Code generation: The process by which an intermediate
code is generated after syntax analysis.
Optimization: A process in which the code is edited to
make efficiency improvements.

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE

5.5. RPN (Reverse Polish Notation)


Reverse Polish notation (RPN): A method of representing
an arithmetic or logical expression without brackets or
special punctuation. RPN uses postfix notation, where an
operator is placed after the variables it acts on. For example,
A + B would be written as A B +

For interpreters:
Analysis and code generation run for each code line Compilers use RPN because any expression can be
as above processed from left to right without backtracking.
Each line is executed as soon as the intermediate
code is generated Advantages of RPN
5.4. Syntax Diagrams and BNF ● RPN expressions do not need brackets, and there is no
need for the precedence of operators
BNF is a formal mathematical way of defining syntax ● RPN is simpler for a machine to evaluate
unambiguously. ● There is no need for backtracking in evaluation as the
It consists of: operators appear in the order required for computation and
can be evaluated from left to right
A set of terminal symbols
A set of non-terminal symbols Infix to Reverse Polish Notation
A set of production rules

6. Security
6.1. Asymmetric Keys and Encryption
Methods

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE

Plain text: data before encryption. 1. The process starts with original data, plaintext,
Cipher text: the result of applying an encryption whatever form it takes.
algorithm to data. 2. This is encrypted by an encryption algorithm, which
Encryption: the making of cipher text from plain text. uses a key.
Encryption can be used: 3. The product of the encryption is ciphertext, which is
When transmitting data over a network. transmitted to the recipient.
It is a routine procedure when storing data within a 4. When the transmission is received, it is decrypted
computing system. using a decryption algorithm and a key to produce
Public key: A key that is shared between the user and the original plaintext.
sender for encryption of the data and verifying digital
signatures. Security concerns relating to a transmission:
Private key: A key which is kept to be a secret and used
Confidentiality: only the intended recipient should be
to decrypt data the data encrypted by the public key. able to decrypt the ciphertext.
Symmetric key encryption: when there is just one key Authenticity: the receiver must be confident who sent
used to encrypt and then decrypt. The sender and the the ciphertext.
receiver of a message share the secret key. Integrity: the ciphertext must not be modified during
Asymmetric encryption is when two different keys
transmission.
are used, one for encryption and another for Non-repudiation: neither the sender nor the receiver
decryption. Only one of these is a secret. should be able to deny involvement in the transmission.
Sending a private message: Availability: nothing should happen to prevent the
receiver from receiving the transmission.

At the sending end, the sender has a key to encrypt some


plaintext, and the ciphertext produced is transmitted to the
receiver. Now, the receiver needs to get the key needed for
decryption.

1. If symmetric key encryption is used, there needs to


be a secure method for the sender and receiver to be
provided with the secret key.
2. Using asymmetric key encryption, the process starts
with the receiver. The receiver must have two keys.
One is a public key, which is not secret. The other is a
private key, which is secret and known only to the
Sending verified messages to the public:
receiver. The receiver can send the public key to a
sender, who uses the public key for encryption and
sends the ciphertext to the receiver. The receiver can
only decrypt the message because the private and
public keys are matched. The public key can be
provided to different people, allowing the receiver to
receive a private message from any of them.

6.2. Digital Signatures and Digital


Certificates

Encryption and Decryption

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE

Using asymmetric encryption, the decryption works if


the keys are used the other way around. An individual
can encrypt a message with a private key and send this
to many recipients with the corresponding public key
and can, therefore, decrypt the message. This is not for
confidential messages but can be used to verify who the
sender is. Only the sender has the private key, and the
public keys only work with that specific private key.
Therefore, used this way, the message has a digital
signature identifying the sender. However, the digital
signature is associated with the encryption of the whole
message.
Cryptographic one-way hash function creates from
the message a number uniquely defined for the
particular message, a digest. The private key is used as a
signature for this digest. This speeds up the process of
confirming the sender's identity.
The message is assumed to be transmitted as plaintext,
and the digital signature is assumed to be a separate file.
The same public hash key function that the sender used
is used, so the same digest is produced if the message
has been transmitted without alteration. The decryption
of the digital signature produces an identical digest if the
message was genuinely sent by the original owner of the
public key the receiver used. This makes the receiver
confident that the message is authentic and unaltered. Suppose a would-be receiver with a public-private key pair
However, someone might forge a public key and pretend wishes to receive secure messages from other individuals. In
to be someone else. Therefore, there is a need for a that case, the public key must be made available in a way
more rigorous means of ensuring authentication. This that ensures authentication. The would-be receiver would
can be provided by a Certification Authority (CA) as part need to obtain the digital certificate to allow safe public key
of a Public Key Infrastructure (PKI). delivery:
1. An individual(A) who is a would-be receiver with a
public-private key pair contacts a local CA.
2. The CA confirms the identity of A.
3. A's public key is given to the CA.
4. The CA creates a public-key certificate(a digital
certificate) and writes A's key into this document.
5. The CA uses encryption with the CA's private key to
add a digital signature to this document.
6. The digital certificate is given to A.
7. A posts the digital certificate on a website.

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE

![PROCESSES INVOLVED IN OBTAINING A DIGITAL


CERTIFICATE: Individuals place the digital certificate on 6.4. Malware
that person's website, but you can post it on a website
designed to keep digital certificate data. Alternatively, a Virus: tries to replicate inside other executable
programs.
digital certificate might be used solely for authenticating
Worm: runs independently and propagates to other
emails. Once a signed digital certificate has been posted
on a website, any other person wishing to use A's public network hosts.
key downloads the signed digital certificate from the Spyware: collects info & transmits to another system.
website and uses the CA's public key to extract A's public Phishing: email from seemingly legit source requesting
confidential info.
key from the digital certificate. For this overall process to
Pharming: setting up a bogus website that appears to be
work, standards need to be defined.
legit.

6.3. Encryption Protocols Malware Vulnerabilities exploited


Virus Executable files used to run or install software.
SSL and TLS encryption protocols are used in client- Worm Shared networks
server applications. Spyware Background processes
SSL (Secure Socket Layer) and TLS (Transport Layer Users mindset on considering emails from
Security) are closely related Internet security protocols. Phishing
random addresses to be trustworthy
TLS is a slightly modified version of SSL. The main use of Users’ mindset of relying on the website’s user
SSL is in the client-server application. The interface Pharming
interface rather than the URL for its validity.
between an application and TCP uses a port number.
Without a security protocol, TCP services an application Malware Methods of restriction
using the port number. Install and use an Anti-Virus software that runs
Virus
The combination of an IP address and a port number is daily scans.
the socket. When the SSL protocol is implemented it Set up a firewall to protect yourself from
Worm
functions as an additional layer between TCP in the external networks.
transport layer and the application layer. The HTTP Install and use real-time Anti-Spyware
Spyware
application protocol becomes HTTPS when the SSL protection.
protocol is in place. Phishing Always check the sender’s email address.
Provides: Pharming Always double-check the website name.
Encryption
Compression of data
Integrity checking 7. Artificial Intelligence (AI)
Connection Process:
Neural Networks
Neural networks are modelled on the human brain.
They contain input and output nodes as well as one or
more hidden layers.
Each input node is assigned a specific weight, these
weights are summed, and an activation function
calculates a value for the output.
Repeated for each layer within the network thereby
allowing reinforcement learning to take place.

Use of Hidden Layers:

Allow deep learning to take place


Used in online shopping and banking websites. Allows the network to make decisions independently
Helps to improve the accuracy of the output

Machine Learning

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE
Machine learning is a field of artificial intelligence in which A graph is an abstract datatype that contains a collection of
computers learn from provided data and past experiences in nodes. These nodes are connected to each other with edges.
order to improve its performance in a given task without A node usually has a name, and an edge usually has a
explicitly being programmed to know how to do the task. For numerical value.
example, rather than telling the computer that emails that One example of graphs is A* or Dijkstra's algorithm. The
advertise free products are most likely scams we feed it a lot nodes represent locations, and the edges represent the
of data and it identifies that pattern on its own. distance between them.

Deep Learning
A subset of machine learning that simulates the decision
making and data processing abilities of the human brain.
Benefits:

Good with extremely large sets of data


Good with unstructured data
Can identify hidden patterns

Reinforcement Learning
Reinforcement learning allows the computers to make
Use of Graphs
decisions that maximize the reward, it is then graded based
on how well it performed. Over time the computer learns Graphs provide relationships between different nodes.
the correct decisions it needs to make based on its past Allows AI problem to be defined as the most efficient
experiences. route between two nodes
Analyzed by machine learning algorithms such as A* to
Supervised Learning perform calculations
Graphs can also be used to represent neural networks.
In supervised learning the computer is fed labelled test data,
and it identifies the patterns that led to the data being A* and Dijkstra’s Algorithm
labelled in a specific way. This allows it to then predict labels
for new unseen data. These algorithms are used to find the shortest route
between two nodes based on the distance.
Unsupervised Learning The main issue with Dijkstra's algorithm is that it is
inefficient when searching for the shortest path.
In unsupervised learning the computer is fed unlabeled test
Dijkstra's algorithm is A* but if the heuristic value was
data, and it identifies hidden patterns.
always 0.
Back Propagation of Errors Using these algorithms
An algorithm identifies errors with the machine learning and
h is the heuristic value
is then used to adjust the model for improved accuracy by
g is the movement cost
starting at the output layer and working backwards through
F is the sum of g and h values.
the hidden layers to the input layer.
For example, if you threw a ball and missed your target.
You'd check how far off you were from the target and then
adjust things like angle and strength the next time you threw
the ball.

Regression
Regression is finding a mathematical function that best fits
out output data based on the previous results in order to
predict the future value.

7.1. Graphs in the context of AI

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE

8.2. File Processing and Exception


Handling
File Processing
Records are user-defined data structures
Defining a record structure for a Customer record with
relevant fields (e.g., customer ID) in Python:

Start from the Home. The cost from Home to Home is 0,


so g= 0. The heuristic cost of a home is 14, so h=14 and
f=g+h=14.
Now, there are three immediate nodes from home: A, B,
and C. Calculate the values of g, h and f for A, B and C
from home and write them in the table.
Select the node whose f value is the shortest (in this
case, Node A). Files are needed to import contents (from a file) saved in
From A, there are two immediate nodes, B and E. secondary memory into the program or to save the
Calculate the g value for each node and add the g value output of a program (in a file) into secondary memory so
of A. Then, add the corresponding h values to get f for that it is available for future use.
each node. Pseudocode:
From E, there are two immediate nodes, School and F.
Calculate the g value for each node and add the g value Opening a file:
of E. Then, add the corresponding h values to get f for OPENFILE <filename> FOR READ/WRITE/APPEND
each node. Reading a file:
From F to School, add the g value (3) to the g value of F READFILE <filename>
(8) and calculate f. Writing a line of text to the file:
WRITEFILE <filename>, <string>
Final path = Home → A→E→F→School. Closing a file:
CLOSEFILE
Testing for the end of the file:
EOF()

Python:
Opening a file
variable = open(“filename”, “mode”)
Where the mode can be:

Mode Description
It opens a file for reading only. The pointer is placed
r
at the beginning of the file.
It opens a file for writing only. Overwrites file if file
w
8. Further Programming a
exists or creates a new file if it doesn’t
Opens a file for appending. Pointer at the end of the
file if it exists or creates a new file if not
8.1. Programming Paradigms

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE
*Special Case: If the records in a sequential file are of a fixed
Reading a file: length, a record can be retrieved using its relative position.
Read all characters So, the start position in the file could be calculated for the
variable.read() record with the key number 15, for example.
Read each line and store it as a list
variable.readlines() Add a new record – Serial Organisation:
Writing to a file:
Write a fixed sequence of characters to file
variable.write(“Text”)
Write a list of strings to file
variable.write[“line1”, “line2”, “line3”]
Using direct access or Random File allows us to read Add a new record – Sequential Organisation:
records directly. ‘random’ is misleading since records are
*Some file processing tasks, like this one, require two files
still systematically read from and written to the file.
because serial/sequential files can only be opened to read
Pseudocode: from or write to in the same session.*

Opening a file using the RANDOM file mode, where once


the file has been opened, we can read and write as many
times as we would like in the same session:
OPENFILE <filename> FOR RANDOM
Move a pointer to the disk address for the record before
Reading/writing to a file can occur:
SEEK <filename>, <address>

Each record is given an ‘address’ at which it is to be written –


the record key.

Write a record to the file:

PUTRECORD <filename>, <identifier> Delete a record:


Read a record from a file:
GETRECORD <filename>, <identifier>

Close the file:

CLOSE <filename>
Algorithms for File Processing Operations for Serial and
Sequential Files:
Display all records:

Amend an existing record:

Search for a record:

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE
Python example of Sequential File Handling:

Algorithms for File Processing Operations for Random


Files:

Display all records: Amend an existing record:

Add a new record:

Search for a record:

Python:

Python:

Delete a record:

Python example of Random File Handling:

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE
Compiler Interpreter
Directly executes/performs
Translates source code (e.g.
instructions written in a
Python code) into machine
programming language by
code, which can be run and
translating one statement at a
executed by the computer
time.
It takes significant time to
It takes less time to analyze the
analyze the source code, but
source code, but the execution
the overall execution time is
time is slower.
comparatively faster.
Generates intermediate objectNo intermediate object code is
code, which further requires
generated; hence, it is memory
linking and more memory. efficient.
It generates the error message Continues translating the
only after scanning the whole
program until the first error is
program. Hence, debugging is met, in which case it stops.
comparatively complex. Hence, debugging is easy.
Programming languages like
Programming languages like C
Python and Ruby use
and C++ use compilers.
interpreters.

Systems that require high performance and for the long


run should be written in compiled languages like C, C++,
Systems that need to be created quickly and easily
should be written in interpreted languages

Features available in debuggers:


Exception Handling
An exception is a runtime error/ fatal error/situation
which causes a program to terminate/crash.
Exception-handling – code that is called when a run-time
error or “exception” occurs to prevent the program from
crashing
When an exception occurs, we say it has been “raised.”
You can “handle” the exception raised by using a try
block.
A corresponding except block “catches” the exception
and returns a message to the user if an exception occurs.
e.g.

8.3. Use of Development Tools and


Programming Environments
Integrated Development Environment: an application
that provides several tools for software development. An
IDE usually includes: a Source code editor, debugger and
automated builder
Features in editors that benefit programming:
Syntax Highlighting: keywords are coloured
differently according to their category
Automatic indentation: after colons, for example,
to make code blocks more distinct, allowing for
better code readability
A library of preprogrammed subroutines that can be
implemented into a new program to speed up the
development process

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 LEVEL COMPUTER SCIENCE

Stepping - traces through each line of code and steps


into procedures. Allows you to view the effect of each
statement on variables
Breakpoints - set within code; program stops
temporarily to check that it is operating correctly up to
that point
Go to File/Line - Look at the current line. Use the cursor
and the line above for a filename and line number. If
found, open the file if not already open, and show the
line. Use this to view source lines referenced in an
exception traceback and lines found by Find in Files. Also
available in the context menu of the Shell window and
Output windows.
Debugger (toggle) - When active, code entered in the
Shell or run from an Editor will run under the debugger.
In the Editor, breakpoints can be set with the context
menu. This feature is still incomplete and somewhat
experimental.
Stack Viewer - Show the stack traceback of the last
exception in a tree widget with access to local and global
variables.
Auto-open Stack Viewer - Toggle automatically opening
the stack viewer on an unhandled exception.

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Viduranga at Royal Institute on 09/12/24.
CAIE A2 Level
Computer Science

© ZNotes Education Ltd. & ZNotes Foundation 2024. All rights reserved.
This version was created by Viduranga on Mon Dec 09 2024 for strictly personal use only.
These notes have been created by Ashmit Bhola for the 2024-2025 syllabus.
The document contains images and excerpts of text from educational resources available on the internet and printed books.
If you are the owner of such media, test or visual, utilized in this document and do not accept its usage then we urge you to contact us
and we would immediately replace said media. No part of this document may be copied or re-uploaded to another website.
Under no conditions may this document be distributed under the name of false author(s) or sold for financial gain.
"ZNotes" and the ZNotes logo are trademarks of ZNotes Education Limited (registration UK00003478331).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy