KEMBAR78
CAIE-A2 Level-Computer Science | PDF | Internet Protocols | Network Packet
0% found this document useful (0 votes)
3K views26 pages

CAIE-A2 Level-Computer Science

Uploaded by

ndaba7709
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)
3K views26 pages

CAIE-A2 Level-Computer Science

Uploaded by

ndaba7709
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/ 26

ZNOTES.

ORG

UPDATED TO 2023-2025 SYLLABUS

CAIE A2 LEVEL
COMPUTER SCIENCE
SUMMARIZED NOTES ON THE THEORY SYLLABUS
Prepared for Bruv 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
1.1. User-Defined Data Types reference to another type. When a programmer uses a
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 Bruv at undefined on 21/10/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) / Use the diagram to state the current values of the following
expressions.
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 i 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 that allows the file to be used as intended. But, for storing
which data to be used by a computer program, there are only two
as de defined file types: text or binary.

SecondPointer <-- @<identifier> //This stores A text file contains data stored according to a defined
SecondPoint character code defined by ASCII or Unicode. A text file
SecondPointer^ <-- MyVariable //This stores t can be created using a text editor.
memory locati A binary file is a file designed for storing data to be used
by a computer program(0's and 1's). It stores data in its
internal representation(an integer value might be stored
e.g in 2 bytes in 2's complement representation to represent
a negative number), and this file is created using a
specific program. Its organisation is based on records (a
collection of fields containing data values). file → records
→ fields → values

Methods of File Organisation and Access

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE

Proper file organisation is crucial as it determines access A sequential database file is more efficient than a text file
methods, efficiency, flexibility, and storage devices. due to data integrity, privacy and less data redundancy. A
change in one file would update any other files affected.
Serial files: contains records that have no defined order. A Primary keys from the DBMS(database management
text file may be a serial file with repeating lines defined by system) must be unique but not ordered, unlike the key
an end-of-line character(s). Records are stored, one after field from the sequential files, which must be ordered
another, in the order they were added to the file. New and unique.
records are added at the end of the file. A particular record is found by sequentially reading the
There's no end of record character. A record in a serial key field's value until the required value is found. New
file must have a defined format to allow data to be input records must be added to the file in the correct place.
and output correctly. To access a specific record, it has to Advantages of sequential file organisation
go through every record until found.
Serial file organisation is frequently utilised for The sorting makes it easy to access records but does not
temporarily storing transaction files that will eventually remove the need to access other records as the search
be moved to more permanent storage. looks for particular records.
The binary search technique can reduce record search
Advantages of serial file organisation time by half the time.
The task at hand is straightforward. File Access
The cost is low.

Disadvantages of serial file organisation Records in this type of file are searched using the Sequential
Access and Direct Access methods.
It becomes difficult to access because you must access
all proceeding records before retrieving the one being Retrieving records using Sequential Access:
searched. Successively read the value In the key field until the
It cannot support modern high-speed requirements for required key is found or the key field of the current
quick record access. record being checked is greater than the key field
File access: Records in this file type are searched using searched for. (This would mean the required record
Sequential Access. Successively read record by record is not in the file).
until the required data is found or the whole file has The rest of the file does not need to be searched as the
been searched, and the required data is not found, thus records are sorted on ascending key field values. This
prolonging the process. Uses: method is efficient when every record in the file needs to
Batch processing be processed.
Backing up data on magnetic tape Retrieving records using Direct Access:
Banks record transactions involving customer accounts
every time there is a transaction. This method finds the required record without reading
other records in the file. This allows the retrieval of
Sequential Files records more quickly. An index of all the key fields is kept
and used to look up the address of the file location
Sequential files are records ordered and suited for long- where the required record is stored.
term data storage and thus are considered an alternative to This method is efficient when an individual record in the
a database. A key field is required to order a sequential file file needs to be processed.
for which the values are unique and sequential—this way, it
can be easily accessed. To edit/delete data:
Create a new version of the file. Data is copied from the
old file to the new file until the record is reached, which
needs editing or deleting.
For deleting, reading and copying the old file, continue
from the next record. If a record has been edited, the
new version is written to the new file and the remaining
records are copied to the new file.
Random Files

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE

