AS Notes
AS Notes
Information Representation
Data Representation
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
128 64 32 16 8 4 2 1
0 0 0 0 0 0 0 0
o Only certain digits are converted to BCD because particular digits represent a digit
greater than 9.
1. 4 = 0100
2. 2 = 0010
Concatenate the 3 nibbles (4-bit group) in order to produce BCD: 0100 0010
1001
Practical applications
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 number is positive or negative.
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
1. Add 1 | 00101010
o Practical applications:
Character Sets:
o A character set generally includes upper & lower case letters, number digits,
punctuation marks, and other characters.
Each character encoding takes ASCII extended to 8 bits, It has an excellent range of
up 7 bits, hence 128 possible hence 256 possible characters, using 2 or 4 bytes
characters characters per character
Bitmap Images
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
Screen Resolution
o Definition: The number of pixels that can be viewed horizontally and vertically on a
device’s screen.
o Definition: The number of bits used to represent the colour of a single pixel.
o Calculation: An image with nn bits has 2nn 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
o Properties: Basic geometric data that determine the shape and appearance of each
object.
Sound
o Analogue vs Digital:
o Sound Signals: Vibrations through a medium, inherently analogue due to infinite detail.
o Conversion:
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
Compression
Definition: Compression is the process of reducing file size without significant loss in quality,
resulting in:
o Faster transfer of compressed files, using less bandwidth than uncompressed files.
Lossless Compression
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.
Lossy Compression
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.
Networking devices: Interconnected devices that enable fast data transmission within a
network.
Networking benefits:
LAN WAN
A network that connects devices within a A network that connects devices within a larger
small geographical area, often within the geographical area, such as a city, country, or
same building. globally.
Client-Server Model
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.
A client that solely runs on the resources provided by An independent client that does not
the server and has no local storage. require the server to run.
Only provides input and receives output; processing is Thick client processes most of the
done by the server. application locally.
Smaller purchase cost: expensive, demanding hardware Can function even if no server is
is not required. connected (works offline).
o Definition: A decentralized network where each connected computer stores data and
operates independently as a ‘peer’, acting as both a client and a server.
Client-Server Peer-to-Peer
Improved security: Files are stored on a It can work even if a device goes down, but the
central server, which would be regularly client-server model can’t work if the server goes
scanned for malware. down.
Network Topologies
o Bus
Other computers can read data being sent between any two computers.
o Star
Consists of a central server (switch) with all other computers connected via
dedicated connections.
o Mesh
Commonly used for wireless networks, such as the Internet, through the mesh
connection of routers.
o Hybrid
Wired Networks
o Benefits Drawbacks
Wireless Networks
o Use radio waves (including WiFi), microwaves, and satellites to connect devices to
networks without cables.
o Benefits Drawbacks
Can travel over large distances with a Low frequency means less data can
Radio wide range of wavelengths. Relatively be transmitted at one time. Affected
waves inexpensive. Used for TV signals and by interference from radio stations
mobile phone communications. with similar frequencies.
Ethernet
o The most common wired medium for data transmission in LANs or WANs.
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:
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.
Real-time On-demand
Encoded video signal uploaded from computer The data is streamed to a buffer in the user’s
to a dedicated streaming server via cables or computer, and the buffer stops the video from
high-speed wireless internet connection. being paused as the bits are streamed.
The server then sends live images to all users As the buffer is emptied, it’s filled again, thus
requesting them as a real-time video. providing continuous viewing.
Cloud Computing
Managed by cloud service providers using large Can be managed internally by the organization
server farms. itself, or outsourced.
Benefits Drawback
Less technical knowledge required, Cannot access the resources/data stored on the cloud if
easy to implement. there are bandwidth issues.
Flexibility to scale with Poor data privacy, since there may be data leakage in the
organization’s growth mindset. multi-tenant architecture (public clouds).
o Protocol: Uses TCP/IP protocol, which uses IP addresses to identify devices connected to
the internet.
Router in a Network:
o Function: Connects two networks together which operate under the same protocols (for
example, IP).
LAN-Supporting Hardware:
o Switch:
Provides each device (end-system) in the wired LAN with a unique MAC address
to uniquely identify it on the network.
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:
o Modems:
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.
Base Stations: Each cell is served by at least one base station (transceiver),
which uses a different frequency range compared to adjacent cells to transmit
data.
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
IPv4 Functionality:
o IP Address Structure:
Network Identifier (netID): Identifies the network to which the host (device) is
connected.
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 and host ID.
Subnet ID: These bits are used to identify each subnet within the
network.
o Public IP:
o Private IP:
Unique within the LAN and can only be accessed within the LAN.
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
Static IP addresses are valid when websites need to Dynamic IP address is relatively more
remember a device for a long time, e.g VPNs secure, hence used where data privacy is
whitelisting. quite important.
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 Structure: Consists of a hierarchy of DNS servers which have a URL database and their
corresponding IP addresses.
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.
Benefits Drawbacks
Reliable since there are no moving Difficult to program functions since there is no
parts interface
Require less power Expensive expert help is needed for the repair
Cheap to mass-produce
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 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
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
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
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:
Resistive Capacitive
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 stores frequently used data.
Volatile memory: loses content when Non-volatile memory: does not lose content when
power is turned off power is turned off
Used to store currently executing program Used for storing OS kernel and boot-up instructions
SRAM DRAM
Doesn’t need to refresh; hence, it uses less Has to be refreshed; it has slower access times
power and faster access time and needs higher power
Electrically Erasable
Programmable ROM Erasable Programmable ROM
Programmable ROM
Data cannot be erased or Chip has to be removed for Can update data without
deleted reprogramming removing the chip.
o Monitoring System:
o Control System:
Time-driven system, where the controller takes action at a specific point in time
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
Logic Gates: use one or more inputs and produce a single logical output
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
A B Output
0 0 0
0 1 1
1 0 1
1 1 1
A Output
1 0
0 1
0 0 1
0 1 1
1 0 1
1 1 0
A B Output
0 0 1
0 1 0
1 0 0
1 1 0
A B Output
0 0 0
0 1 1
1 0 1
1 1 0
o Von Neumann realized data & programs are indistinguishable and can, therefore, use
the same memory.
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.
o Arithmetic and Logic Unit (ALU): part of the processor that processes instructions which
require some form of arithmetic or logical operation
o Immediate Access Store (IAS): memory unit that the processor can directly access
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 processor to memory
address register (MAR)
o Control bus
Bidirectional
used to transmit control signals from the control unit to ensure access/use of
data & address buses by components of the system does not lead to conflict
o Clock Speed
number of pulses the clock sends out in a given time interval, which determines
the number of cycles (processes) the CPU executes in a given time interval
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
o Cache Memory
Commonly used instructions are stored in the cache memory area of the CPU.
o Number of Cores
Most CPU chips are multi-core — have more than one core (essentially a
processor)
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
Can only connect output devices (e.g. second monitor/display) to the processor
through a VGA port
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
CIR ← [MDR]
Decode
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
Once ISR is completed, the processor restores the registers’ contents from the
stack, and the interrupted program continues its execution.
Assembly Language
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 one machine code instruction (object code)
Symbolic addressing
Assembler
o Software that changes assembly language into machine code for the processor to
understand
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
Addressing
Data Movement
Arithmetic Operations
Comparing
Conditional Jumps
Unconditional Jumps
I/O Data
Ending
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
Bit Manipulation
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.
Bit Masking
Masking: an operation that defines which bits you want to keep and which bits
you want to clear.
Mask the content of the register with a mask pattern which has 0 in the ‘mask
out’ positions and 1 in the ‘retain’ positions.
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”.
The final ‘non-zero’ result confirms the patterns are not the same else vice
versa.
Need for OS
Memory protection to ensure 2 programs do not try to use same memory space
Paging
o File Management
o Security Management
o Process Management
Utility Software
o Disk Formatter
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.
Gets size for each folder and files, and generates a graphical chart showing disk
usage distribution according to folders or other user defined criteria.
o File Compression
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
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
o Process simple because assembly language has a one-to-one relationship with machine
code.
Compiler Interpreter
Reports all errors at the end of compilation: Debugging easier/faster, since it stops translating
difficult to locate errors∴ development when it reaches an error. This allows real time
process long. error correction.
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
o Presentation
Expand and Collapse code blocks: Saves excessive scrolling if collapsed, and easy
to see global variable declarations and main program body when collapsed
o Debugging
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
To prevent corruption of data and To prevent access of viruses to the system and prevent
prevent hackers from using data hackers from entering your computer system
o Malware
Virus: Software that replicates itself by inserting a copy of itself into another
piece of software, which may cause the computer to crash and can lead to
deletion or corruption of data
Spyware: software that gathers information about users' online and offline
activity, including accessed sites, applications, and downloaded files.
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
o Pharming
Risk restriction: use a reliable ISP; check that links are genuine and ensure https
is present in the URL
Can assign privileges to files so users with low privileges do not have access.
o Firewalls
(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:
Encryption
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.
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
o Parity Check
o Checksum Check
Data sent from one place to another as block of bytes rather than individual
bytes
If two bytes different, error occurred therefore block of bytes must be sent
again
Computer Ethics
o Regulate how computing professionals should make decisions regarding professional &
social 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
A license gives users freedom to run, copy, distribute, study, change, and
improve 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
o Commercial: Requires payment before it can be used, but includes all program's
features, with no restrictions
Artificial Intelligence (AI): the ability of a computer to perform tasks in such a way that is
conventionally associated with human intelligence:
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
AI Impacts
o Social
o Economic: Due to increased innovation and efficiency with automation provided by AI,
there’d be lower manufacturing costs in general
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
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 access rights of individuals or groups of users
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
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 the query plan.
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 updated when table data changes
Normalization
1st Normal Form (1NF): contains no repeating attribute or groups of attributes. Intersection of each
tuple and attribute contains only 1 value. Example:
3rd Normal Form (3NF): it is in 1NF and 2NF and all non-key elements are fully dependent on the primary
key. No inter-dependencies between attributes.
MANY-TO-MANY functions cannot be directly normalized to 3NF, must use a 2 step process e.g.
o written in SQL
Creating a database:
Creating a table:
Changing a table:
ADD <field-name>:<data-type>
Example:
Query and maintenance of data done using this language – written in SQL
Queries:
Creating a query:
SELECT <field-name>
WHERE <search-condition>
SQL Operators:
= Equals to
ORDER BY <field-name>
GROUP BY <field-name>
INNER JOIN
Data Maintenance:
Deleting a record:
WHERE <condition>
UPDATE <table-name>
WHERE <condition>
Identifier Table
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
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 REPEAT loop if you do not know the number of iterations required.
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.
Program Modules
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
Operator Meaning
>= Greater/equal
= Equal to
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:
Boolean:
Date:
Equates to number of seconds elapsed since 1st January 1970 00:00:00 UTC, excluding leap
seconds.
Array:
File:
ASCII Code
ASCII values can take many forms: numbers, letters (capitals and lower case are separate),
punctuation, non-printing commands (enter, escape, F1)
Unicode
o UTF-8: compatible with ASCII, variable-width encoding can expand to 16, 24, 32, 40, 48
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
Python:
o Printing column: use for loop and keep adding 1 to the row and keep column same
Bubble Sort
Another FOR loop is set up next in order to search through the array
The second FOR loop is count based thus will stop after a specific number of times
Linear Search
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:
r Opens file for reading only. Pointer placed at the beginning of the file.
w Opens a file for writing only. Overwrites file if file exists or creates new file if it 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:
An Abstract Data Type (ADT) is a collection of data with associated operations. There are three types of
ADTs:
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 removed from the other end (called the front)
Linked List: a linear collection of data elements whose order is not given by physical placements
in memory (non-contiguous). Each element points to the next.
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
o Pseudocode: IF…THEN…ELSE…ENDIF
“CASE” Statement
Iterations
Count-controlled Loop
<statement(s)>
ENDFOR
statement(s)
REPEAT
Not possible in Python
<statement(s)>
Use ‘’’python WHILE‘’’ and ‘’’python IF‘’’
UNTIL <condition>
Pre-condition Loop
WHILE <condition>
while expression:
<statement(s)>
statement(s)
ENDWHILE
Built-in Functions
String/character manipulation:
Converting:
Procedure
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)
<statement(s)>
ENDPROCEDURE
Calling a procedure:
CALL () Identifier()
Function
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
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
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 on development and producing a product-prototype.
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
Debugging:
Single stepping: traces through each line of code and steps into procedures. Allows you to view
the effect of each statement on variables
Variable dumps (report window): at specific parts of program, variable values shown for
comparison
Structure Charts
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
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:
Syntax errors:
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:
Corrective Maintenance
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.
Adaptive Maintenance
Testing Strategies
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’
Stubs are computer programs that act as temporary replacement for a called module and give
the same output as the actual product or software.
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.
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.