9618 computer science notes
9618 computer science notes
Paper 1
Benefits of BCD
Applications of BCD
● electronic displays e.g. calculators, digital clocks – only need to show individual
digits, conversion between denary and BCD is easier
● storage of date and time in BIOS of PC – conversion with denary is easier
Applications of Hexadecimal
● MAC addresses
● HTML colour codes
● can also be used to refer to memory addresses in assembly language and in
machine code
ASCII Representation
Similarities
2
Differences
● Unicode can represent multiple languages and a wider range of characters than
ASCII
● ASCII – 7bit, Extended ASCII – 8bit, UNICODE – 16bit
1.2 Multimedia
Graphics **
Bitmap Graphic
● made up of pixels, each of a single colour (with each colour having a unique binary
value)
● stored as sequence of binary numbers (store binary value of each pixel)
● prone to pixelation when enlarged
● larger file size – data is stored about each pixel
● can be compressed significantly
● more difficult to edit – each pixel needs to be edited separately
Pixel
File header
● Stores data (metadata) about the bitmap image (e.g. colour depth, image
resolution)
● Can store: file type, compression type, dimensions (width x height), file size
Image Resolution
● Total number of pixels in an image (number of pixels wide * number of pixels high)
● Increasing resolution – more pixels can be stored, image is sharper/less pixelated
● The number of bits used to represent each colour // number of bits per pixel
● Determines number of colours that can be represented in an image
3
● Increase in bit depth – image has greater range of colours and is closer to original
(leads to increased file size)
Vector Graphic
Drawing Object
Drawing Property
Drawing List
● the list of shapes that make up an image // list of all drawing objects in image
● stores commands required to draw each object
Sound **
Sound Representation
Sampling
4
Sampling Rate
● sound is recorded more often // smaller gaps in sound wave & between samples
● reduces quantisation errors
● improves accuracy – digital waveform resembles analogue one more closely
● increases file size (increases number of total samples taken – so more bits needed
to store the data, takes up more space in memory)
Sampling Resolution
● increases number of bits used to store each sample // more bits per sample
● wider range of amplitudes can be stored // more amplitudes can be represented
● file size increases
● digital waveform is closer to original (improves accuracy)
● smaller quantisation errors
Analogue data
1.3 Compression
Compression Reasons
● reduces file size – takes up less space in memory (leaves space for other files,
allows more images/files to be stored)
● faster download/upload rate (reduced transmission time) from/to web
● less bandwidth used to download/transmit
● original might be too large to send through email/as attachment
Lossy Compression
● Original data is lost/deleted (cannot be done in text file) & file cannot be
reconstructed
5
● If used on text file, it would corrupt (all data is required, otherwise it would not
make sense)
● Videos have a lower resolution, will buffer less if being streamed real-time, lowers
bandwidth required to transmit
● Used when all data is not required, quality can be reduced without user noticing or
if a significant reduction in file size is needed
Lossless Compression
Compressing Files
Sound **
● reduces amplitude range (to only range used) – reduces bits needed to store each
sample
● run-length-encoding – consecutive sounds grouped (binary value of sound
recorded along with number of times it repeats)
● record only changes in sound (not actual sounds)
● RLE – consecutive sounds grouped (binary value of sound recorded along with
number of times it repeats)
Images
(Lossy)
● reduce bit depth – reduces number of bits used to store a colour (each pixel has
fewer bits)
● reduce number of colours – fewer bits needed to store each colour
● reduce resolution – fewer pixels altogether (less binary to store)
(Lossless)
● RLE – replaces sequences of the same colour pixel with colour code and number of
identical pixels
Run-length Encoding **
RLE Limitations
● Works by storing a colour and the number of times it occurs consecutively – there
may not be many sequences of same colour
● It would store each colour then the count, which would be 1 – only adds to file size
// adds to total data
● E.g. RBG would become R1 B1 G1
7
2. Communication
LAN
allows…
WAN
Client-Server Model
Thick-Client
Thin-Client
Star Topology
Mesh Topology
Cloud Computing
Advantages
● can be free
● saves storage on existing devices
● data can be accessed from any device (with internet access)
● data will likely be backed up/ higher chance of recovery
● better security
● scalable & easily shared
Disadvantages
● freedom of movement (not fixed to a single location) – can move between rooms,
no need for physical connection // devices can be portable
● easily expandable/scalable if more devices want to join (ppl can join on multiple
devices)
● less cabling needed – cheaper setup
● allows access in remote locations (e.g. rural areas)
● higher latency
● affected by weather
● slower transmission speed
● direct line of sight needed
Copper Cables
Fibre-optic Cables
Radio Waves
Satellite
Switch
Server
Functions of WNIC
WAP
Bridge
Repeater
Role of Router **
Ethernet
● a protocol
● used for data transmission over a wired network
● uses CSMA/CD
● data is transmitted in frames – each frame has source and destination address and
error checking data
CSMA/CD (protocol)
● data from two nodes can start to transmit simultaneously, causing collision
● if collision occurs, nodes send signal to stop transmitting
● waits a random time before attempting to send data again
13
Bit Streaming
Real-time
● Used when watching a live stream of events that are currently taking place
● Event is captured live with a video camera connected to a computer
● Media is sent to user’s device/buffer via bit stream directly as it is being recorded
● Cannot be paused or rewound
On-demand
WWW
Internet
PSTN
IPv4
IPv6
Subnetting benefits **
● improves security – data stays in its subnet, not all devices can access all areas of
network, devices do not receive unintended data
● allows extension of network/easier to expand – allows greater range of IP
addresses
● reduces amount of traffic in a network – improves network speed, data stays
within subnet and devices are not flooded with data
● easier maintenance/management – only one subnetwork may need taking down,
rest can continue *faults can also be isolated more efficiently
IP address in subnetwork
Public IP address
Private IP address
Dynamic IP address
Static IP address
● does not change each time a device connects to the internet // is fixed
● A URL is entered into web browser and parsed to obtain the domain name
● The Domain name is sent to DNS
● DNS has database of domain names and their corresponding IP Addresses
● DNS searches its database for given domain name
● If found, the IP addresses is returned to web browser, which displays the
resource
● If not found, the request is forwarded to a higher level DNS and the IP addresses
returned is added to the database of the lower level DNS
16
3. Hardware
Embedded system **
Disadvantages
***no hardware operation questions have been repeated so far so chances are the other
devices we have to know (e.g. speakers, laser printers etc.) will likely come up***
Operation of 3D Printer
● additive manufacturing
● uses digital 3D model or CAD file
● builds up model one layer at a time – starting from bottom, using xyz coordinates
● material is fused together layer by layer
Microphone Operation
● has a diaphragm
● incoming sounds waves cause vibrations about diaphragm
● this causes coil to move past a magnet
● electrical signal is produced
Speaker
Advantages
● costs less per unit storage (used when large storage capacity is required)
● has more longevity (used with devices that work all the time and have large
number of read write operations)
● uses a grid of columns and rows (arrays/blocks) that has two transistors at each
intersection:
● floating gate – stores voltage (represents either a 1 or 0)
● control gate – controls movement of charge/electrons during read/write
operations
● not possible to overwrite existing data (need to erase first then write data into
location)
Advantages
● a rotating disk with concentric tracks made from a reflective metal layer
● data is read/written using laser light (either red or blue) that is shone onto the
disc
● data is stored in pits and lands on the track – sequences of amorphous and
crystalline states on the metallic layer (correspond to 0s and 1s)
● reading – reflected light from different states is encoded as a bit pattern
● writing – laser changes surface to crystalline or amorphous states based on the
bit pattern being stored
● read and write operation can occur simultaneously
Features/Uses
Purpose of a buffer
Process
RAM
● primary memory
● stores currently running part of software/data/OS/programs/processes
● either static or dynamic
● can store data about I/O devices, contents of buffer or information about current
process
SRAM Advantages/Disadvantages
DRAM Advantages/Disadvantages
ROM
● primary memory
● stores start-up instructions/BIOS, firmware, any permanently required data
● stores the kernel of the operating system // parts of OS
● PROM – can be set once
● EPROM – erased using UV light, needs to be removed from device, can be
overwritten multiple times, must be entirely erased to rewrite
● EEPROM – erased using voltage (no additional equipment is needed), erased
within device, can be overwritten multiple times, does not have to be entirely
erased before rewriting, contents of firmware can be changed easily
21
Control system
● uses feedback
● produces an action
Role of an Actuator
Importance of feedback
● instructions and data are stored in the same memory space/in main memory
● Buses
● Registers
● CPU
● CU
● ALU
● IAS
● System clock
Special Purpose Registers (All registers we have to know are special purpose)
Program counter
● stored address from memory location currently being read from or written to
(where data is being fetched from)
Index Register
Status Register
● stores flags – from results of logic and arithmetic operations // interrupt flags
● contains bits – can be individually set or cleared depending on operation
CU
System Clock
● system clock gives out timing signals – sent on the control bus, this synchronises
the other system components
● CU initialises data transfer – generates signals that are sent on control bus to
other components
Performance **
Number of cores
● software may not be designed for multiple cores – one core will be left idle
● memory access speed wont match speed of cores – causes delay
● may be other differences – e.g. amount of RAM
Bus Width
Clock speed
Cache
● higher capacity means it can store a higher amount of frequently used instructions
for fast access
25
Quantity of RAM
Ports
Purpose of an Interrupt
Interrupts **
● Once ISR finishes, check for further interrupts (if found, repeat cycle)
● Otherwise load data/contents from stack into registers and continue with previous
process
Two-Pass Assembler
Second Pass
Instruction Groups **
Immediate Addressing
Direct Addressing
Indirect Addressing
28
Indexed Addressing
● forms address from given address/address in operand plus the contents of the
index register
Relative Addressing
Binary Shifts – moving bits in a register a certain number of places within a register
Bit Masking
● memory management
● file management
● security management
● hardware management
● input/output management
● process management
● error checking and recovery
Memory Management
Security Management
● creates accounts/passwords
● provides firewall or anti-malware
● validates user and process authenticity
30
Hardware Management
Process Management
Utility Software **
Defragmentation – over time, saving and deleting small files fragments disk
● Scans for errors/inconsistencies in a disk and corrects them – prevents bad sectors
being used
● Reduces access times by optimising storage
● Creates copy of data in case the original is lost (in regular intervals)
● Allows retrieval of data is any is lost/corrupted
Disk/System clean up
Compression software
Virus Checker
Program Library **
● requires less main memory as DLL is only loaded once when needed
● executable file is smaller (does not contain all library routines)
● no maintenance needed from programmer (DDL is separate from program)
32
Assembler
Compiler **
After Testing
Interpreter **
When Testing
Partial Interpreters/Compilers
(programs may not need to be compiled if the software is already an executable file, has
been pre-compiled/built using compiler or if the source code has not been provided)
IDE Features/Tools **
Coding
Error Detection
Presentation
Debugging
34
● single stepping – allows programmer to run the code one line at a time (breaking
in between) so effects of each statement on values can be seen/checked
● breakpoints – stop the code executing at a set line (to check current
values/progress)
● report windows – output contents of variables and data structures (see how
variables change)
● variables & expressions
Data Security
● ensure recovery
Data Privacy
Data Integrity
Biometric passwords
Digital signatures
● regularly scans computer for viruses, checks against stored database of viruses
● database needs to be updated regularly
● if virus detected, it is quarantined or deleted
● compares downloaded files to database of known viruses – prevents download
from continuing
Anti-spyware
Backups
Encryption
Access rights
Virus/Malware
Spyware
● malicious software
● downloaded/run without user’s knowledge
● runs in background
● can pretend to be legitimate
Hacking/Hackers
Pharming – AUTOMATIC
Access Rights
Encryption
Validation
Verification
In parity blocks…
● *an error cannot be detected if an even number of bits has been changed, as they
could cancel each other out*
Copyright
● encryption
● use product key
● Compile source code (distribute as .exe file)
41
Software Licencing
● user can edit/improve source code (must be released under same conditions as
original software/same legal rights apply)
● user can redistribute the software
Shareware
● enables program to be copyrighted – user cannot legally modify it, control over
product is maintained, protects intellectual property rights
● user always gets a trial period – can also gain income if bought afterwards
● user cannot redistribute the software
● cannot be edited – developed keeps control
● more people might try it – free trial allows more people to experience it, meaning
they are more likely to buy it (also allows people to give feedback based on free
trial
Commercial Software
● user must pay before being able to legally use the software
● cannot be redistributed or edited
● enables program to be copyrighted – user cannot legally edit it, control over
product is maintained
● protects source code / prevents changes being made
● a fee can be charged for program – programmer gains income
42
● prevents illegal copies being made – action can be taken if this occurs
● for customer – likely to have fewer bugs, redress available if game is broken,
potentially better support as a fee is being charged
Applications of AI **
Social impacts
Economic Impacts
8. Databases
● reduced data redundancy – each data item is only stored once (due to linked
tables)
● maintains data consistency (data integrity) – changes in one table automatically
update in another
● complex queries easier to run
● can provide different views – user can only see specific aspects/parts of the
database (improved privacy)
● program-data independence – programs do not need to be rewritten if data is
changed (data is separate from software)
Entity
Field
● column/attribute in a table
Tuple (Record)
Primary Key
Candidate key
Secondary Key
● alternative/additional key used along with primary key to locate specific data
(candidate key that has not been chosen as primary key)
Foreign Key
Normalisation
1NF
2NF
3NF
● no transitive dependencies
● all attributes/fields fully dependant on primary key AND NO OTHER ATTRIBUTES
0NF to 1NF
1NF to 2NF
2NF to 3NF
DBMS
46
Data Dictionary Contents (metadata about database) // data abt data in a database
Logical Schema – shows structure of database, its relationships (e.g. E-R diagram)
Security in a DBMS
● authentication
● backup/recovery procedures – automatically creates copies of database and stores
it off-site on a regular basis, allows data to be recovered if lost
● access rights – users are given different access permissions to different tables,
read/write, read only etc.
● views – different user able to see different parts of database, only see what’s
required
● encryption – data is turned into ciphertext, cannot be understood without
decryption key
● record and table locking – prevents simultaneous access to data, so data is not
overwritten
column_name1 DATATYPE
PRIMARY KEY(column_name)
);
● Data Types
- CHARACTER
- VARCHAR(n) – like a string, VARCHAR(255) allows 255 characters
- BOOLEAN
- INTEGER
- REAL
- DATE
- TIME
48
Paper 2
Abstraction
Decomposition
49
Benefits
9.2 Algorithms
Stepwise Refinement
● set total/count to 0
● input a number
● check if…
● repeat from step # a set number of times // repeat for total of # iterations
● output the total/count/element/string
● calculate the rounded value of…
● assign value to an element
● use function … to return a value
● open file in read/write mode
● loop through all lines in a file
● loop ends when…
(obviously, be specific to the question, for example, say how many times it repeats and
from which step)
● declare a record – containing all data items required // containing items of different
data types
● declare an array of the given record – each array element represents data for one
instance of an object (e.g. would store one customer order)
Advantages of Records
Uses of BOOLEAN
● when the variable can only take one of two possible values
10.2 Arrays
10.3 Files
● Data items are combined to form a single string (set of data is saved as a single
line in file)
● Items are separated by a special character
Linked Lists
● Consists of nodes – each node contains data and a pointer to the next node
● Has a pointer to the start of list (start pointer)
● Last node in list has a null pointer (indicated there are no further nodes in list)
● Data is added by manipulating pointers (Data in nodes does not need to be moved)
● Nodes are traversed in sequence (based on pointers)
● Unused nodes are stored on free list
Advantages
Disadvantages
Queues
* first in first out – first data item put in queue is also the first one removed
Adding/inserting a value
Removing a value
● value pointed to by the front of queue pointer is removed first – can be assigned to
a variable
● front of queue pointer is incremented
Required Operations
● adding an item – a check needs to be carried out to ensure queue is not full
● removing an item – a check needs to be carried out to ensure queue is not empty
Implementing a queue
Stacks
● Used to store string data which needs to be accessed in several modules within a
program
Implementing a Stack
Why files may not appear correctly if using a stack (from O/N 2023 paper 22)
● If a multiple lines are stored at once, lines transferred to file will appear out of
sequence as stacks operate on a FILO basis
● Stack is full – not all lines can be stored on stack, resulting file will be missing
original lines
● Stack is empty – stack is being read faster than being written into, so blank lines
may be inserted into file
11. Programming
● Indentation
● White space
● Comments
● Meaningful variable names, use of camelCase
● Capitalised keywords
● Standard way to indicate special cases (such as unused array elements) – allows
recognition when processing, means there is no unexpected data
Constants
● More complex functions can be used in code through use of a program library
Use
● Used for tasks that are performed/repeated in several places within the code
● When part of an algorithm performs a specific task
● Reduces complexity of program
● Testing/debugging is easier
11.2 Constructs
Selection constructs
● IF statement
● CASE statement (from O/N 2023 paper 21)
- consists of clauses that are checked in sequence
- if a value satisfies the first clause, other clauses will never be tested
- the “otherwise” clause may never be performed if all possible values are
addressed via the other previous clauses
Iterative constructs
● WHILE pre conditional loop – used when number of iterations is not known
● REPEAT post conditional loop – used when number of iterations is not known
● FOR count-controlled loop – used for known number of iterations
56
Sequence construct
Functions/Procedures
Benefits
Benefits
Stages
Analysis
Design
57
Coding
Testing
Waterfall Design
Benefits
● easy to manage, stages do not overlap and are completed one at a time
● each stage has clear/specific deliverables (detailed documentation of project)
● leaves little room for client to change mind and the project is planned out
thoroughly, meaning a smoother development process (client also has better
idea of the finished product when designing it)
Disadvantages
Iterative Design
● development cycle is run repeatedly until full program has been developed
● split into stages which are repeated
Benefits
Drawbacks
Benefits
Drawbacks
Structure Chart
Purpose
Symbols
State-Transition Diagrams
Types of Maintenance
Adaptive
Perfective
● Changes are made to program after it has been made available to public
Corrective
Types of Testing
Beta Testing
Integration Testing
Stub Testing
Walkthrough Method
(Required Information)
● program is checked by creating a trace table, going through program one line at a
time
● records/checks variables as they change
● error may be indicated when…
- variable is given an unexpected value
- unexpected path through program/faults in logic of program
White-box Testing
Black-box Testing
Alpha Testing
Types of Errors
Syntax Errors
Run-time Errors
Test Data
Pseudocode
General Operations
INPUT variable_name
TYPE record_name
ENDTYPE
*referenced similarly to 2D arrays… name of the column in record is used as 2nd index
array_name[Index].column_name ← *value*
10.2 Arrays
10.3 Files
CLOSEFILE file_name
* file name should always end in .txt and be written in quotation marks e.g. “filename.txt”
* in exams, if given a file name as a variable, assume that is it already in the correct format
and includes the .txt portion
11. Programming
11.1 Basics
* use constants with variables that do not change throughout code, you get marks for
using them instead of variables
* when declaring multiple variables of the same data type, commas can be used and only
one declaration statement has to be made (e.g. DECLARE index, total, count : INTEGER)
11.2 Constructs (all have a statement indicating end of loop/condition e.g. ENDIF)
● if statements
IF <condition> THEN
ELSE
ENDIF
65
● case statements
CASE OF variable_name
ENDCASE
NEXT variable_name
REPEAT
UNTIL <condition>
WHILE <condition>
ENDWHILE
● procedure
ENDPROCEDURE
* there can also be no parameters, in which case leave brackets empty e.g.
parameter_name()
● function
ENDFUNCTION
Pass by Value
● a copy of the variable is passed into the module, the variable is not changed
outside of the module
Pass by Reference
— Paper 3 —
Composite
● Collection of data that consists of multiple elements of different (or the same) data
types which are grouped under a single identifier
● Can be user-defined or primitive
68
Record
● Uses other data types in its definition to form a single new one
● Data types referenced can be primitive or user-defined
● Includes related items and a fixed number of items
TYPE record_name
DECLARE field_name1 : DATA TYPE
DECLARE field_name2 : DATA TYPE
DECLARE field_name3 : DATA TYPE
ENDTYPE
Set
Non-Composite
● Enumerated
69
● Pointer
Serial Files
Sequential Files
Random Files
● Records are stored in no particular order within the file (there is no sequencing)
● There is a relationship between the record key and its location within the file – the
location of the record is found using a hashing algorithm
● Updates to the file can be carried out directly
● Records are checked linearly until the desired record is found/end of file is reached
● Starts searching for records one after the other from the physical start of the file
until the record is found or the end of the file is reached
● Most suitable when data is stored in a certain order based on a field – e.g. bank
stored data records in ascending order of account number
● Sequential Files
➔ an index of all key fields is kept – the index is searched for the address of
the file location where the target record is stored
● Random Files
➔ a hashing algorithm is used on the key field of the record to calculate
address of the memory location where the target record is expected to be
stored
➔ Linear probing or Search overflow can be used to find a record if it is not at
the expected location
Hashing algorithm
Hash Value Duplicates (a calculated hash value is a duplicate of another value for a
different record key)
Collisions
● occurs when two values/data items in the key field for two records result in the
same hash value (when passed through a hashing algorithm)
71
● Means the storage location identified by the algorithm may already be in use by
another record – two records cannot occupy the same address
● When the number of bits in the mantissa is raised, the precision/accuracy of the
represented number increases – when the bit number is lowered, the accuracy is
reduced
● When the number of bits in the exponent is raised, the range of possible numbers
can be represented is increased – when the bit number is lowered, the range
decreases
Overflow
Underflow
*always refer to the loss in precision and state the number/digits would be truncated
Both are always in two’s complement (There is a binary point following the -1 in
the mantissa)
Mantissa Representation:
Exponent Representation:
73
-128 64 32 16 8 4 2 1
➔ 00000100 = 4
➔ 0.1011010 - point shifts 4 places right
➔ 01011.010 = 1 + 2 + 8 + ¼ = 11.25
1. Convert the number into binary, separating fractions using a binary point
2. Move the binary point left until only one digit comes before it, counting the
amount of places the point moves up (gives you the exponent)
Eg. 4.75
➔ 4.5 = 4 + ½ + ¼ = 0100.11
➔ 0100.11 → 0.10011 - point is shifted 3 places left, hence the exponent is 3
➔ 3 = 0011, so the final number is 010011 x 0011
14.1 Protocols
Purpose of Protocols
Protocol Suites
● The protocols in a stack determine the interconnectivity rules for a layered network
model such as the TCP/IP model
Application
Transport
Internet
Link
● Provides access to all programs that exchange data - interacts directly with the
user
● Used by web browsers or server software
● Enables data transfer to/from the Transport Layer - allows applications to access
services in other TCP/IP layers
● Defines the protocols that an application uses to allow the exchange of data
4. Link Layer (Network Access Interface) – Handles how data is physically sent
● Each layer can only accept input from adjacent layer (next higher or next lower
layer)
● There is an interface between the adjacent layers which the only interaction
between them
● Interactions are carried out by installed software
● User interaction takes place at the application layer of stack through protocols
● Direct access to hardware takes place at the Link layer of the stack
Circuit Switching
Use
Advantages
● No need to reassemble data - frames arrive in same order in which they are sent
● Entire bandwidth is available
● Simpler and fast method of data transfer – data is transmitted with a fixed data
rate and follows the same path (means no data is lost or disordered)
● Fast data transfer rate - suitable for real time transmission
Disadvantages
● No other transmission can occur when circuit is in use - wasted bandwidth (cannot
be shared)
● Not very secure - can be intercepted more easily as all data travels along same
route
● Significant cost and time required to establish dedicated connection between
stations
● Only one route is available - if an error occurs, transmission ends
● Can take time to set up circuit before start of transmission
● Circuit is always there, even it is not being used
Packet Switching
Use
● On digital data networks such as the internet – for sending large files that don’t
need to be live streamed
● When it is necessary to overcome faulty lines through rerouting
● For secure communication and high volume data transmission
● When the entire bandwidth isn’t required
78
Advantages
Disadvantages
Benefits
● Completeness – Missing packets can be easily detected and a resend request sent
to message arrives complete
● Router can detect changes in networks and send data another way, ensuring it
arrives
● Allows simultaneous use of channel by multiple users
● Better security – packets are hashed and send by different routes
Drawbacks
Pipelining
Process
4. After the interrupt has been serviced the registers are restored to their original
status (data is restored from the stack)
Computer Architecture
● One processor executes a single instruction using the same data set – data is
taken from a single source and only a single instruction is performed on it
Virtual Machines
Benefits
● cost saving – new system can be tried on different virtual hardware without the
need to purchase the hardware
● different instruction set architectures can be emulated on a single computer
● the system can crash without affecting the host machine – virtual machine
provides protection to other software
● security – if a virus is downloaded on the emulated system, it only affects the VM
● more than one new computer system can be emulated – allows multiple new
systems to co-exist on a single computer (multiple VMs can be used on the same
computer)
● allows emulation of programs for new CS that are not compatible with the host
operating system – through the use of a guest operating system
● can emulate old software on a newer system using a compatible guest OS
Limitations
● cannot emulate some hardware – new hardware might have been developed after
the VM was
● using the machine means extra code has to be executed and more load is put on
the host computer – is less efficient, increases processing time, uses more RAM
(hence has poorer performance)
● increases the maintenance expenses as both host system and the virtual machine
must be maintained (is also more complex to manage & implement)
● VM may be affected by weaknesses of the host machine
INPUT OUTPUT
X Y sum carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
● Consists of a XOR and AND gate – XOR outputs sum, AND outputs carry
INPUT OUTPUT
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
Sequential Circuits – the output depends on the input value produced from a
previous output value
SR Flip-Flop
85
Problems of SR Flip-Flops
* when assigning values, S and NOT Q will be the same, and R and Q will be the
same (aim is to get the gate inputs to be either 00 or 11)
INPUT OUTPUT
S R Q NOT Q
1 0 0 1
0 1 1 0
2. Using NAND Gates
* when assigning values, the same applies; S and NOT Q will be equal, R and Q
will be equal
(truth table is the same, only difference is when no change or invalid state occurs)
JK Flip-Flops
Advantages
● Uses a clock pulse as an input (to synchronise inputs) and adds additional gates
no change to Q.
Boolean Algebra
Boolean Notation
AND A.B
OR A+B
NOT
NAND
NOR
De Morgan’s Laws
Karnaugh Maps
Advantages
Rules of Simplification
Example 1:
Example 1:
User Interface
Process Management
Multi-tasking
● Allows computers to (appear to) carry out more than one process at a time
Implementation
Interrupt Handling
Process States
● Ready – program is waiting to run on the CPU for allocated amount of time
● Running – program is currently running/being executed on the CPU
● Blocked – program execution is halted, waiting for an event to occur
Process Changes
● Running → Ready
➔ The time slice of the running process expires
➔ There is a process with a higher priority in the ready queue (the running
process gets preempted)
90
➔ An interrupt arrives at the CPU – the process running on the CPU gets
preempted
● Ready → Running
➔ Process is selected by CPU to be executed – the OS scheduler has
allocated this given time to the process
● Running → Blocked
➔ Process needs to carry out an input/output operation or wait for a
resource to be available
➔ Process cannot proceed with execution before a specified event takes
place
● Blocked → Ready
➔ Event or input/output operation has occurred, program can resume
● Allows more than one task to appear to be executed at the same time (enables
multi-tasking)
● Allows high priority jobs to be completed first
● Keeps the CPU busy at all times – this ensures all processes execute efficiently
and reduces wait times for all processes
Scheduling Routines
● Short processes are executed first and followed by longer processes (executed in
ascending order of CPU time required)
● Leads to an increased throughput – as more processes can be executes in a smaller
amount of time
Round Robin
Virtual Memory
● is created temporarily
● secondary storage is used to simulate additional main memory
● extends RAM – means the CPU appears to be able to access more memory space
than the actual RAM available
● only data in use needs to be in main memory – data can be swapped between
RAM and virtual memory as necessary
● when RAM is running low – e.g. when a computer is running many processes at
once
● for more efficient use of RAM – if programs are not immediately needed, they can
be moved from RAM to virtual memory
Segmentation
92
● In segmented memory, the virtual address space is broken into varying sized
blocks (sections) - segment size is calculated by the compiler
● Each segment has a name, size and is numbered - its number is used as an index in
the segment map table
● During execution segments from virtual memory are loaded into physical memory
● Address is specified by the user - contains the segment name and offset value
● An offset value determines the size of the segment
● Segment map table maps virtual addresses to physical addresses (contains
segment number and offset value)
● Slower access times than paging
Page Replacement
● ‘Page Fault’ – an interrupt raised by hardware that occurs when a requested page
is not yet loaded into main memory
● The OS replaces an existing page with a new one – done by swapping pages
between secondary and main/primary memory
● Replaces the page which has not been used for the longest time
● Implemented using a linked list consisting of all pages in memory – most
recently used page is at the front, least recently used at the back
● Uses a circular queue structure – has one single pointer that acts as a head and
tail
● Has an R-flag which can be 0 or 1
➔ If R=0 – the page being pointed to is removed and a new page is inserted
into its place , else a new page is inspected
93
Disk Thrashing
● Problem that occurs when virtual memory is being used (due to frequent transfers
between virtual and physical memory)
➔ As main memory fills up, more pages need to be swapped between virtual
and physical memory
➔ This swapping leads to a very high rate of hard disk access - results in
excessive head movements
➔ Latency increases as hard disk head movements take a relatively long time
➔ Eventually, more time is spent swapping the pages/data than processing it -
program may freeze or not run
Interpreter
Compilation Stages
Lexical Analysis
● converting a sequence of characters into a sequence of tokens
Syntax Analysis
Code generation
● converting an intermediate representation of source code into an executable form
Optimisation
94
Example
● To define a hexadecimal number, the following definitions can be made:
<digit> ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 ;
<letter> ::= A | B | C | D | E | F ;
<hexnum> ::= <digit> | <letter> | <hexnum> <digit> | <hexnum> <letter>
➔ This states that only digits between 0-9 and letters from A-F are valid
➔ Many BNF definitions are recursive, allowing the hexadecimal number to
have multiple digits and letters
● Stack – operands are popped from stack in reverse order to how they were pushed
● Binary Tree – allows both infix and postfix to be evaluated (tree traversal)
Infix vs Postfix
3 2 10 10 2
20 20 60 60 30 30 30 30 60
17. Security
Key Cryptography
Asymmetric Encryption
96
Process
Detecting Alterations
● The message, together with the digital signature, is decrypted using the receiver’s
private key
● The digital signature received is decrypted with the sender’s public key to recover
the digest sent
● The decrypted message received is hashed with the agreed hashing algorithm to
reproduce the message digest received
● The two digests (received and reproduced) are compared – if they are the same,
then the message has not been altered
Symmetric Encryption
● Uses a single key which is used/shared by all to encrypt and decrypt messages
● Simple process that can be carried out quickly - risk of compromise is higher
● Length of keys is shorter (usually 128/256 bits)
Quantum Cryptography
Benefits
97
Limitations
Private Key
Digital Certification
Digital Signatures
Digital Certificate
● To find the optimal shortest and most cost-effective route between two nodes
based on distance/cost/timeArtificial Neural Network
● Part of AI that is meant to simulate the function of a human brain
● Key component of machine learning
● Have self-learning capabilities – enables production of better results as more data
becomes available
● Can solve complex problems humans cannot/find it difficult to
Deep Learning
● uses artificial neural networks which are modelled after the human brain –
structures algorithms in layers – an input layer, output layer and many hidden
layers
● uses large number of hidden layers to progressively extract higher level features
from the raw input (has more success)
● is a specialised form of machine learning
● trained using large amounts of unlabeled data
Reinforcement Learning
Machine Learning
Supervised Learning
Unsupervised Learning
101
19.1 Algorithms
Binary Search
Process
102
Linear Search
● sequentially checks each element of the array/list until the matching element is
found, or the end of the array/list is reached.
● does not require the elements to be sorted.
● will usually do more comparisons of records/iterations against the target (before
finding it) than a binary search
● starts at the beginning of the array/list.
● time to search increases linearly in relation to the number of items in the list for a
linear search and logarithmically for a Binary search
● time to search increases less rapidly for a binary search and time to search
increases more rapidly for a linear search
Big O Notation
● O(log n) is a time complexity that uses logarithmic time – the time taken goes up
linearly as the number of items rises exponentially
Queue
103
Stack
● Uses FILO data structure – data is removed in the reverse order to which is it
received
● Is of varying length
● Data is popped and pushed onto/off a stack from the same end
● Has one movable pointer
Uses of a Stack
● Recursion
● Implementation of ADTs
● Procedure calls
● Interrupt handling
● Evaluating an RPN expression
Array Implementation
19.2 Recursion
● Winding – the statements following a recursive function call are not executed
until the general case has reached base case
● Unwinding – occurs once the base case has been reached
Benefits of Recursion
Drawbacks
● Very repetitive and requires more storage space (demanding use of stack),
meaning stack overflow can occur
● Infinite recursion can occur
Programming Paradigm
Low-Level
Imperative
105
Object Oriented
Properties/Attributes
Methods
● the modules (e.g. functions) in a class implementing the behaviours that act on the
attributes (properties)
Inheritance
● methods and properties contained in one class are reused/made available to a
derived class
Polymorphism
● allows methods to be redefined (take on different behaviours) for derived classes
Encapsulation
● process of putting properties and methods inside a class (ensures sensitive data is
hidden) together as a single unit
Getter
● method that is used to return the value of a property
Setter
● method that is used to update/set the value of a property
Instance
● an occurrence of an object
106
Structure/Contents of a Class
● Attributes/properties and their respective data types - these are variables bound to
the class
● Methods - subroutines that act upon the attributes
● Getters and Setters - methods that fetch/update the attribute contents
● Constructor - used to create instances of objects in the class
● The class is only defined once, but many objects can be created from it - acts as a
template from which objects are created
● Objects are allocated memory space when created
● Classes are not allocated memory space when defined
● A class cannot be manipulated, but objects can (a class is not available in memory)
● Classes are defined, objects are created/declared
● Classes can use inheritance, objects cannot
Declarative
Exception