Records are stored randomly in the file but are accessed Most suited for when a program needs a file in which
directly. The location for each record is found using a individual data items might be read, updated or deleted.
Hashing Algorithm on the record's key field. Magnetic
and optical disks use random file organisation. Factors that Determine the File Organisation to
Use
Advantages of random file organisation

Quick retrieval of records. How often do transactions occur, and how often does
The records may vary in size. one need to add data?
How often does it need to be accessed, edited, or
Direct Access Files deleted?

File access: Records in this file type are searched using the 1.3. Floating-Point Numbers,
Direct Access method. A hashing algorithm is used on the
key field to calculate the address of the file location where a
Representation, and Manipulation
given record is stored.
The Real Number: A number that contains a fractional
Direct access/random access files: access isn't defined by
part.
a sequential reading of the file(random). It's well suited for
Floating-point Representation: The approximate
larger files, which take longer to access sequentially. Data in
representation of a real number using binary digits.
direct access files are stored in an identifiable record, which
could be found by involving initial direct access to a nearby Format: Number = ±Mantissa × BaseExponent
record followed by a limited serial search. Mantissa: The non-zero part of the number.
Exponent: The power to which the base is raised to
The choice of the position must be calculated using data in order to accurately represent the number.
in the record so the same calculation can be carried out Base: The number of values the number systems allows
when there's a search for the data. One method is the a digit to take. 2 in the case of floating-point
hashing algorithm, which takes the key field as an input representation.
and outputs a value for the record's position relative to The floating point representation stores a value for the
the file's start. To access, the key is hashed to a specific mantissa and the exponent.
location. Some bits are used for the significant/mantissa, +-M. The
This algorithm also considers the potential maximum remaining bits are for the exponent, E. The radix, R, is
length of the file, which is the number of records the file not stored in the representation as it has an implied
will store. value of 2(representing 0 and 1s).
e.g., If the key field is numeric, divide by a suitable large If a real number was stored using 8 bits: four bits for the
number and use the remainder to find a position. But we mantissa and four bits for the exponent, each using two
won't have unique positions. The next position in the file complement representations. The exponent is stored as
is used if a hash position is calculated that duplicates one a signed integer. The mantissa has to be stored as a fixed
already calculated by a different key. This is why a search point real value.
will involve direct access, possibly followed by a limited The binary point can be in the beginning after the first
serial search. That's why it's considered partly sequential bit(immediately after the sign bit) or before the last bit.
and partly serial. The former produces smaller spacing between the values
that can be represented and is more preferred. It also
File access: has a greater range than the fixed representation.
The value in the key field is submitted to the hashing
algorithm, which then provides the same value for the
position in the file that was provided when the algorithm
was used at the time of data input. It goes to that hashed
position and through another short linear search
because of collisions in the hashed positions—fastest
access.

To edit/delete data:
Only create a new file if the current file is full. A deleted
record can have a flag set so that the record is skipped
over in a subsequent reading process. This allows it to be
overwritten.

Uses:

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE

For negatives, use 2's complement.


