Computer Science As Level 9618 Theory Notes
Computer Science As Level 9618 Theory Notes
Computer Science As Level 9618 Theory Notes
Data Representation
The two fundamental characteristics of any number system are:
o A base: The number of different digits that a system can use to represent numbers
o Place value: The specific-value of a digit based on its position within a number
Denary - Base 10
12 3
64 16 8 4 2 1
8 2
0 0 0 0 0 0 0 0
For example, 65 in binary is 0100001
1|Page
Denary Prefix Factor Value Binary Prefix Factor Value
kilo- (k) ×103 kibi- (Ki) ×210
mega- (M) ×106 mebi- (Mi) ×220
giga- (G) ×109 gibi- (Gi) ×230
tera- (T) ×1012 tebi- (Ti) ×240
Binary Coded Decimal (BCD)
o Binary representation where each positive denary digit is represented by a sequence of 4 bits (nibble).
o Only certain digits are converted to BCD because particular digits represent a digit greater than 9.
1. 4 = 0100
2. 2 = 0010
3. 9 = 1001
Concatenate the 3 nibbles (4-bit group) in order to produce BCD: 0100 0010 1001
Practical applications
2|Page
o Electronically coding denary numbers
Two’s Complement
o We can represent a negative number in binary by making the most significant bit (MSB) a sign bit, which indicates whether the
1. Find the binary equivalent of the denary number (ignoring the negative sign) | 42 = 101010
2. Add extra 0 bits before the MSB, to format the binary number to 8 bits | 00101010
2. Add 1 | 00101010
3|Page
o Possible digits: 0 to 9 and A to F, where A to F represent denary digits 10 to 15
o Practical applications:
Character Sets:
o A character set generally includes upper & lower case letters, number digits, punctuation marks, and other characters.
o Character sets use different binary representations for each character via character encoding
4|Page
ASCII Extended ASCII Unicode
bits, hence 128 possible characters possible characters using 2 or 4 bytes per character
2 or 4 times more storage space per
Smaller storage space
character
o Definition: Bitmap images are created by assigning a solid color to each pixel using bit patterns.
o Encoding:
Bit patterns are generated by considering each grid row as a series of binary color codes corresponding to each pixel’s color.
o Pixels: The smallest picture element whose color can be accurately represented by binary code.
o File Header: Bitmap images contain a file header with metadata, including image size, number of colors, etc.
Image Resolution
5|Page
Screen Resolution
o Definition: The number of pixels that can be viewed horizontally and vertically on a device’s screen.
Colour depth
o Definition: The number of bits used to represent the colour of a single pixel.
o Calculation: An image with 𝑛n bits has 2𝑛n colours per pixel (e.g., a 16-color bitmap has 4 bits per pixel because 244 = 16)
o Effect: Increasing color depth improves color quality but also increases file size.
o Applications: Scanned images and general computer usage, where small file sizes and easy manipulation are beneficial.
Vector Graphics
6|Page
o Drawing Objects: Mathematically defined constructs (e.g., rectangles, lines, circles).
o Properties: Basic geometric data that determine the shape and appearance of each object.
o Encoding: Data is encoded using mathematical formulas to generate properties for drawing lines and curves to create the image.
Sound
o Analogue vs Digital:
o Sound Signals: Vibrations through a medium, inherently analogue due to infinite detail.
o Conversion:
These samples are encoded as a binary number sequence, providing a digital representation of the sound wave
7|Page
Sampling Rate
o Effect: Increasing the sampling rate improves the accuracy of the digitized sound wave representation but increases file size.
Sampling Resolution
o Effect: Increasing sampling resolution improves the accuracy of digitized sound waves but increases file size.
Bit Rate
Resolution
Compression
Definition: Compression is the process of reducing file size without significant loss in quality, resulting in:
8|Page
o Reduced time needed to search for data.
o Faster transfer of compressed files, using less bandwidth than uncompressed files.
Lossless Compression
o Definition: A type of compression that allows original data to be perfectly reconstructed from a compressed file by utilizing some
form of replacement.
o Examples: Bitmap (.bmp), vector graphic (.svg), .png images, text file compression, database records.
Definition: A form of lossless compression used for compressing text files and bitmap images.
Mechanism: Reduces file size by encoding sequences of adjacent, identical elements (characters in text files and pixels in bitmap
Lossy Compression
9|Page
o Effect: File accuracy/quality is lower than with lossless compression, but file size is significantly reduced (often to about 10% of the
lossless size).
Perceptual Coding: Removes parts of the sound that are less audible or discernible to human hearing, as used in .mp3 compression.
10 | P a g e
Communication
Networks, including the Internet
Networking devices: Interconnected devices that enable fast data transmission within a network.
Networking benefits:
o Resource sharing: Use network-connected output devices like printers or share software within the network.
LAN WAN
A network that connects devices within a small geographical A network that connects devices within a larger geographical
area, often within the same building. area, such as a city, country, or globally.
Only private ownership. Private or public ownership.
Transmission medium: Twisted Pair Cables , Coaxial Cables
Transmission medium: PSTN or Satlink.
or Wi-Fi.
11 | P a g e
LAN WAN
Higher data transfer rate. Lower data transfer rate.
Lesser congestion. Higher congestion.
Client-Server Model
o Server-based network: A dedicated server provides applications (administration of users, security, and resources) for the client
computer to utilize.
o Client-server Applications:
File Sharing: Clients access software and user data files stored on the server.
Proxy server.
The client sends a login request to the server, which processes and grants the request if the user ID & password are recognized.
12 | P a g e
Thin Clients Thick Clients
A client that solely runs on the resources provided by the server and has no An independent client that does not require the
local storage. server to run.
Thick client processes most of the application
Only provides input and receives output; processing is done by the server.
locally.
Can function even if no server is connected (works
Smaller purchase cost: expensive, demanding hardware is not required.
offline).
Improved security: Cannot run unauthorized, harmful software. No lag related to network problems.
Peer-to-Peer network model (P2P)
o Definition: A decentralized network where each connected computer stores data and operates independently as a ‘peer’, acting as
Client-Server Peer-to-Peer
Centralized backup. Lesser initial setup cost.
Files & resources centralized in server: Prevents illegal Lesser network traffic: Each peer can simultaneously receive
resource usage. data from different sources.
Improved security: Files are stored on a central server, which It can work even if a device goes down, but the client-server
would be regularly scanned for malware. model can’t work if the server goes down.
13 | P a g e
Network Topologies
o Bus
A single line (bus) connects all devices with terminators at each end.
Other computers can read data being sent between any two computers.
o Star
14 | P a g e
Consists of a central server (switch) with all other computers connected via dedicated connections.
The server can send packets to different devices simultaneously and bidirectionally.
15 | P a g e
o Mesh
Every device (node) is directly interconnected with each of the other devices (nodes).
Commonly used for wireless networks, such as the Internet, through the mesh connection of routers.
16 | P a g e
o Hybrid
Wired Networks
Benefits Drawbacks
Copper Less expensive and easier to install. Flexible. Easier to make Doesn’t perform well with small charges.
17 | P a g e
Benefits Drawbacks
Cable terminations. Affected by electromagnetism.
Greater bandwidth, improved security, lightweight, easy to install, and
Fiber-Optic Needs expensive optical transmitters
less signal boosting are required; used in long-distance
Cables and receivers.
communications.
Wireless Networks
o Use radio waves (including WiFi), microwaves, and satellites to connect devices to networks without cables.
Benefits Drawbacks
Can travel over large distances with a wide range of Low frequency means less data can be transmitted
Radio
wavelengths. Relatively inexpensive. Used for TV signals at one time. Affected by interference from radio
waves
and mobile phone communications. stations with similar frequencies.
Expensive to build emitting towers. Physical
Microwaves Larger bandwidth allows more data transfer.
obstacles can interfere with signals.
Cost-effective for long-distance communication, used in
Satellites Susceptible to interference. Expensive setup.
satellite phones and radio broadcasts.
Ethernet
o The most common wired medium for data transmission in LANs or WANs.
18 | P a g e
o Typically used in bus topology; data collisions are managed by the CSMA/CD (Carrier Sense Multiple Access with Collision
Detection) method.
o CSMA/CD Process:
If a collision occurs, transmission is aborted, and both devices wait random times before retrying.
Bit Streaming
o Sequence of digital signals (bits) transferred over a communication path at high speeds, requiring a fast broadband connection and
buffers.
The user has to download and display bits at the same time.
Higher quality media requires faster speeds due to larger data frames as well.
19 | P a g e
Real-time streaming needs higher speeds due to simultaneous data requests coming from multiple different users.
Real-time On-demand
Existing digital files are converted to encoded bit-streaming
The event is captured live via a video camera that is connected
format for broadcasting on the internet by uploading to a
to a computer.
dedicated server.
A link for encoded video is placed on the website, and the user
Video signal converted to an encoded streaming video signal.
clicks on the link to view encoded streaming video.
Encoded video signal uploaded from computer to a dedicated The data is streamed to a buffer in the user’s computer, and the
streaming server via cables or high-speed wireless internet buffer stops the video from being paused as the bits are
connection. streamed.
The server then sends live images to all users requesting them As the buffer is emptied, it’s filled again, thus providing
as a real-time video. continuous viewing.
It cannot be paused, fast-forwarded, etc. Can be paused, fast-forwarded, etc.
Cloud Computing
o On-demand provision of computing services over the internet, including infrastructure, and platforms.
20 | P a g e
Public cloud Private Cloud
Access provided by third-party service providers, shared among Owned and maintained by a single organization, providing
multiple users. exclusive access.
Can be managed internally by the organization itself, or
Managed by cloud service providers using large server farms.
outsourced.
Benefits Drawback
Less technical knowledge required, easy to Cannot access the resources/data stored on the cloud if there are bandwidth
implement. issues.
Flexibility to scale with organization’s growth Poor data privacy, since there may be data leakage in the multi-tenant
mindset. architecture (public clouds).
o Protocol: Uses TCP/IP protocol, which uses IP addresses to identify devices connected to the internet.
21 | P a g e
Router in a Network:
o Function: Connects two networks together which operate under the same protocols (for example, IP).
o Connections: Allows internal connections between LANs or external connection from the main LAN to a WAN.
o IP Address Translation: Translates private IP addresses to public IP addresses and vice versa.
LAN-Supporting Hardware:
o Switch:
o Server:
Provides each device (end-system) in the wired LAN with a unique MAC address to uniquely identify it on the network.
22 | P a g e
Wireless Network Interface Card (WNIC):
Provides each end-system of a wireless (WiFi) LAN a unique network address to identify it.
Allows devices to connect to the LAN via WiFi instead of using a cable.
o Cables:
o Bridge:
Connects two LANs which work using the same protocol, which can be two segments of the same network.
Stores network addresses for all devices (end-systems) between the two networks.
o Repeater:
Regenerates the sent data signal over the same network before the signal weakens (attenuation) to prevent it from being corrupted.
Internet-Supporting Hardware:
23 | P a g e
o Modems:
Function: A transmitter uses a modem to convert digital signals (from the transmitting device) to analogue signals sent down the
telephone line. A receiver uses a modem on the other end to convert the analogue signals to digital signals so the receiving device
Channel: Used between two endpoints for the call duration via circuit switching.
Communication: Bi-directional.
o Dedicated Lines:
Function: Able to host websites as well as carry phone calls. Allows continuous, uninterrupted access to the Web.
Wireless networks spread over land areas divided into (hexagonal) cells.
24 | P a g e
Base Stations: Each cell is served by at least one base station (transceiver), which uses a different frequency range compared to
Capacity: Larger capacity is possible since the same frequencies can be used in non-adjacent cells.
Transmission: Radio waves are usually used for transmission. Can be broadcast in all directions over a wide area.
Portable Transceivers: Devices like mobile phones can communicate and access the internet via base stations.
IPv4 IPv6
32-bit address, split into 4
The 128-bit address is divided into eight 16-bit blocks by “:”
blocks by “.”
Each block could have a value
between 0 and 255 (00 to FF Each block can have 4 hex values ranging from 0000 to FFFF.
in hex).
IPv6 can be shortened by removing at least (≥) 2 blocks containing only zeroes. For example:
For example, 255.0.1.255. “2001:0db8:85a3:0000:0000:8a2e:0070:7334” can be shortened to
“2001:0db8:85a3::8a2e:0070:7334"
IPv4 Functionality:
o IP Address Structure:
Network Identifier (netID): Identifies the network to which the host (device) is connected.
25 | P a g e
Host Identifier (hostID): Identifies the host within the network.
Classful Addressing: Used for IPv4, where different bit lengths for identification impose restrictions on available addresses.
o Subnetting:
Structure: IP addresses are broken down into three parts by not changing the netID but partitioning the host ID into a subnet ID
Subnet ID: These bits are used to identify each subnet within the network.
Subnet Masks: Numbers that hide (mask) the netID of a system's IP address and leave only the host part as the machine
identifier, allowing data to be routed within the subnet to the appropriate host.
o Public IP:
o Private IP:
26 | P a g e
Unique within the LAN and can only be accessed within the LAN.
NAT (Network Address Translation): Required for private IP addresses to access the internet directly.
Security: Private IPs are more secure than public IPs since they are not directly accessible on the Internet and are hidden by NAT.
Address Range: The range of IP addresses used for private IP addressing can never be assigned to public IP addresses.
Static Dynamic
IP address never changes. The IP address will change at regular periods.
Static IP addresses are valid when websites need to remember a Dynamic IP address is relatively more secure, hence used
device for a long time, e.g VPNs whitelisting. where data privacy is quite important.
Faster upload/download speeds. Maintaining the cost of the dynamic IP address is a lesser.
27 | P a g e
Unique reference address for the exact location of an internet resource on the WWW
Protocol: Enables the browser to know what protocol is used to access information in the domain.
o Definition: A naming system used for computers or resources having an internet connection.
o Structure: Consists of a hierarchy of DNS servers which have a URL database and their corresponding IP addresses.
28 | P a g e
Hardware: Computers and Their Components
A general-purpose computer system comprises a processor, memory, and I/O functionality.
o Primary Storage: Main memory storing critical program instructions and data.
Embedded systems:
o Miniature computer systems such as microprocessors that are often a part of a more extensive system.
o Each embedded system performs a few specific functions, unlike general-purpose computers.
Benefits Drawbacks
Reliable since there are no moving Difficult to program functions since there is no
parts interface
29 | P a g e
Benefits Drawbacks
Require less power Expensive expert help is needed for the repair
Cheap to mass-produce
Principle Operations of Hardware Devices
o Laser printer:
A laser beam and rotating mirrors are used to draw an image of the page on a photosensitive drum
The image is converted into an electric charge, which attracts charged toner such that it sticks to the image
The electrical charge was removed from the drum, and excess toner was collected
o 3D Printer:
The process starts with a saved digital file that holds the blueprint of the object to be printed
The object is then built by sequentially adding layers of a material (e.g. polymer resin) until the object created
The object is then cured (e.g. resin-made objects are hardened by UV light)
o Microphone:
Incoming sound waves enter the screen and cause vibrations in the diaphragm
30 | P a g e
Vibrations cause the coil to move past a magnetic core
o Speaker:
Takes electrical signals and translates them into physical vibrations to create sound waves
Change in digital audio signal causes current direction to change, which changes field polarity
Electromagnet is either attracted or repelled to a permanent magnet, causing a diaphragm that is attached to the coil to vibrate
The degree of vibration determines the amplitude and frequency of the sound wave produced
o Hard disks have platters whose surfaces are covered with a magnetisable material.
o The surface of platters is divided into concentric tracks & sectors, where data is encoded as magnetic patterns
o When writing, current variation in the head causes magnetic field variation on the disk
o When reading, magnetic field variation from the disk produces current variation in the read head
31 | P a g e
Solid State (Flash) Memory:
o Consist of a grid of columns & rows that has 2 transistors at each intersection
o Two transistors:
o Floating Gate: stores electrons, and the presence or absence of charge (electrons) represents either 1 or 0
o Tracks have sequences of amorphous and crystalline states on the metallic layer
o When reading, the reflected light from the different states on the track is encoded as bit patterns
o When writing, the laser changes surface to crystalline and amorphous states along the track, corresponding to 1s or 0s.
Touchscreen:
32 | P a g e
o Considered as both an input & output device
Resistive Capacitive
Consists of two charged plates Made from materials that store electric charge
Pressure causes plates to touch, completing the circuit When touched, the charge is transferred to the finger
Point of contact registered with coordinates used to calculate the
position
Virtual (Reality) Headset:
o Virtual headsets consist of 2 lenses, (an LCD) display, a circuit board with sensors, a cover and foam padding
o The user can ‘move’ in the virtual environment by moving their head or using controllers
Buffers:
o A queue that temporarily stores data to balance input/output speed of data, while the cache is the short-term memory storage that
RAM ROM
Volatile memory: loses content when power is turned Non-volatile memory: does not lose content when power is turned
33 | P a g e
RAM ROM
off off
It can be read and altered It can only be read
Used to store currently executing program Used for storing OS kernel and boot-up instructions
Types of RAM - Static RAM vs. Dynamic RAM
SRAM DRAM
Doesn’t need to refresh; hence, it uses less power and faster Has to be refreshed; it has slower access times and needs
access time higher power
Only a single transistor & capacitor, hence less expensive to
More complex circuitry, hence more expensive
purchase
Each bit is stored in a flip-flop Each bit is stored as a charge
Has lower data density Has higher data density
Used in cache memory Used in main memory
Types of ROM – PROM vs. EPROM vs. EEPROM
34 | P a g e
o Monitoring System:
No changes were made to the environment by the system, and hence, no feedback
o Control System:
Event-driven system: the controller alters the system's state in response to some event
Time-driven system, where the controller takes action at a specific point in time
Sensor that measures an (analogue) property and transmits it to a processing unit, generally as an electrical or optical signal
Actuators that switch on/off heavy appliances (e.g. heater to heat/fan to cool)
o Feedback Systems:
Enabling the system output to affect subsequent system inputs may cause a change in the actions taken by the system
35 | P a g e
This enables the system to adjust conditions in a continuous process automatically
AND gate: If both inputs are high, the output is high (A•B)
A B Output
0 0 0
0 1 0
1 0 0
1 1 1
\n
36 | P a g e
A B Output
0 0 0
0 1 1
1 0 1
1 1 1
OR gate: If either input is high, the output is high (A+B)
A Output
1 0
37 | P a g e
A Output
0 1
A B Output
0 0 1
0 1 1
1 0 1
1 1 0
38 | P a g e
NAND gate: (A•B) \n
A B Output
0 0 1
0 1 0
1 0 0
1 1 0
39 | P a g e
A B Output
0 0 0
0 1 1
1 0 1
1 1 0
Processor Fundamentals
Central Processing Unit (CPU) Architecture
Von Neumann model
o Von Neumann realized data & programs are indistinguishable and can, therefore, use the same memory.
40 | P a g e
o It follows a linear sequence of fetch–decode–execute operations for the set of instructions, i.e. the program.
Registers: smallest unit of storage of microprocessor; allows fast data transfer between other registers
o Used to temporarily store data values which have been read from memory or some processed result
Program Counter (PC): holds the address of the next instruction to be fetched
Memory Data Register (MDR): holds data value fetched from memory
Memory Address Register (MAR): Holds the address of the memory cell of the program which is to be accessed
Accumulator (ACC): holds all values that are processed by arithmetic & logical operations.
41 | P a g e
Current Instruction Register (CIR): Once program instruction is fetched, it is stored in CIR and allows the processor to decode &
execute it
Status Register: holds results of comparisons to decide later for action, intermediate and erroneous results of arithmetic performed
o Arithmetic and Logic Unit (ALU): part of the processor that processes instructions which require some form of arithmetic or logical
operation
o Control Unit (CU): part of the CPU that fetches instructions from memory, decodes them & synchronizes operations before sending
signals to the computer’s memory, ALU and I/O devices to direct how to respond to instructions sent to the processor
o Immediate Access Store (IAS): memory unit that the processor can directly access
o System Clock: a timing device connected to a processor that synchronises all components.
Buses
o set of parallel wires that allow the transfer of data between components in a computer system
Data bus: bidirectional bus that carries data instructions between processor, memory, and I/O devices.
Address bus: unidirectional bus that carries the address of the main memory location or input/output device about to be used, from
o Control bus
42 | P a g e
Bidirectional
used to transmit control signals from the control unit to ensure access/use of data & address buses by components of the system
o Clock Speed
number of pulses the clock sends out in a given time interval, which determines the number of cycles (processes) the CPU
If the clock speed is increased, then the execution time for instructions decreases. Hence, more cycles per unit time, which
increases performance.
However, there is a limit on clock speed since the heat generated by higher clock speeds cannot be removed fast enough, which
leads to overheating.
o Bus Width
Increasing bus width increases the number of bits transferred simultaneously, increasing processing speed and performance.
43 | P a g e
o Cache Memory
Commonly used instructions are stored in the cache memory area of the CPU.
If the cache memory size is increased, more commonly executed instructions can be stored, and the need for the CPU to wait for
instructions to be loaded reduces. Hence, the CPU executes more cycles per unit of time, thus improving performance.
o Number of Cores
Most CPU chips are multi-core — have more than one core (essentially a processor)
Each core simultaneously processes different instructions through multithreading, improving computer performance.
Ports
o Hardware which provides a physical interface between a device with CPU and a peripheral device
o Peripheral (I/O) devices cannot be directly connected to the CPU, hence connected through ports.
o Universal Serial Bus (USB): Can connect both input and output devices to the processor through a USB port.
Can only connect output devices (e.g. LCD) to the processor through a HDMI port
HDMI cables transmit high-bandwidth and high-resolution video & audio streams through HDMI ports
Can only connect output devices (e.g. second monitor/display) to the processor through a VGA port
44 | P a g e
VGA ports allow only the transmission of video streams but not audio components
o Fetch stage
PC is incremented
o Decode stage: The opcode and operand parts of instruction are identified
o Execute stage: Instructions executed by the control unit sending control signals
MAR ← [PC]
PC ← [PC] + 1
MDR ← [[MAR]]
CIR ← [MDR]
Decode
45 | P a g e
Execute
Return to start
Double square brackets: CPU is getting value stored at the address in the register
Interrupts
o The processor checks the interrupt register for interrupt at the end of the F-E cycle for the current instruction
o If the interrupt flag is set in the interrupt register, the interrupt source is detected
All contents of registers of the running process are saved on the stack
46 | P a g e
Once ISR is completed, the processor restores the registers’ contents from the stack, and the interrupted program continues its
execution.
Assembly Language
Assembly language: low-level programming language with instructions made up of an op code and an operand
Machine code: code written in binary that uses the processor’s basic machine operations
Relationship between machine and assembly language: every assembly language instruction (source code) translates into exactly
Symbolic addressing
Assembler
o Software that changes assembly language into machine code for the processor to understand
47 | P a g e
o The assembler replaces all mnemonics and labels with their respective binary values (that are predefined before by the assembler
software)
o Assembler converts mnemonic source code into machine code in one sweep of program
Symbol table created to enter symbolic addresses and labels into specific addresses
48 | P a g e
Op Code Operand Explanation
LDM #n Immediate: Load n into ACC
LDD Direct: load contents at address into the ACC
LDI Indirect: load contents of address at given address into ACC
LDX Indexed: load contents of given address + IR into ACC
Data Movement
STO Store contents of ACC into address
Arithmetic
Operations
ADD Add contents of register to ACC
INC Add 1 to contents of the register
Comparing
CMP Compare contents of ACC with that of given address
CMP #n Compare contents of ACC with n
Conditional Jumps
JPE Jump to address if compare TRUE
JPN Jump to address if compare FALSE
Unconditional Jumps
JMP Jump to given address
49 | P a g e
Op Code Operand Explanation
I/O Data
IN Input any character and store ASCII value in ACC
OUT Output character whose ASCII value is stored in ACC
Ending
END Return Control to operating system
#denotes immediate addressing
B denotes a binary number, e.g. B01001010 & denotes a hexadecimal number, e.g. &4A
Modes of Addressing
o Indirect Addressing: The address to be used is at given address. Load contents of this second address to ACC
o Relative addressing: next instruction to be carried out is an offset number of locations away, relative to address of current
o Conditional jump: has a condition that will be checked (like using an IF statements)
o Unconditional jump: no condition to be followed, simply jump to the next instruction as specified
50 | P a g e
Bit Manipulation
Binary numbers can be multiplied or divided by shifting
Arithmetic shift: Used to carry out multiplication and division of signed integers represented by bits in the accumulator by ensuring
that the sign-bit (usually the MSB) is the same after the shift.
Cyclic shift: the bit that is removed from one end by the shift is added to the other end.
51 | P a g e
Bit Masking
Masking: an operation that defines which bits you want to keep and which bits you want to clear.
Matching: an operation that allows the accumulator to compare the value it contains to the given value in order to change the state
Mask the content of the register with a mask pattern which has 0 in the ‘mask out’ positions and 1 in the ‘retain’ positions.
Set the result with the match pattern by using the AND command with a direct address.
Mask the content of the register with a mask pattern which has 0 in the ‘mask out’ positions and 1 in the ‘retain’ positions.
Compare the result with the match pattern by using the CMP command or by “Checking the pattern”.
52 | P a g e
o Checking the pattern
The final ‘non-zero’ result confirms the patterns are not the same else vice versa.
53 | P a g e
System Software
Operating System
Need for OS
o OS hardware is unusable without an OS, as the OS acts as an interface since it controls communication between user and
hardware
Memory protection to ensure 2 programs do not try to use same memory space
Paging
54 | P a g e
o File Management
o Security Management
o Process Management
55 | P a g e
E.g. via Round-robin method
Utility Software
o Disk Formatter
Performs formatting, process where computer ‘draws lines’ on disk surface to split it into small areas
o Virus checker
o Defragmentation Software
Files can be big so have to be stored in multiple sectors, which can result in fragmentation (contents of file scattered across >2
non-contiguous sectors)
Fragmentation slows down disk access and thus the performance of the entire computer.
Defragmenting software works by physically reorganizing disk contents (files) such that they are stored in contiguous sectors.
This defragmentation reduces number of movements of the read/write heads require to access the disk contents, hence increasing
computer performance
56 | P a g e
The defragmentation also creates larger contiguous free space regions
Gets size for each folder and files, and generates a graphical chart showing disk usage distribution according to folders or other
o File Compression
Causes improvements in the computer’s performance by reducing the data that needs to be stored
o Back-up Software
Makes copy of files on another storage medium in the event of a hard drive failure, user error, disaster or accident.
Program Libraries
o Pre-written code that can be linked to a software under development without any amendments
57 | P a g e
o Can perform common or complex tasks
o Benefits:
Library file is a complex algorithm which the user does not need to understand to use it
o Code saved separately from the main .EXE file, reducing the .EXE file’s size
o DDL file can be made available to several applications simultaneously, thus reducing strain on memory
o DLL files act as modules in more complex programs, making it easier to install and run updates
Language Translators
Assembler
o Software that translates assembly language statements into machine code (binary) for execution
58 | P a g e
o Process simple because assembly language has a one-to-one relationship with machine code.
Compiler Interpreter
Translates a high-level language program to machine
Translates and executes a high-level language program, line-by-line.
code.
Creates a .exe file which can be easily distributed. No .exe file created.
Once compiled, .exe file does not need to be compiled
Execution very slow – translated each time program run.
again, resulting in faster execution.
Reports all errors at the end of compilation: difficult to Debugging easier/faster, since it stops translating when it reaches
locate errors∴ development process long. an error. This allows real time error correction.
Only be produced when all errors are fixed. Can run program any time, even before code finished.
Used when development is completed. Used during development.
Two-step translation
o Java and some other high level language programs may require two-step translation, i.e., they will be partially compiled and
partially interpreted
o Bytecode finally interpreted by the Java Virtual Machine to produce machine code
o Coding
59 | P a g e
Context-sensitive prompts: Displays choice of keywords and available identifiers appropriate at current insertion point and provides
Dynamic syntax checks: Automatic checking and highlighting of syntax errors, as soon as line typed
o Presentation
Expand and Collapse code blocks: Saves excessive scrolling if collapsed, and easy to see global variable declarations and main
o Debugging
Single stepping: Executes program line-by-line to see the effect of each statement on variables
Breakpoints: Pauses program at a specific line to ensure program operates correctly up to that line
60 | P a g e
Security, Privacy and Data Integrity
Data Security
Data Security: ensuring data is protected against loss and unauthorized access.
Data Integrity: making sure that data is valid and does not corrupt after transmission
Data Privacy: ability to determine what data is shared with a third party
o Malware
Virus: Software that replicates itself by inserting a copy of itself into another piece of software, which may cause the computer to
61 | P a g e
Spyware: software that gathers information about users' online and offline activity, including accessed sites, applications, and
downloaded files.
Risk restriction: Ensure anti-virus and anti-spyware software is installed, regularly updated and run.
o Hacking
Hackers can obtain user’s confidential data which can cause identity theft
o Phishing
Attempt through emails to obtain user’s confidential data which can cause identity theft
Risk restriction: Ignore suspicious mails and ensure firewall criteria include SPAM filters, blacklist, etc.
o Pharming
Redirects user to a fake website that appears legitimate to gain confidential data
Risk restriction: use a reliable ISP; check that links are genuine and ensure https is present in the URL
62 | P a g e
Usernames & passwords to deny access to unauthorized users
User-assigned privilege, which accesses to only the user’s workplace, preventing the user to have admin rights.
Can assign privileges to files so users with low privileges do not have access.
o Firewalls
Hardware or software that filters information travelling between the computer system and the internet
(software) firewall can make decisions about what to allow and block by detecting illegal attempts by specific software to connect to
the internet
o Authentication
o Anti-virus software
o Encryption:
63 | P a g e
Conversion of data to code by encoding it
Encryption
Access Rights to data (authorization): different users assigned different authorization levels which prevent them from accessing all
o Data Backup
An exact copy of an original piece of data in case the original is lost or corrupted
o Disk-mirroring strategy
Real-time strategy that writes data to two or more disks at the same time.
Data Integrity
Data validation and data verification help protect the integrity of data by checking whether the data entered is sensible and
accurate, respectively.
64 | P a g e
Data Validation: checks if data entered is valid, but not its accuracy
o Limit check: checks whether a value entered is within acceptable minimum and maximum values.
o Check digit: A digit is used as the answer to an arithmetic operation of other digits in data. If not matched, then data entered
incorrectly
Data Verification: checks data entered is accurate during data entry and data transfer
o Visual Check: Person manually compares original data with that entered to check if correct
65 | P a g e
o Errors may occur when data moved in system.
o Parity Check
E.g. two communicating devices decide there will always be an odd number of 1s. A byte is received that has even number of 1s so
error occurred and receiving device would ask for it to be sent again
o Checksum Check
Data sent from one place to another as block of bytes rather than individual bytes
Any bits lost at most-significant end as carry ignored so answer is an 8-bit number
If two bytes different, error occurred therefore block of bytes must be sent again
66 | P a g e
Ethics and Ownership
Ethics: a system of moral principles that guide behaviour based on philosophical views
Computer Ethics
o Regulate how computing professionals should make decisions regarding professional & social conduct.
o A computing professional can be ethically guided by joining a professional, ethical body such as the BCS and IEEE, which have
codes of conduct.
Ownership
o Data ownership: having legal rights and complete control over a single piece or set of data elements.
o Copyright gives the creators of some types of media rights to control how they're used and distributed.
o Competitors can steal programming ideas and methods; software can easily be copied and bootlegged (sold illegally); hence,
legislation is needed to protect the ownership, usage, and copyright of data.
Software Licencing
o Free Software Foundation:
A license gives users freedom to run, copy, distribute, study, change, and improve the software.
Condition: any redistributed version of software must be distributed with original terms of free use, modification, and distribution
(aka copyleft)
o The Open Source Initiative:
The source code of open-source software is readily available to users under copyright; it does enable users to re-distribute the
software.
The concept of an open-source program relies on the fact that users can review source code to eliminate bugs in it
o Shareware:
Demonstration software that is distributed for free but for a specific evaluation period only
Distributed on a trial basis and with an understanding that sometime later, a user may be interested in paying for it
Used for marketing purposes
o Commercial: Requires payment before it can be used, but includes all program's features, with no restrictions
67 | P a g e
Artificial Intelligence (AI): the ability of a computer to perform tasks in such a way that is conventionally associated with human
intelligence:
o AI can learn from past mistakes
they adapt to stop the same problem from occurring again
they learn to predict what might happen & raise alert
o AI can learn to work more efficiently
when an action slows the system down, it can prevent this from happening again
when an action increases the speed of the system, it can repeat this when necessary to improve efficiency
AI Applications
o Developing autonomous mechanical products
o Machine learning through data sets
AI Impacts
o Social
Replacement of manual labour with automation could lead to massive unemployment.
However, it could lead to increased leisure time.
o Economic: Due to increased innovation and efficiency with automation provided by AI, there’d be lower manufacturing costs in
general
o Environmental: Detrimental impact on the environment due to robot manufacture with limited resources and its waste disposal
68 | P a g e
Database and Data Modelling
File Based System
Data stored in discrete files, stored on computer, and can be accessed, altered or removed by the user
DBMS: Software programs that allow databases to be defined, constructed and manipulated
Features of a DBMS:
Data management: data stored in relational databases - tables stored in secondary storage
69 | P a g e
Data dictionary contains:
Data modeling: analysis of data objects used in database, identifying relationships among them
Logical schema: overall view of entire database, includes: entities, attributes and relationships
Data integrity: entire block copied to user’s area when being changed, saved back when done
Data security: handles password allocation and verification, backups database automatically, controls what certain user’s view by
Lock all records in the table being modified – one user changing a table, others can only read table
Lock record currently being edited – as someone changes something, others can only read record
User specifies no locks – software warns user of simultaneous change, resolve manually
Deadlock: 2 locks at the same time, DBMS must recognize, 1 user must abort task
Tools in a DBMS:
70 | P a g e
Developer interface: allows creating and manipulating database in SQL rather than graphically
Query processor: handles high-level queries. It parses, validates, optimizes, and compiles or interprets a query which results in
Table: contains a group of related entities in rows and columns called an entity set
Primary key: attribute or combination of them that uniquely define each tuple in relation
Indexing: creating a secondary key on an attribute to provide fast access when searching on that attribute; indexing data must be
71 | P a g e
Relational Design of a System
Normalization
1st Normal Form (1NF): contains no repeating attribute or groups of attributes. Intersection of each tuple and attribute contains
72 | P a g e
2nd Normal Form (2NF): it is in 1NF and every non-primary key attribute is fully dependent on the primary; all the incomplete
73 | P a g e
3rd Normal Form (3NF): it is in 1NF and 2NF and all non-key elements are fully dependent on the primary key. No inter-
MANY-TO-MANY functions cannot be directly normalized to 3NF, must use a 2 step process e.g.
becomes:
o written in SQL
Creating a database:
Creating a table:
Changing a table:
74 | P a g e
Adding a primary key:
ADD <field-name>:<data-type>
Example:
Queries:
Creating a query:
SELECT <field-name>
75 | P a g e
FROM <table-name>
WHERE <search-condition>
SQL Operators:
= Equals to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
<> Not equal to
IS NULL Check for null values
Sort into ascending order:
ORDER BY <field-name>
GROUP BY <field-name>
INNER JOIN
Data Maintenance:
76 | P a g e
INSERT INTO <table-name>(field1, field2, field3)
Deleting a record:
WHERE <condition>
UPDATE <table-name>
WHERE <condition>
77 | P a g e
PRACTICAL
Algorithm Design & Problem-Solving
Abstraction: filtering out and concentrating on the relevant information in a problem; allowing a programmer to deal with
complexity
Decomposition: breaking down problems into sub-problems in order to understand a process more clearly; program modules,
procedures and functions all help the programmer to break down large problems
Identifier Table
Identifier: name given to a variable in order to call it
78 | P a g e
Rules for naming identifiers:
o Must be unique
o Consist only of a mixture of letters and digits and the underscore character ‘_’
Sequence: programming statements are executed consequently, as they appear in the program
79 | P a g e
Selection: control structure in which there is a test to decide if certain instructions are executed
As for selecting what loop to use, it is best to use FOR loops when you know the number of iterations required, and a WHILE or
Stepwise Refinement
Process of developing a modular design by splitting a problem into smaller sub-tasks, which themselves are repeatedly split into
even smaller sub-tasks until each is just one element of the final program.
80 | P a g e
Program Modules
This refers to a modular program design
Subroutines: self-contained section of code, performing a specific task; part of the main program
Procedures: performs a specific task, no value returned to part of code where called
Functions: performs a specific task, returns a value to part of code where called
Logic Statements
Operato
Meaning
r
< Less than
<= Less than/equal
> Greater than
>= Greater/equal
= Equal to
<> Not equal to
81 | P a g e
Data Representation
Data Types
Integer:
Some languages differentiate short/long integers (more bytes used to store long integers)
Real:
Referred to as singles and doubles depending upon number of bytes used to store
Character:
String:
82 | P a g e
Each character stored in two bytes using Unicode
Boolean:
Date:
Equates to number of seconds elapsed since 1st January 1970 00:00:00 UTC, excluding leap seconds.
Array:
File:
83 | P a g e
Object that stores data, information, settings or commands
ASCII Code
Uses 1 byte to store a character
ASCII values can take many forms: numbers, letters (capitals and lower case are separate), punctuation, non-printing commands
Unicode
ASCII allows few number of characters; good for English
o UTF-8: compatible with ASCII, variable-width encoding can expand to 16, 24, 32, 40, 48
84 | P a g e
Arrays
1-Dimensional (1D) Array: declared using a single index, can be represented as a list
2-Dimensional (2D) Array: declared using two indices, can be represented as a table
85 | P a g e
Pseudocode:
Python:
o Printing column: use for loop and keep adding 1 to the row and keep column same
86 | P a g e
Bubble Sort
Another FOR loop is set up next in order to search through the array
An IF is used to see if the first number of the array is greater than the second. If true:
87 | P a g e
o Stored variable assigned to second number
The second FOR loop is count based thus will stop after a specific number of times
Linear Search
88 | P a g e
File Handling
Files are needed to import contents (from a file) saved in secondary memory into the program, or to save the output of a program
(in a file) into secondary memory, so that it is available for future use
Pseudocode:
Python:
Mode Description
r Opens file for reading only. Pointer placed at the beginning of the file.
89 | P a g e
Mode Description
Opens a file for writing only. Overwrites file if file exists or creates new file if it
w
doesn’t
a Opens a file for appending. Pointer at end of file if it exists or creates a new file if not
Reading a file:
Writing to a file:
Stack: an ordered collection of items where the addition of new items and removal of existing items always takes place at the same
end.
Queue: a linear structure which follows the First In First Out (FIFO) mechanism. Items are added at one end (called the rear) and
90 | P a g e
Linked List: a linear collection of data elements whose order is not given by physical placements in memory (non-contiguous).
Programming
Programming is a transferable skill
Transferable skill: skills developed in one situation which can be transferred to another situation.
Variables
Declaring a variable:
o Python: no need to declare however must write above as a comment (‘’’python #...‘’’)
Assigning variables:
Selections
“IF” Statement
91 | P a g e
o Pseudocode: IF…THEN…ELSE…ENDIF
“CASE” Statement
Iterations
Count-controlled Loop
FOR <identifier> ← <val1> TO <val2> STEP <val3>
<statement(s)>
ENDFOR
Pre-condition Loop
WHILE <condition> while expression:
<statement(s)> statement(s)
92 | P a g e
Count-controlled Loop
ENDWHILE
Built-in Functions
String/character manipulation:
Converting:
93 | P a g e
Procedure
Procedure: subroutine that performs a specific task without returning a value
PROCEDURE <statement(s)>ENDPROCEDUR
def identifier():statement(s)
E
When a procedure has a parameter, the function can either pass it by either reference or value
Pass by value: data copied into procedure so variable not changed outside procedure
<statement(s)>
ENDPROCEDURE
def identifier(param):
statement(s)
Pass by reference: link to variable provided so variable changed after going through procedure (not in Python)
<statement(s)>
ENDPROCEDURE
Calling a procedure:
CALL () Identifier()
94 | P a g e
Function
Function: subroutine that performs a specific task and returns a value
Functions are best used to avoid having repeating blocks of code in a program, as well as increasing the reusability of code in a
large program.
<statement(s)>
ENDFUNCTION
def identifier(param):
statement(s)
return expression
95 | P a g e
Software Development
Program Development Cycle
Analyze problem: define problem, record program specifications and recognize inputs, process, output & UI
Design program: develop logic plan, write algorithm in e.g. pseudocode or flowchart and test solution
Code program: translate algorithm into high level language with comments/remarks and produce user interface with executable
processes
Test and debug program: test program using test data, find and correct any errors and ensure results are correct
Formalize solution: review program code, revise internal documentation and create end-user documentation
Maintain program: provide education and support to end-user, correct any bugs and modify if user requests
96 | P a g e
There are three different development life cycles:
Waterfall model: a classical model, used to create a system with a linear approach, from one stage to another
Iterative model: a initial representation starts with a small subset, which becomes more complex over time until the system is
complete
Rapid Application Development (RAD) model: a prototyping model, with no (or less) specific planning put into it. More emphasis
Coding:
The IDE executes the code & initial error detection carried out by compiler/interpreter doing the following:
o Syntax/Logic Error: before program is run, an error message warns the user about this
97 | P a g e
o Runtime Error: run of the program ends in an error
Debugging:
Single stepping: traces through each line of code and steps into procedures. Allows you to view the effect of each statement on
variables
Breakpoints: set within code; program stops temporarily to check that it is operating correctly up to that point
Variable dumps (report window): at specific parts of program, variable values shown for comparison
Structure Charts
Purpose: used in structured programming to arrange program modules, each module represented by a box
Tree structure visualizes relationships between modules, showing data transfer between modules using arrows.
Example of a top-down design where a problem (program) is broken into its components.
Rules:
Data couple: Data being passed from module to module that needs to be processed
98 | P a g e
Flag: Check data sent to start or stop a process. E.g. check if data sent in the correct format
Selection: Condition will be checked and depending on the result, different modules will be executed
Example:
99 | P a g e
Types of Errors
Syntax errors:
100 | P a g e
Examples:
Run-time errors:
Source code compiles to machine code but fails upon execution (red lines show up in Python)
When the program keeps running and you have to kill it manually
Examples:
o Division by 0
o Infinite loop – will not produce error message, program will just not stop until forced to
Logic errors:
Examples:
101 | P a g e
o Misuse of logic operators
Corrective Maintenance
Corrective Maintenance is correcting identified errors
White-Box testing: making sample data and running it through a trace table
Trace table: technique used to test algorithms; make sure that no logical errors occur e.g.
102 | P a g e
Adaptive Maintenance
Making amendments to:
Testing Strategies
Black box testing:
Use test data for which results already calculated & compare result from program with expected results
Testing only considers input and output and the code is viewed as being in a ‘black box’
Stub testing:
Stubs are computer programs that act as temporary replacement for a called module and give the same output as the actual
product or software.
103 | P a g e
Important when code is not completed however must be tested so modules are replaced by stubs
The value of a variable is manually followed to check whether it is used and updated as expected
Walkthrough testing:
A test where the code is reviewed carefully by the developer’s peers, managers, team members, etc.
Integration testing:
Taking modules that have been tested on individually and testing on them combined together
This method allows all the code snippets to integrate with each other, making the program work.
Alpha testing:
This is the testing done on software ‘in-house’, meaning it is done by the developers
Beta testing:
This is the testing done on the software by beta users, who use the program and report any problems back to the developer.
104 | P a g e
Basically another term for ‘second round of testing’
Acceptance testing:
A test carried out by the intended users of the system: the people who requested the software.
The acceptance criteria should completely be satisfied for the program to be released.
105 | P a g e
106 | P a g e