When implementing the floating point representation, a
decision must be made regarding the number of bits to
use and how many for the mantissa and exponent.
Usually, the choice for the total number of bits will be
provided as an option when the program is written.
However, the floating point processor will determine the
split between the two parts.
If there were a choice, it's convenient to note that
increasing the number of bits for the mantissa would
give better precision but leave fewer bits for the
exponent, thus reducing the range of possible values and
Converting a denary value expressed as a real number into a vice versa. For maximum precision, it is necessary to
floating point binary representation: Most fractional parts do normalise a floating point number.
not convert to a precise representation as binary fractional Optimum precision will only be made once full use is
parts represent a half, a quarter, an eighth…(even). Other made of the bits in the mantissa, therefore using the
than .5, there are no different values unless the ones above largest possible magnitude for the value the mantissa
can be converted accurately. So you convert by multiplying represents.
by two and recording the whole number part. Also, the two most significant bits must differ—0 1 for
For example, 8.63, 0.63 * 2 = 1.26; therefore, .1 -> 0.26 * 2 = positives and 10 for negatives.
0.52 and .10 -> 0.52 * 2 = 1.04 and .101, and you keep going They both equal two, but the second one with the higher
until the required bits are achieved. bits in the mantissa is the most precise.
The method for converting a positive value is: 0.125 * 2^4 = 2 0 001 0100
1. Convert the whole number part 0.5 * 2^2 = 2 0 100 0010
2. Add the sign bit 0 -For negatives.
3. Convert the fractional part. You start by combining the
two parts, giving the exponent value zero. Shift the binary 0.25 * 2^4 = -4 1 110 0100
points by shifting the decimal to the beginning, providing a 1.0 * 2^2 = -4 1 000 0010
higher exponent value. Depending on the number of bits, When the number is represented with the highest
add extra 0's at the mantissa's end and the exponent's magnitude for the mantissa, the two most significant bits
beginning. are different. Thus, a number is in a normalised
4. Adjust the position of the binary point and change the representation. How a number could be normalised: for
exponent accordingly to achieve a normalised form. a positive number, the bits in the mantissa are shifted
Therefore: 8.75 -> 1000 -> 01000 -> .11 -> 010000.11 -> left until the most significant bits are 0, followed by 1.
0.100011(mantissa) -> 0100011000 0100(10 for M, and 4 for For each shift left, the value of the exponent is reduced
E). 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 Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE

Saves space by storing many numbers using the smallest 1. The conversion of real denary values to binary mainly
bytes possible. needs a degree of approximation followed by
Normalization reduces the representation of leading restricting the number of bits used to store the
zeros or ones. mantissa. These rounding errors can become
Maximizing the precision or accuracy of the number for significant after multiple calculations. The only way to
the given number of bits. prevent a severe problem is to increase the precision
Allows for the precise storage of both very large and very by using more bits for the mantissa. Programming
small numbers. languages, therefore, offer options to work in
Avoids the possibility of many numbers having multiple double/quadruple precision.
representations. 2. The highest value represented is 112; thus, it is a
limited range. This produces an overflow condition. If
Precision vs Range. a result value is smaller than one that can be stored,
there would be an underflow error condition. This
Increasing the number of bits for mantissa increases the very small number can be turned into zero, but there
precision of the number. are several risks, like multiplication or division of this
The number range can be increased by increasing the value.
number of bits for exponent. 3. There is an inability to store the number 0 using
Precision and range will always be a trade-off between normalised floating point numbers. This is because
the mantissa and exponent size. 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.

2. Communication and
Internet Technologies
2.1. Protocols
Problems with Using Floating Point Numbers A protocol sets the rules of the communication. Protocols
allows for devices to communicate across different
platforms. If two devices attempted to communicate while
using different protocols, the communication would fail.
TCP/IP is the dominant protocol suite for internet usage.
There are the main types of protocols:

HTTP and HTTPS (Hypertext Transfer Protocol): Used


to transfer webpages from server to client. HTTPS is
more secure.
FTP (File Transfer Protocol): Used for sending and
receiving files over the network between two devices.
POP3 (Post Office Protocol): Used for receiving emails.
IMAP (Internet Message Access Protocol): Also used
for receiving emails. The email client retrieves the emails
from the mail server.
SMTP (Simple Mail Transfer Protocol): Used for
sending emails

TCP/IP Suite

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE

A layered model (stack) with 4 layers; Application. Handles the transmission of data using IP addresses.
transport, internet and data link. The Suite uses a set of Identifies the intended network and host and then
protocols for the transmission of data in these layers like transmits the packets through the data link layer.
TCP (Transport Control Protocol) and IP (Internet Routes each packet independently through the best
Protocol). route available
TCP maintains connection between two nodes and IP Addresses, of the sender and receiver, and checksum
ensures delivery of data between the two nodes. are added when sending messages
IP provides rules of exchange for packets and decides When receiving a message it reassembles the fragments,
the route for sending packets. 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.
Ensures correct network protocols are followed.
Verifies the checksum when receiving a message and
then sends it to the internet layer

Peer-to-peer File Sharing


Application Layer: BitTorrent uses Peer-To-Peet file sharing model.
A BitTorrent client software is made available to the
The application layer provides user services. public.
Encodes data in an appropriate format when sending a Swarm: All connected peer computers that have all or
message parts of file being downloaded/uploaded.
Performs the action requested by the user when Tracker: A central server that stores information on
receiving a message which computers have which files and which parts of
Transport Layer: those files. It also shares the IP addresses of computers
to allow them to connect to each other.
Handles packets. Seed: is the peer computer that uploads the file that is
Converts the data received from the application layer being downloaded.
into individual packets when sending a message.
Adds packet headers and then sends these packets to If a user wishes to join this network, they need to use a
the internet layer. BitTorrent client to load the torrent descriptor file. When a
Controls the flows of packets and handles packet loss or user wishes to download a file, pieces of this file are
corruption. downloaded and uploaded at the same time. When a user
When receiving a message it reads the header and has even a single piece of a file they become a seed. To be
determines which application layer the data must be able to download this file, a complete copy needs to exist on
sent to, then strips the header and forwards it one of the peer computers.

Internet Layer: 2.2. Circuit Switching, Packet Switching


Circuit Switching

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE
Circuit Switching Packet Switching
Dedicated circuit is selected before the communication Data segmented into
starts and is used to send all the data through this route. Nature Dedicated channel
packets
- Uses the whole bandwidth. Requires pre-established
Releases circuit once the communication ends. Setup No prior setup needed
channel
Used for live video broadcasts or calling Data Message gets split into
Data arrives in order so it doesn’t need to be Message remains intact
handling packets
reassembled. Path recalculated each
Transmission Single Path
Whole bandwidth is available. time
Data can’t get lost. Order In order May need reassembly
Less secure as it only uses one route. Layer (Data) Link Layer Network Layer
No alternative route in case of failure. Makes full use of Bandwidth can be
Bandwidth can’t be shared. Bandwidth
bandwidth shared
Error Communication ends Allows packets to be
Packet Switching handling incase of an error resent
Complexity Simple More complex
Data is split into multiple packets and each packet a
route is calculated for each packet.
Each packet contain a header, which has a source IP 3. Hardware and Virtual
address and destination IP address, and a payload.
Calculates the most efficient path for each packet. Machines
Used when sending large files that don’t need to be live
streamed or when it is necessary to be able to overcome
faulty lines by rerouting like emails, text messages, 3.1. Processors
sending documents, etc.
Harder to intercept as new route is used each time. Complex Instruction Set Computer (CISC)
Packets need to be reassembled.
If there’s a missing packet, a request is sent to retransmit Many different instruction formats which means that
the data. different instructions can take a different number of
clock cycles to be executed.
Role of Router: Programmable CU.
Uses few registers.
Examines the header and finds the destination IP Relies a lot on cache memory rather than RAM.
address. Cache isn’t split between data and instructions.
Decides the best route for the packet, with the help of
the information from the routing table, and sends it Reduced Instruction Set Computer (RISC)
towards the next hop.
Instructions executed in a single clock cycle as the
2.3. Comparison instructions are simple and have a fixed length.
Hardwired CU.
Makes use of many registers.
Doesn’t rely on cache as much compared to RAM.
Cache split between data and instructions.

Comparison

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE
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
The ISR (Interrupt Service Routine) is loaded onto the
Instruction Amount Few Many
pipeline and is executed.
Instruction Formats Few Many
When the interrupt has been serviced, the paused
Can be pipelined Yes No
processes are resumed by bringing them back from the
Addressing modes Few Many registers to the pipeline
Circuit Complexity Less complex Complex RISC processors allow for providing efficient pipelining.
Register use High Low Pipelining is instruction-level parallelism. Its underlying
Memory reliance Relies on RAM Relies on cache principle is that the fetch-decode execute cycle can be
Is cache split Yes No separated into several stages.
Control unit Hardwired Programmable
3.2. Parallel Processing
Pipelining
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


Used extensively in RISC processor-based systems to (SIMD)
reduce the time taken to run processes
Allows several instructions to be executed Parallel computers with many processors execute the
simultaneously therefore increasing the rate at which the same instruction set using different data sets and do so
CPU processes instructions. sequentially.
Each instruction is divided into 5 parts: Can take advantage of pipelining.
1. Instruction Fetch (IF) Commonly used to process 3D graphics.
2. Instruction Decode (ID)
3. Operand Fetch (OF) Multiple Instruction Stream Single Data Stream
4. Instruction Execute (IE) (MISD)
5. Write Back (WB)
During each clock cycle, each subtask is completed. Parallel computers with many processors execute
For example, when one instruction is being decoded, different instructions using the same data set.
another one is being fetched in the same cycle. Used to sort large quantities of data.
No two instructions can execute the same subtask in the
same cycle; only one instruction can be decoded at a Multiple Instruction Stream Multiple Data Stream
time. (MIMD)
Interrupt handling Many processors execute different instructions using
different data sets.
All processors work independently.
Commonly used in parallel computer systems.

Massively Parallel Computers

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE
A large number of computer processors that are connected A B X
together simultaneously performing a set of coordinated 0 0 0
instructions. As the computers are connected together, they 0 1 0
communicate over the network by sending messages. 1 0 0
One hardware issue faced by these computers is that 1 1 1
processors need to communicate with each other to be able
to transfer data between them. One software issue faced by
these computers is that there needs to be an algorithm that
splits the data between them for efficient processing.
When an app is being made for these computers, it needs to
be able to split the code to allow for simultaneous execution
rather than sequential.

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. OR Gate: A + B = X
Host: The original OS
A B Output
Pros Cons
0 0 0
Performance of the guest
Multiple operating systems can might not be accurate if it were 0 1 1
be run on the same device. to be run individually as there 1 0 1
is a greater load on the host. 1 1 1
Cannot emulate certain
A virtual machine can crash hardware as the hardware may
without affecting the host. have been developer after the
virtual machine.
Virtual machine may be
Can run legacy software by
affected by the weakness of
running it on the guest OS.
the host.
Can test software for different
platforms on the same device Greater maintenance cost as
without needing to purchase you have to maintain host and
hardware for the second guest OS.
system.
Register use High
Memory reliance Relies on RAM
NOT Gate: A = X
4. Hardware and Virtual A Output
Machines 0
1
1
0

4.1. Logic Gates & Circuit Design


Logic Gates: A component of a logical circuit that can
perform a Boolean operation (logical function).

AND Gate: A.B = X

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE

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

A B Output A B Output
0 0 1 0 0 0
0 1 1 0 1 1
1 0 1 1 0 1
1 1 0 1 1 0

NOR Gate: A + B = X

A B Output
0 0 1
0 1 0
1 0 0
1 1 0

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE

Logic circuits: A circuit that performs logical operations Double Complement: A = A


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

{example}

4.3. Karnaugh Maps

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/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 Bruv at undefined on 21/10/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 Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE

5.5. Syntax Diagrams and BNF


For interpreters:
Analysis and code generation run for each code line BNF is a formal mathematical way of defining syntax
as above unambiguously.
Each line is executed as soon as the intermediate It consists of:
code is generated
A set of terminal symbols
5.4. RPN (Reverse Polish Notation) A set of non-terminal symbols
A set of production rules
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 +

Compilers use RPN because any expression can be


processed from left to right without backtracking.

Advantages of RPN
● RPN expressions do not need brackets, and there is no
need for the precedence of operators
● RPN is simpler for a machine to evaluate
● There is no need for backtracking in evaluation as the
operators appear in the order required for computation and
can be evaluated from left to right

Infix to Reverse Polish Notation

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE

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

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE

1. If symmetric key encryption is used, there needs to Using asymmetric encryption, the decryption works if
be a secure method for the sender and receiver to be the keys are used the other way around. An individual
provided with the secret key. can encrypt a message with a private key and send this
2. Using asymmetric key encryption, the process starts to many recipients with the corresponding public key
with the receiver. The receiver must have two keys. and can, therefore, decrypt the message. This is not for
One is a public key, which is not secret. The other is a confidential messages but can be used to verify who the
private key, which is secret and known only to the sender is. Only the sender has the private key, and the
receiver. The receiver can send the public key to a public keys only work with that specific private key.
sender, who uses the public key for encryption and Therefore, used this way, the message has a digital
sends the ciphertext to the receiver. The receiver can signature identifying the sender. However, the digital
only decrypt the message because the private and signature is associated with the encryption of the whole
public keys are matched. The public key can be message.
provided to different people, allowing the receiver to Cryptographic one-way hash function creates from
receive a private message from any of them. the message a number uniquely defined for the
particular message, a digest. The private key is used as a
6.2. Digital Signatures and Digital signature for this digest. This speeds up the process of
confirming the sender's identity.
Certificates 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.
However, someone might forge a public key and pretend
to be someone else. Therefore, there is a need for a
more rigorous means of ensuring authentication. This
can be provided by a Certification Authority (CA) as part
of a Public Key Infrastructure (PKI).

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE

![PROCESSES INVOLVED IN OBTAINING A DIGITAL


CERTIFICATE: Individuals place the digital certificate on
that person's website, but you can post it on a website
designed to keep digital certificate data. Alternatively, a
digital certificate might be used solely for authenticating
emails. Once a signed digital certificate has been posted
on a website, any other person wishing to use A's public
key downloads the signed digital certificate from the
website and uses the CA's public key to extract A's public
key from the digital certificate. For this overall process to
work, standards need to be defined.

6.3. Encryption Protocols


SSL and TLS encryption protocols are used in client-
server applications.
SSL (Secure Socket Layer) and TLS (Transport Layer
Security) are closely related Internet security protocols.
TLS is a slightly modified version of SSL. The main use of
SSL is in the client-server application. The interface
between an application and TCP uses a port number.
Without a security protocol, TCP services an application
using the port number.
The combination of an IP address and a port number is
the socket. When the SSL protocol is implemented it
Suppose a would-be receiver with a public-private key pair functions as an additional layer between TCP in the
wishes to receive secure messages from other individuals. In transport layer and the application layer. The HTTP
that case, the public key must be made available in a way application protocol becomes HTTPS when the SSL
that ensures authentication. The would-be receiver would protocol is in place.
need to obtain the digital certificate to allow safe public key Provides:
delivery: Encryption
1. An individual(A) who is a would-be receiver with a Compression of data
public-private key pair contacts a local CA. Integrity checking
2. The CA confirms the identity of A. Connection Process:
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.

Used in online shopping and banking websites.

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE
Machine learning is a field of artificial intelligence in which
6.4. Malware computers learn from provided data and past experiences in
order to improve its performance in a given task without
Virus: tries to replicate inside other executable explicitly being programmed to know how to do the task. For
programs. example, rather than telling the computer that emails that
Worm: runs independently and propagates to other advertise free products are most likely scams we feed it a lot
network hosts. of data and it identifies that pattern on its own.
Spyware: collects info & transmits to another system.
Phishing: email from seemingly legit source requesting Deep Learning
confidential info.
Pharming: setting up a bogus website that appears to be A subset of machine learning that simulates the decision
legit. making and data processing abilities of the human brain.
Benefits:
Malware Vulnerabilities exploited
Good with extremely large sets of data
Virus Executable files used to run or install software.
Good with unstructured data
Worm Shared networks
Can identify hidden patterns
Spyware Background processes
Users mindset on considering emails from Reinforcement Learning
Phishing
random addresses to be trustworthy
Users’ mindset of relying on the website’s user Reinforcement learning allows the computers to make
Pharming
interface rather than the URL for its validity. decisions that maximize the reward, it is then graded based
on how well it performed. Over time the computer learns
Malware Methods of restriction the correct decisions it needs to make based on its past
Install and use an Anti-Virus software that runs experiences.
Virus
daily scans.
Set up a firewall to protect yourself from Supervised Learning
Worm
external networks.
Install and use real-time Anti-Spyware In supervised learning the computer is fed labelled test data,
Spyware
protection.
and it identifies the patterns that led to the data being
Phishing Always check the sender’s email address. labelled in a specific way. This allows it to then predict labels
Pharming Always double-check the website name. for new unseen data.

Unsupervised Learning
7. Artificial Intelligence (AI)
In unsupervised learning the computer is fed unlabeled test
Neural Networks data, and it identifies hidden patterns.

Neural networks are modelled on the human brain. Back Propagation of Errors
They contain input and output nodes as well as one or
more hidden layers. An algorithm identifies errors with the machine learning and
Each input node is assigned a specific weight, these is then used to adjust the model for improved accuracy by
weights are summed, and an activation function starting at the output layer and working backwards through
calculates a value for the output. the hidden layers to the input layer.
Repeated for each layer within the network thereby For example, if you threw a ball and missed your target.
allowing reinforcement learning to take place. You'd check how far off you were from the target and then
adjust things like angle and strength the next time you threw
Use of Hidden Layers: the ball.
Allow deep learning to take place Regression
Allows the network to make decisions independently
Helps to improve the accuracy of the output Regression is finding a mathematical function that best fits
out output data based on the previous results in order to
Machine Learning 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 Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE
A graph is an abstract datatype that contains a collection of
nodes. These nodes are connected to each other with edges.
A node usually has a name, and an edge usually has a
numerical value.
One example of graphs is A* or Dijkstra's algorithm. The
nodes represent locations, and the edges represent the
distance between them.

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
Use of Graphs case, Node A).
From A, there are two immediate nodes, B and E.
Graphs provide relationships between different nodes. Calculate the g value for each node and add the g value
Allows AI problem to be defined as the most efficient of A. Then, add the corresponding h values to get f for
route between two nodes each node.
Analyzed by machine learning algorithms such as A* to From E, there are two immediate nodes, School and F.
perform calculations Calculate the g value for each node and add the g value
Graphs can also be used to represent neural networks. of E. Then, add the corresponding h values to get f for
each node.
A* and Dijkstra’s Algorithm From F to School, add the g value (3) to the g value of F
(8) and calculate f.
These algorithms are used to find the shortest route
between two nodes based on the distance. Final path = Home → A→E→F→School.
The main issue with Dijkstra's algorithm is that it is
inefficient when searching for the shortest path.
Dijkstra's algorithm is A* but if the heuristic value was
always 0.

Using these algorithms


h is the heuristic value
g is the movement cost
F is the sum of g and h values.

7.2. Use of Development Tools and


Programming Environments

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE

Integrated Development Environment: an application Stepping - traces through each line of code and steps
that provides several tools for software development. An into procedures. Allows you to view the effect of each
IDE usually includes: a Source code editor, debugger and statement on variables
automated builder Breakpoints - set within code; program stops
Features in editors that benefit programming: temporarily to check that it is operating correctly up to
Syntax Highlighting: keywords are coloured that point
differently according to their category Go to File/Line - Look at the current line. Use the cursor
Automatic indentation: after colons, for example, and the line above for a filename and line number. If
to make code blocks more distinct, allowing for found, open the file if not already open, and show the
better code readability line. Use this to view source lines referenced in an
A library of preprogrammed subroutines that can be exception traceback and lines found by Find in Files. Also
implemented into a new program to speed up the available in the context menu of the Shell window and
development process Output windows.
Debugger (toggle) - When active, code entered in the
Compiler Interpreter Shell or run from an Editor will run under the debugger.
Directly executes/performs In the Editor, breakpoints can be set with the context
Translates source code (e.g.
instructions written in a menu. This feature is still incomplete and somewhat
Python code) into machine
programming language by
code, which can be run and
translating one statement at a
experimental.
executed by the computer Stack Viewer - Show the stack traceback of the last
time.
It takes significant time to exception in a tree widget with access to local and global
It takes less time to analyze the variables.
analyze the source code, but
source code, but the execution Auto-open Stack Viewer - Toggle automatically opening
the overall execution time is
time is slower.
comparatively faster. the stack viewer on an unhandled exception.
Generates intermediate objectNo intermediate object code is
code, which further requires
linking and more memory.
generated; hence, it is memory
efficient. 8. Further Programming
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. 8.1. Programming Paradigms
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:

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE

Reading a file:
8.2. File Processing and Exception Read all characters
Handling variable.read()
Read each line and store it as a list
File Processing variable.readlines()
Writing to a file:
Records are user-defined data structures Write a fixed sequence of characters to file
Defining a record structure for a Customer record with variable.write(“Text”)
relevant fields (e.g., customer ID) in Python: Write a list of strings to file
variable.write[“line1”, “line2”, “line3”]
Using direct access or Random File allows us to read
records directly. ‘random’ is misleading since records are
still systematically read from and written to the file.

Pseudocode:

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
Files are needed to import contents (from a file) saved in
Move a pointer to the disk address for the record before
secondary memory into the program or to save the
Reading/writing to a file can occur:
output of a program (in a file) into secondary memory so
SEEK <filename>, <address>
that it is available for future use.
Each record is given an ‘address’ at which it is to be written –
Pseudocode:
the record key.
Opening a file:
Write a record to the file:
OPENFILE <filename> FOR READ/WRITE/APPEND
Reading a file: PUTRECORD <filename>, <identifier>
READFILE <filename>
Writing a line of text to the file: Read a record from a file:
WRITEFILE <filename>, <string>
Closing a file: GETRECORD <filename>, <identifier>
CLOSEFILE Close the file:
Testing for the end of the file:
EOF() CLOSE <filename>
Algorithms for File Processing Operations for Serial and
Python: Sequential Files:
Opening a file Display all records:
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
exists or creates a new file if it doesn’t
Opens a file for appending. Pointer at the end of the
a
file if it exists or creates a new file if not Search for a record:

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE
*Special Case: If the records in a sequential file are of a fixed Python example of Sequential File Handling:
length, a record can be retrieved using its relative position.
So, the start position in the file could be calculated for the
record with the key number 15, for example.

Add a new record – Serial Organisation:

Add a new record – Sequential Organisation:

*Some file processing tasks, like this one, require two files
because serial/sequential files can only be opened to read
from or write to in the same session.* Algorithms for File Processing Operations for Random
Files:

Display all records:

Add a new record:

Delete a record:

Python:

Amend an existing record:

Delete a record:

WWW.ZNOTES.ORG Copyright © 2024 ZNotes Education & Foundation. All Rights Reserved. This document is
authorised for personal use only by Bruv at undefined on 21/10/24.
CAIE A2 LEVEL COMPUTER SCIENCE

Amend an existing record:

Exception Handling
Search for a record: 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.

Python:

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 Bruv at undefined on 21/10/24.
CAIE A2 Level
Computer Science

© ZNotes Education Ltd. & ZNotes Foundation 2024. All rights reserved.
This version was created by Bruv on 07/10/24 for strictly personal use only.
These notes have been created by Shrey Agarwal and Reyansh Roy for the 2023-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