Computer Science Notes
Computer Science Notes
Two's Complement
& Data
Compression
Key terms
You will need to know some key terms before we get started:
1. Most Significant bit (MSB) - this is the bit in the binary number which is on the
leftmost side of the bnary number and it carries the highest denary weight
2. Least Significant bit(LSB) - this is the bit on the rightmost side. It carries the
lowest denary weight of one
3. Bit 0 is also considered as the LSB
Conversion
You will need to know how to convert from one number system to another:
1. Binary to Denary (vice versa)
2. Denary to Hex (vice versa)
3. Binary to Hex (vice versa)
We will talk about how each on is done briefly and I will also put a video for you
to watch at the end of the chapter
Binary to Denary
Let's take a simple binary number
00110011
The binary value has a place value of 2x
The LSB has a weight of 1 and the 2nd bit has a weight of 2 and so on
So whenever there is a 1 you take that particular place value weight of that digit
Do the same for all other digits which are 1
Then take the sum of all the weights and it will give you the denary value
0 0 1 1 0 0 1 1
- - 32 16 - - 2 1
32+16+2+1 = 51
There is also another method you can follow
00110011
You start with the MSB
First mutliply the MSB with 2 then get the value
After you find the value you add either 1 or 0 depending on the next bit
Then the new value is multiplied by 2 again and the whole process continues
When you receive the last digit(LSB) you just add the bit to the value and this
gives you the denary value
0*2=0
(add 0)
0*2=0
(add 1)
1*2=2
(add 1)
3*2=6
(add 0)
6 * 2 = 12
(add 0)
12* 2 = 24
(add 1)
25* 2 = 50
(Finally just add 1)
50 +1 = 51
This is my opinion a good method to follow
Denary to binary
There are also two methods for this
We will take the denary value 254 as the example
So we keep dividing the denary value by 2. We will sometimes get a remainder of
1 or 0. Then you read the remainders from the bottom to the top which gives us the
binary number
2|254
2|127 → 0
2|63 → 1
2|31 → 1
2|15 → 1
2|7 → 1
2|3 → 1
2|1 → 1
0 →1
Binary to Hex
This is the easiest conversion
We group the binary numbers to nibbles starting from the right and we find the
denary value of each nibble and this is converted to Hex ( very similar to BCD )
0011011
As we can see, this has 7 bits so how can we group in 4 bits
(0)001 1011
You need to add a 0 to the start to make it 4bits
0001 1011
1 11
1 B
= 1B16
To convert from Hex to binary follow the reverse order
1 B
1 11
0001 1011
Prefixes
Same as physics, we don't like to give storage or other specifications in large
numbers, we usually like to give it in 1 d.p
Here are the Decimal/denary prefixes
Prefix Magnitude
kilo 103
Mega 106
Giga 109
Tera 1012
This table uses Bytes as an example
This means that the size of data is grouped in quantities and the prefix tells us the
size of data
However, recent questions don't ask this now but, lets see one example
Convert 200000 Bits to MB
First convert the bits to bytes
200000/8 = 25000Bytes
Then to convert to MB just divide by 106
25000/1000000 = 0.025MB
But now we use binary prefixes because it is the correct way of representing
quantities
Prefix Magnitude
Kibi 210
Mebi 220
Gibi 230
Tebi 240
The 210 means 1024 Bytes
This is a bit complex and requires you to do a lot of workings
Lets take the same example
Convert 200000 Bits to MiB
Note now it MiB
200000/8 = 25000Bytes
25000/1024 = 24.4KiB
24.4/1024 = 0.024MiB
So really they will usually specify which one they want. If they say KB use denary
prefixes. If they use KiB use binary prefixes
Also if they say Mib instead of MiB it means they want Mebibits not Mebibytes
and so you don't have to divide by 8
Two's Complement
This is one's complement plus 1
What is one's complement?
One's complement is when the bits in a byte are substracted
from 1 ( so making a 1 to 0 and 0 to 1
An example is 00100100 is converted to 11011011 - so every bit is changed
To find two's complement we just need to add 1 to the 11011011
don't use this method as it is quite confusing
To convert a binary number to two's complement directly, follow this steps
Lets take an example
10011100
Ignore the first 0's on the right side
And also ignore the first 1 on the right
Then invert all other bits - convert 1 to 0 and 0 to 1
So we will get:
01100100
The first 0's and the first 1 doesn't change
This is a much easier method and usually used to change negative sign and
magnitude binary numbers
Properties
There are some properties of 2's complement and sign and magnitude you need to
know
Two's complement has only one representation for 0 where as sign and magnitude
have two forms - one for -0 and one for 0. This is actually an advantage of two's
complement
The maximum value which can be represented for signed integers using 4 bits is
2n-1 = 7
The largest negative number formed is -2n = -8
Binary aritmethics
Lets see an example
01011101
01111011+
________
11011000
To do this just follow the normal addition
Binary addition begins from the rightmost side
If 1 + 1 then it gives 0 and 1 is carried
If 1 + 0 then it gives 1 and no carry
If 1 + 1 + 1 then it give 1 and a carry of 1
If 1 + 1 + 1 + 1 then it gives 0 and a carry of 2
There is a pattern if you can see if the summed value is a multiple of 2 then we get
0 if not we get 1
The carry is the number of 2's which can fit the summed value
don't worry I will include a video for all these calculations below
There is also another longer method and that includes converting the binary
number to denary and doing the calculation
Lets see an example now to substract binary numbers
01111101
01111011-
________
00000010
Binary substraction begins from the right side to the left side
If 1 - 0 then it would be 1
If 1 - 1 then it would be 0
If 0 - 1 then it gives 1 and borrows one from the next digit
Why does it becomes 1? Because when we borrow 1 we get 2
Overflow errors
It is when the result of a calculation is larger than the number
of bits used to define the storage for the result
So sometimes when you add 2 binary number the result may have more number of
bits
1111
1111+
_____
(1)1110
Sometimes these overflow can cause the result to become negative when we add
two positive numbers
0111
0111+
_____
1110
Or when two negative numbers are added it can produce a positive number
10100000
10100000+
________
(1)01000000
The (1) will not be recorded as it won't fit in the storage, so then computer will
read this as a positive number which is wrong
Both of these examples are overflow errors and the processor must be able to
identify these - we will see them more in Assembly language chapter
0010
o ASCII
o Unicode
The standard uses 2 bytes to store each character allowing 65536 possible
characters
However most of the time its usually less as some bits are required to
describe the encoding used
UTF - 8 and UTF - 16 bits means that in UTF - 8 the system handles each 8
bits at a time.
Unicode use the term code point instead of character code
Unicode is able to represent all the characters in the world and many other
language so it used more commonly than ASCII
Unicode code point are usually represented using Hexadecimals - for
example U - FFFF
Notes in ASCII
All you need to know is ASCII is enough to represent the english character
set and numbers and some commands
Characters which are in sequence are changed by the ASCII value of 1 - Ex
A and B are only different by one value
The difference between the uppercase and lowercase ASCII characters is in
bit 5 - Ex (A=65) where as (a=97) so difference in 32
Representation of graphics
There are 2 types of graphics:
o Vector Graphics
o Bitmap Graphics
File header
The above calculated value gives the space required only to store the
graphics however at the start of the file there is a file header which provides
metadata of the file
Number of bits at the start of a image file which is used to
define the coding used such as the color depth and the
resolution
These are the things defined by the file header:
1. Image resolution
2. Color depth and the coding schemes
3. Image name and type
4. Compression techniques used(if any)
Sound Representation
Sound waves in the air are analogue waves which contain a range of values
and amplitudes and must be converted to the digital forms, we will discuss
each point in detail
Sampling
It is taking regular measurements of amplitudes at set
timed intervals (regular intervals)
So for the ADC convertor to convert from analogue signals to digital it must
take the amplitude at regular intervals and digitise them to binary.
Another point to remember that there is usually a band-limiting filter in the
sound encoder(instrument for recording and digitising sound) to remove
high frequency which can not be heard by the human ear
Sampling Rate
This is also known as sampling frequency
The number of samples recorded per second
This makes the sound more clearer/smooth and high quality as there is more
changes in the sound per second
Sampling resolution
The number of bits required to store each sample
This is also known as bit depth
The definition is easy however the understanding is also required - greater
bits required to store each samples means more possibilities of amplitude
can be recorded, this means if 3 bits are used to store each sample, then the
sample can represent 8 different sound levels or amplitudes
Usually 16 bits are required for good quality and to avoid any quantinising
errors
Higher sampling resolution means the sound is more crisp
Compression Teachniques
Remember that there are two types of compressions:
o Lossless Compression
Lossy Compression
This method removes unnecessary data which the
process can not be reversed to obtain the original file
This is done by reducing the image or sound quality by reducing the
color depth or the sampling resolutions
Removing slight changes in shade of color in images with one color
Using perceptual shaping where frequency which are inaudible are
either removed or stored with lower sampling resolutions
The resolution of the image can also be reduced
The problem is the quality is reduced but managable to the user
Internet, WWW,
Networks &
Transmissions
Network Structures
There are many different types of networks and it depends on the size of the
network
These include:
o WAN
o LAN
o Internet
o Thin client
So in thin client it sends request or data to a server and the processing occurs
only on the servers . Then the server will send a signal or an output to the
client
This is actually PHP coding
o Thick client
So in thick client the server sends the application/software onto the browser
and so the proccesing occurs on the browser itself and not on the server.
This is Javascript coding
We use each type for different purposes such as for ecommerce or online
stores we have to use thin client as data must be sent to the server. However,
if we use an online calculator the browser itself can perform the processing
The reason why I didn't mention the disadvantages as the advantages of the
other options are the disadvantages
Modes of Transmission
When ever they say mode of transmission there are 3 types
o Simplex mode
o Duplex
Topologies
It is the configuration or structure of a network and how
devices are connected
There are some main topologies which you must know and each of them
have there own advantages and disadvantages.
o Point to point
o Mesh topology
o Star topology
o Bus topology
Advantages
The performance of the network or other devices is not affected when a
device connected to the network fails
Also fewer cabling is used compare to the other topologies as a single
shared wire is used. So more cheaper
Disadvantages
However if the shared link is damaged the whole network fails
Higher chance of congestion as single wire is used so slow transmission
Also the message is broadcasted and so it is less secure
o Mesh Topology
Advantages
This allows direct communication with in the system and so faster and more
secure transmission
If a device fails it doesn't affect the network
Disadvantages
Requires alot of cabling so highly expensive and unrealistic
o Star topology
Advantages
Doesn't affect the perfomance of the network if an endsystem fails
More secure as the central device can filter the data
Disadvantages
If central device fails the whole network fails
Requires alot of cabling as devices must be connected to the central device
Depending on the central device there could be data collisions and
corruption and so less secure
Hybrid Network
It is a collections of LAN's which contains different
supporting technologies or topologies
Example is when a Bus topology is connected to a star topology we then call
it a hybrid Network
Usually as a whole the internet is a hybrid network
Bac k Ne xt
Recommended
These are things you might like. Clicking these ads can help us improve our
free services in the future...
Remember these videos are handpicked by me and I feel these are one of the best ones out
there. But I constantly update this list for each chapter.The Youtubers are more than
welcome to contact me.
Also, don't forget to Subscribe to our Youtube channel - Wiscus
Watch
Network Hardware,
ISPs, PSTNs & IP
Addresses
Transmission mediums
Transmission can be either guided (wired or cable) or unguided(wireless)
For each transmission medium there are many options. So we will see for each
their properties and advantages and disadvantages
Cable (guided)
Transmission which uses a wire such as twisted pair, fibre optic
or coaxial cable
Name of cable Bandwidth Interfe
Another point to remember is that fibre optics are highly expensive and twisted
pair is the cheapest
Wireless (unguided)
Transmission which uses radio, microwave or infrared.
Wireless Bandwidth Penetr
There is no clear trend for interference, however wireless transmission has more
interference than wired transmission
Also the need for repeaters is less often used than for wired transmission
Depending on the situation the type of wireless transmission used depends
Understand that infrared has a short range compare to microwaves and radiowaves.
For this reason we use infrared only for short range transmission
Satelites
Instead of using wired transmission for world wide communications we can use
satelites which uses wireless transmission (microwaves).
There are 3 types of satelites depending on their positions
o Geostationary Satelites
These are satelites which has an orbital period of one day and it is about
35000km above the surface of the earth.
Also the satelite will positioned above the same point above the earth
always.
They are usually on top of the equator
3 are required to enable global coverage and is usually used for long
distance telephone communications or networks
o MEO - Satelites
This is called medium earth orbit satelites which is used for GPS and 10 are
required for global coverage
o LEO Satelites
The Low earth orbit satelites has the lowest orbital radius. Thus this is used
in high speed telecommunciations and internet communications.
Usually the main reason why we don't use Satelites is because they are
highly expensive and difficult to maintain and also as they are very far away
they have a delay in transmission.
This delay is called latency
LAN Hardware
There are many devices or hardwares in a particular network and they have
there own functions
We must know in depth the functions of each device
o Repeaters
A device connecting two wires which provides a full
strength signal to the second wire.
The reason why the word amplifier is wrong is that a amplifier boost both
the interference and the signal whereas the repeater boosts the signal only.
o Bridge
o Switch
o Server
o Router
Acts as a node on the internet
So usually the router is used when we are connecting two networks together.
Actually the router we know is actually different from the ones the ISP
use.The routers used by ISP actually acts a point or a node which connects
other routers from other ISPs
The router also enables you to communicate with different underlying
network technologies - this is actually called a gateway but is replaced by
the router now.
Also as the name suggests the router finds the most suitable route for data
packets to be transmitted over the internet
Ethernet
Is used as a wired transmission for LAN networks.
The original ethernet or also known as legacy ethernet was used in LAN
networks
The central device used in early times was a hub
The hub had no control of where the data is sent and it is broadcasted to all
the devices
This has a higher chance of data collisions and data corruptions
There was a method used to avoid data collisions and this is called
CSMA/CD - carrier sense multiple access/ collision detection
You will need to know briefly this process
1. Firstly the transmission medium is checked if it has a voltage. If a voltage
is present then it will wait a random time and try again
2. When no voltage is detected the transmission is started and there is a
continous check for a collision.
3. If a collision is detected then the transmission stops and it alerts other
endsystems of the presence of a collision.
4. Then it waits a random time and tries again.
.
ISP
It is a company or organisation which links a device to the
internet by providing an IP address.
The fact is that this defines access ISP and there are actually many types of
ISPs
So the access ISP are connected to the middle tier ISP and the middle tier
ISP are connected to Tier 1 ISP.
This is indeed confusing however lets approach this logically. We know one
organisation can't handle the world ISPs. So the ISP are broken down
depending on their Hierachy and size.
The Tier 1 is the largest ISP and they connect Middle tier ISP to the internet.
The Middle Tier ISP connects the access ISPs. The Access ISP connects
users like you to the internet
It is mainly digital
So analogue signals means sound is transmitted
So telecommunications use analogue signals to transmit data
The internet transmits data in the form of digital electrical signals
o Cloud Computing
The reason why we use Public cloud servers rather than creating our
own servers(private cloud) is because it is highly costly and also not
alot of technical expertise are required to use public cloud services
The only problem with public cloud services are that data can be
accessed by the third party. So the user must hope and trust the cloud
service provider that they will maintain data security.
Bit streaming
They usually ask:
What is bit streaming?
IP Addressing (Ipv4)
An Ip address is quad dotted number which uses 32 bits to store each
address. Each 8 bits can be used to represent a value from 0 to 255.
Usually an ip address is in denary form
Example - 192.168.2.1
Ip addresses are provided by the access ISPs
The Ip address is used to identify a location on the internet so that data can
be sent to the correct location
As Ipv4 can only represent 232 differenct address it is not enough and so
there are many schemes used to use the IP addresses more efficiently.
There are two types of IP addresses
o Static IP address
o Dynamic IP address
Original scheme
In the original schemes the IP address were divided into fixed Class A , B or
C. These Ip address use the first few bits to define the class and also
contained a fixed number of bits used for Network and Host ID
The table is not required to be remembered.
The problems was that as due to the rigid number of host and network IDs.
This left alot of unused number of host IDs or very little amount of Host
IDs.
For example the Class C uses 21 bits to define the network ID and 8 bits to
define the Host ID
So this allowed alot of networks to be provided however only 256 hosts can
be connected to each network.
This caused many problems as the number of host were increasing this class
was not suitable.
Subnetting
A large organization that contains many workstations and quite far away.
Say each of them uses a separate network and the use they 8 bits for host ID
Then each workstation can connect 256 hosts to each network but each
workstation only uses 10-20 hosts, so this is gone for waste as not all the IP
addresses are used in each station
To make it more efficient we use subnetting.
For this we need a router that acts as a node and stores the IP address of the
hosts connected to the router.
So a single network could be used and then be divided using a router so then
it can connect workstations. So rather than using separate networks, the
single network can provide IP addresses for the hosts in each workstation.
In other words the network is split and each workstation gets an allocated
number of IP addresses depending on the number of hosts in each
workstation.
For this to occur the router must record the IP address of each host in every
station.
A single network is used and each subnetwork is a host and each end
system connected to each sub-network is also a host
Private Network Address- NAT
NAT is Network address translation.
We know that Ipv4 is not enough to identify each device on the internet
For this reason we use a method which requires only the (private)network
address to be unique and the IP address within the Network (private
address) must also remain unique. However, the private address of a
particular network doesn't have to be unique among different networks
For example your router has a public address that uniquely identifies the
particular network you're using. This address can not be repeated anywhere
on earth.
However when you connect your device to the WIFI router you will provide
an IP address called the private address which can not repeat in the same
network but can repeat in a different network. So if your friend connects to
the same WIFI router he will not have the same address as you. However, if
he goes to his own WIFI router, he might have the same IP address as you.
So a component called the NAT box is usually installed on the router which
converts the Private address to a public address before it is sent to a different
server. It also keeps a log of the request sent by the individual devices on the
private network.
Remember when I say the word network in this scenario it means private
network - network usually in a building home or office use.
Ipv6
As Ipv4 is not enough for future use, we must use Ipv6.
It uses 128 bits to store each address, and so can represent 2 128 addresses.
It is usually written in the Hexadecimal form
ffff:ffff:::ffff:ffff:ffff:1234The :: means it
contains:0000 inside
DNS service
It is a hierarchy distributed database which is installed on
the DNS servers which maps the domain name to their
corresponding Ip addresses
DNS servers are the servers that contain the DNS database.
So usually as it is hard to remember Ip addresses, we use domain names to
identify a particular web server or website.
The process by which the DNS servers map the domain name to the IP
address is called Name resolution.
Across the world there are few DNS servers called the root servers (top-
level DNS servers) and they store the domain names of the top-level
domains such as .com
Sub domain servers hold subdomains in their system and the Ip address for
that particular zone
Example - the Britain sub DNS servers may contain domains such as
the .edu or .gov which are only related to a specific region.
Here is an example of a domain name: Revisezone.com
Name resolution
You will need to know the steps of mapping a domain name to its Ip address
1. First, the domain name is typed on the user browser, then it is sent to the
DNS servers.
2. If the domain name is in the system or database then the correct Ip
address is returned
3. If it is not in the database the domain name is forwarded to a different
root server and follows the hierarchy of the domain name to retrieve the Ip
address. This means if it was a .uk.edu it would first go to UK then the edu
sub-domain servers
4. If not found the browser will check the cache memory for the old Ip
address and use this instead.
Bac k Ne xt
Recommended
These are things you might like. Clicking these ads can help us improve our
free services in the future...
End of Chapter Videos
Remember these videos are handpicked by me and I feel these are one of the best
ones out there. But I constantly update this list for each chapter.The Youtubers are
more than welcome to contact me.
Also, don't forget to Subscribe to our Youtube channel - Wiscus
Watch
RAM
This is called random access memory
They are used to store programs and part of the Os currently in use
Data can be written to or read from many times
They are volatile (data is lost when the power is switched off) and so they store
data temporarily
There are two types of RAM:
o DRAM
Dynamic RAM
This type of RAM stores data in capacitors and transistors where they are
contantly charged to prevent data leaking out and losing their identity
This usually has a greater capacity than SRAM
They are much cheaper than SRAM but more slower to access
Also DRAM uses less power
DRAM has more memory cells per area than SRAM
o SRAM
Static RAM
Data are stored in flip flops
Has a very fast access time and thus used for cache memory
Stores less data than DRAM and is more expensive and uses more power
than DRAM
ROM
Read only memory
Data can only be read from many times but can not be written
It stores boot up instructions such as the BIOS
It is non volatile memory and so it is permanent
Usually ROM chips contains the instructions when the chips are
manufactured but the other 3 are slightly different
There are three type of ROM:
o PROM
Programmable ROM
The chips are given to the people who installed the code. Once installed it
can not be changed and must be replaced
o EPROM
Erasable PROM
This are ROM chips which data can be erased in the presence of UV light,
however the chip must be removed from the circuit board
o EEPROM
Buffers
A place made in the memory where data is temporarily
stored when moving data from one location to another
which functions as a queue
When data is transmitted at a faster rate than it is processed or displayed
( Bit streaming ) then data must be temporarily stored as a queue
Secondary memory
There are many types of secondary memory, we will discuss them
Hard disk
This also uses magnetism to store data
Data is stored in many disks called platters which are spun at high speeds
The disc are usually made out of aluminium plated with glass
There is a read-write head on each side of the platter which either reads or
writes data using the magnetic properties - this done by varying the electric
current in the write head
Data is stored in concentric tracks(circle) in each platter
The tracks are divided into sectors and the sector contains the smallest unit
of storage.
Data in the hard disk are stored in blocks
There is a confusion between a disk sector and a track sector
When we talk about sectors, we are talking about the track sector which is a
sector a single track and not the whole disk
Optical media
This uses a way different property and this is used by CDs and DVDs and
more
The CD - ROM and DVD - ROM have slightly different mechanisms which
we will discuss
o CD - ROM
Uses a red laser light to read data
This is done by the read/head
The disc spins at high speeds
This stores data in spiral tracks
The surface contains pits and lands
The red laser is reflected by the surface. The pits reflect less light than
the lands - this is then decoded in to binary code
o DVD - ROM
o CD - RW
o Blu-ray
The solid state drive which is used instead of the hard disk uses the
same solid state technology and there are many advantages over the
Hard disk drive
1. The main advantage of using SSD over HDD is that SSD has a
faster access time so it is usually fast
2. Also SSD does not have any moving parts and so it is more reliable
and more long lasting
3. Also SSD is more lightweight and portable as no moving parts,
also it uses less power
Summary
Registers and cache memory has the smallest storage and they are
highly expensive but has a very fast access time
Secondary storage has a high storage and are cheap but has a slow
access time
Screen Displays
There are 3 main types of displays
o CRT
o LCD/LED Screens
o OLED
Organic LED
This does not require any backlighting and so the screens are
very thin
The screen contains and anode which emits there own light
which causes an image on the screen
These are made from polymers which are very flexible
OLED screens are very expensive
Printers
There are two main types of printers which we will discuss
o Inkjet printers
These spray ink using small printer nozzles - this is done by either
using thermal bubble technology or the piezoelectric technology
The ink is sprayed line by line until the whole document is printed
Usually inkjet printers are cheaper than laser however the ink costs
more
Also inkjet printers are relatively smaller than laser printers
o Laser printer
This uses the idea of charge and printer toner to produce hard copies
We will need to know each step in the right order
1. Data is sent to the the printer driver to convert it to a form the
printer understands
2. Data is stored in the buffer
3. Firstly the drum is given a charge and it starts rotating
4. A red light is switched on and off on the drum as it rotates - when
it switches on it discharges the charge on the drum
5. The drum rotates step by step until a full electrostatic image is
formed - the discharged areas are the content to be printed
6. The printer toner which is also given a charge sticks to the
discharged areas of the drum
7. A charged paper is fed in and the toner sticks to the paper then the
paper is passed through heaters which fuses the toner to the paper
8. If you need to print color the paper must go through the printer
several times for each color (CMYK)
The advantage of laser printer is that it is very fast and also has a high
quality
However, every large and expensive compare to the inkjet printers
The printing cost on the other hand is cheaper than inkjet
Printing Colour schemes
Usually images are displayed using the RGB format, however in t
printed documents color is printed using the CMYK format
C - CYAN . M - MAGENTA . Y - YELLOW . K - BLACK
So different levels of cyan, magenta and yellow are used to produce
color documents
So to print a colored document it must go for each type of main color
3D Printers
These are used to create 3D objects which are created from of
software called the CAD or the CAM(computer aided manufacture)
The printer contain nozzles which sprays the powder or the material
and nozzles to spray the glue
The design of the 3D object is made from many layer designs and so
the onject is created by layer by layer until the full object is made
After this the object must be finished or cured - final touches
Keyboard
This is an input device
We will need to know the mechanism of this
The keyboard contains wires which are aligned horizontally and
vertically. Every key on the keyboard has its own key matrix which
when clicked can be uniquely identified
When a key is pressed this causes the wires to be pushed and cause
the wires to contact with each other
When the wires contact together it completes a circuit and the signal
is sent to the microprocessor
The processor determines the position of the contact and sents a
signal to the keyboard ROM and accesses the corresponding character
code and then send it to the computers processor
Remember this processing is done by the keyboard itself
The ROM contains the character codes whereas the microprocessor
identifies the position of the contact
Touchscreen
This is a bit confusing but touchscreens are input devices this is
because we usually talk about the input mechanism and not the
display
There are two main types of touchscreens but we will discuss the
other ones too:
o Resistive
o Capacitive
Other technologies
Other screen technologies include infrared and sound waves
When a finger is pressed the infrared signals or sound waves are
blocked or weakened and detected by the sensors
The position of the touch is calculated and decode to data by the
processors
Scanners
In order to convert a hardcopy to a softcopy we need scanners
Usually the paper or the document is fed in and a bright white light is
shined over this document
The reflected light from the document is focused using lenses and
mirrors to a light sensitive screen known as the CCD - charge couple
device
The CCD contains smalls photoelectric sensors which converts the
light into electric signal. Also the electric signal produced is
proportional to the intensity of the light
Each cell or sensor of the CCD represents a pixel when converting
and storing the image as BMP or JPEG file
Also the electric signals from the sensors must be converted to
digital(binary data) using an ADC convertor
Each cell or sensor of the CCD represents a pixel when converting
and storing the image as BMP or JPEG file
o Speakers
3D scanners
This is an input device
This uses the principle of tomography where the objects is
broken down to small layers and stored in the computer
Usually the layers can be viewed using the CAD software
This technology is used in MRIs
2D and 3D cutters
This is an output device
This uses either laser or high pressure water to cut objects and
the information is given by the computer
Bac k Ne xt
Recommended
These are things you might like. Clicking these ads can help us
improve our free services in the future...
End of Chapter Videos
Remember these videos are handpicked by me and I feel these are one
of the best ones out there. But I constantly update this list for each
chapter.The Youtubers are more than welcome to contact me.
Also, don't forget to Subscribe to our Youtube channel - Wiscus
Watch
Logic gates
These manipulate the bits entered to the gate and output a bit depending on the
type of the gate used
We usually use a truth table to show the different combinations of bits which can
be entered to the logic gate and their corresponding outputs. A bit can be either 0
or 1
You will need to know some of these gates and how to draw them and draw their
truth table:
o NOT Gate
Truth Table
Input
o AND Gate
There can have two or more inputs
In this both the inputs must be true for the output to be true.
Truth Table
A B
0 0
0 1
1 0
1 1
o OR Gate
This also can have two or more input values.
In this gate either one of the input values must be true for the output to be
true.
Truth Table
A B
0 0
0 1
1 0
1 1
o NAND Gate
It is the opposite of the AND gate. This is done by using a NOT gate after
the AND gate.
The output is TRUE only when both Inputs are not TRUE which means only
when inputs are both true the output is false. If one input is true and the
other one is not then the output is still true
In simpler terms the output is true when neither A or B are both true
Truth Table
A B
0 0
0 1
1 0
1 1
If you do forget how to draw the table just draw the opposite of the AND
truth table.
o NOR Gate
Truth Table
A B
0 0
0 1
1 0
1 1
o XOR
It only can have 2 inputs
The output is TRUE when the input values are different (not same).
Truth Table
A B
0 0
0 1
1 0
1 1
3 Inputs
Most questions usually have 3 inputs (A B C) and so this leads to 2 3 possibilities =
8 combinations
So now there are 8 rows and 3 inputs. So we also need to remember this pattern
Truth Table
A B
0 0
0 0
0 1
0 1
1 0
1 0
1 1
1 1
We create the truth table based on the number of input values the ciruit begins with
and not with the intermediate values
Truth Table
A B C E(N
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
1 -
1 -
1 -
0 -
For you to identify this requires practice and a bit of trial and error
As we know that the next gate must be a NAND gate(or else this could lead to
infinite possibilities).
So the value of the first NAND gate is compared with another NAND gate.
So to get 0001 as required output I must try 1110
Which is same as the first row. This means the output is split or duplicated as the
diagram below
They will ask to replace NOR With OR gate as this is because OR and AND and
NOT gates are fundamental gates which are used to create more complex gates
Below I gave some very common examples which you have to remember
Bac k Ne xt
Recommended
These are things you might like. Clicking these ads can help us improve our free
services in the future...
Remember these videos are handpicked by me and I feel these are one of the best ones out
there. But I constantly update this list for each chapter.The Youtubers are more than
welcome to contact me.
Also, don't forget to Subscribe to our Youtube channel - Wiscus
Watch
Processor,
Interrupts &
Register Notations
Von Neumann architecture
You will need to remember some characteristics of the von neumann architecture.
1. A single processor is used.
2. The processor has direct acces to the memory
3. The model contains a single memory unit which stores both intructions and data
- this are called stored programs
4. The instructions are executed one after another in sequence
The CPU
There are many components of the cpu which you have to remember
These include registers, the system buses, the internal clocks and more
The CPU has an internal clock which is also known as the CPU clock. This clock
tells us the frequency which the processor operates at. It tells us the number of
activities performed by the CPU per second - Ex 1.7GHz means that the system
performs 1.7 billion calculations per second
An internal clock is a clock which controls the cycles of activity
(clock frequency) of the processor per second
There is also a thing called system clock which controls the cycles or clock
frequency of the components out of the processor, this includes the input and out
devices.
The system clock controls the number of activities processed
per second outside the proccesor.
Usually the system clock is less than the CPU clock.
Registers
A component of the processor which is an area of memory that
stores data temporarily in order for fast access of data
There are many registers in the proccesor and you will need to know some of these
registers
First of all we need to know that there are two types of registers and they are:
A register used for general purposes and to store any type of data. An
example is the Accumalator(ACC)
We will also need to know the definition of the accumalator register
This will be covered below
You need to know that this register is located in the ALU and it stores the
data or value which is currently being executed and after it is executed -
Example is when we add a value to the ACC
Also the accumalator can store one value only at a time
These are register which are used for special purposes and they store
specific types of data
There are many special purpose registers you have to know
Special registers
Name Abbreviation
Memory address register MAR
Index register IX
Program counter PC
Status register SR
SR and CIR
Most questions asks you to define these two registers - so we will define
them in depth:
o SR
The status register contains bits which are independant of each other
and they flag a certain event such as an overflow, carry or negative
flag
o CIR
Control unit
Is a component of the CPU which sends and receives
control signals from other system components. This make
sure that data is synchronised and executed in a sequential
manner
The control unit is the same as CU and contains two registers - the CIR and
PC
System bus
A set of wires which transmits bits simultaneously (parallel
transmission) which allows components in a system to
communicate.
There are 3 types of system buses:
o Address Bus
This bus only carries addresses, usually from the MAR to the
memory or I/O
The bus is unidirectional bus so it can transfer addresses in one
direction only
Usually the bus width of the address bus tell us the maximum number
of memory locations in the memory - Ex A 64 bit bus width means
264 memory locations
o Data Bus
This Bus can carry data - which includes instructions and addresses,
usually form the memory to the MDR and also from the MDR to the
memory.
This is because the bus is a bidirectional bus which can transfer data
both directions
o Control Bus
This bus is used to send control signals to carry out the opcode and
also timing signals to make sure the components are synchronised
and operating at the same clock freqency.
This is a bi-directional bus so it can send signals and also receive
signals - Example receive signals from I/O
o Word length
o Cache memory
Cache memory are not registers but are an area of memory
which can store data temporarily for fast access of data. We
have discussed this in the hardware chapter.
I/O ports
Input and output devices are very important as they let the user
communicate with the applications. However for it to
communicate there must be an interface - in order words a
translator for the I/O devices to communicate with the CPU
So that's why we use an I/O controller which is connected
between the CPU and the I/O ports
The I/O ports are used to connect peripheral devices to the
system.
USB
This stands for universal serial bus
We call it a bus because it it parallel transmission however this
is a bit confusing as it uses both serial and parallel
transmission. Serialised and then deserialised
Usb is used to connect peripheral devices through the USB
ports such as your keyboard
There are some points or advantages you need to know.
1. The USB is plug and play which means the device could be
used and controlled as soon as it is plugged in.
2. It is now an standard for industrial use
3. It is supported by many OS
4. It can only be fitted one way and the newest version is 3.2
Special multimedia ports
Usually USB cable would not have a high bandwith and so we
need to use other ports such as a VGA ( visual graphics array -
blue wire head ) or HDMI (High definition multimedia
interface).
However the HDMI cable has a higher bandwith than VGA
and so can transmit higher graphics and also sound/audio
whereas VGA can only transmit graphics
The above one shows one cycle and sometimes you need to do
2 or more cycles to do a simple calculation.
Also remember the time taken for the cycle depends on the
clock frequency
Register notations
The above steps could be written in register notation but there
are some rules you need to know.
MAR ← [PC]MDR ← [[MAR]]; PC ← [PC]+1CIR ← [MDR]
Interrupt handling
Usually interrupt can be caused by several reasons but, we first
need to know what an interrupt is.
An interrupt is a signal generated by the
software or hardware which requests the CPU's
attention to service it.
Interrupts are usually caused by:
1. Hardware faults - example no paper in the printer
2. Software error
3. Timing signals - Inorder for programs run simultaneously.
4. I/O signals - Try holding the shift key for 10 seconds
5. User interactions
Bac k Ne xt
Recommended
These are things you might like. Clicking these ads can help us
improve our free services in the future...
Try out
End of Chapter Videos
Remember these videos are handpicked by me and I feel these are one
of the best ones out there. But I constantly update this list for each
chapter.The Youtubers are more than welcome to contact me.
Also, don't forget to Subscribe to our Youtube channel - Wiscus
Watch
Assembly
Language, Machine
Code & Computer
Arithmetics
Machine code instructions
Machine code is the language computers can understand so all other languages
must be converted to machine code
A machine code instruction usually consists of 2 parts - the opcode and the
operand
Sometimes there can be no operand or sometimes more than one operand
Opcode
It is the action to be taken by the instruction
This is done by sending it to the Control unit
We will look at this notation again
CU ← [CIR[x:y]]
This shows that part of the instruction stored in the CIR is sent to the CU and this
is the opcode
Operand
It is the data or value to be used or needed by the instruction
Assembly Language
It is a low level language where opcodes are written using
mnemonics and operand as labels/names
As it is hard to code in machine code we use assembly language as this makes it
easier to read and code and so less errors
Also it executes much faster compare to high level languages as assembly language
is considered as a low level language
So an assembler is required to convert the assembly language to machine
code(binary)
Directives
Instructions given to the assembler on how to translate the code and produce the
final code. Also it defines any use of files or procedure to be used by the code
Macros
A sequence of instruction or a block of code which is used frequently - this is like a
procedure
Representations of Assembly
Languages
There are 3 ways assembly language program can be written in and they are:
o Symbolic addressing
o Relatively addressing
So this uses offset values to represent the addresses. This means that the
operand is represent as an offset value from the starting point or the base
address.
Example is ADD [BR] + 15
This shows that the address to be used is 15 steps away(down) from a
defined base address.
o Absolute addressing
Base address
It is either the starting address or the address defined so all other addresses
are offset values from it. Offset values - It shows the number of steps away
the address is from the base address.
o Immediate
o Direct addressing
o Indirect addressing
o Indexed addressing
Shift operations
Shifting means that the bits are shifted to one direction and the removed bit
is replaced by a 0
There are 3 types of shifts we will need to know:
o Logical Shifts
Logical shifts can either be left logical shifts(LSL #n) or right logical
shifts(RLS #n)
This shifts the bits in the accumalator to the left or to the right
An example is the ACC contains 10101010 and this is shifted left by
2 (LSL #2) this will produce a new value in the ACC of 10101000
o Cyclic shifts
The bits are shifted in a cycle and it reappears on the other side of the
register
o Arithmetical shifts
We don't need to know these in depth but just have a basic understanding.
Logical shifts are the most important thing to remember
Computer Arithmetics
We have discussed in chapter 1 that the CPU must be able to detect
overflow errors and correct them. We will see a brief explanation.
Firstly you need to remember the status register and the 3 flags
(overflow,carry and negative flag)
Negative flag(N) - checks whether the result is negative
Overflow flag(V) - checks whether the Most significant bit has been
changed due to an overflow
Carry flag(C) - checks whether a positve value is caused but has been
caused by an overflow
If the addition of two positive values results in a negative value - both the
negative and overflow flag are set to true and so the processor must try to fix
it depending on this combination of flags
If the addition of two negative values results in a positive value - both
overflow and carry flags are set to true and the processor must be able to
detect this and correct it.
The mechanism of correction is not required
Tracing
This is always asked in past papers
They usually give us the instruction set which define what each opcode
does.
The trace table holds the contents of the registers (Accumalator) and the
memory address used to store values
You need to know some points when doing the trace table, you need a new
line for each instruction in the trace table
Also the value must be recorded only when the value is updated or else you
could leave it blank
Check the video section to see an example on this
Recommended
These are things you might like. Clicking these ads can help us improve our
free services in the future...
Bac k Ne xt
Try out
End of Chapter Videos
Remember these videos are handpicked by me and I feel these are one of the best
ones out there. But I constantly update this list for each chapter.The Youtubers are
more than welcome to contact me.
Also, don't forget to Subscribe to our Youtube channel - Wiscus
Watch
Monitoring &
Controlling
Systems & Bitwise
Operations
What you need to know?
Controlling systems are systems which measure a physical properties and alerts the
user if the system is out of range.
There is very little difference between a monitoring process and a controlling
software. The only difference is that the controlling does an extra role and sends
signals to an actuator to alter the system
You will need to know the hardware used in monitoring and controlling systems.
Also we need to remember the steps when the process occurs.
Usually these points are the same in every marksheme and will help you to score
the marks.
Sensors
It is an input device which measures a physical property of the
environment and sends digital signals to the processor
There are many types of sensors you have to know and identify
o Temperature sensor
o Ph sensor
o Infrared sensor
o Pressure sensor
Actuator
A hardware or device which receives signals from the
processor to alter the system.
A good example is a cooler or a fan on your CPU, the fan spins faster when
you're gaming.
Bitwise Operations
Bitwise operator are heavily used in assembly language. It compares two
binary numbers or denary(must be converted to binary) and outputs a result
depending on the operator used
When dealing with bitwise operations. The individual bits are considered
01100101 AND 01110111
Usually when representing a binary number we use b01100101
So the individual bits are compared
01100101 AND
01110111
________
01100101
Bac k Ne xt
End of Chapter Videos
Remember these videos are handpicked by me and I feel these are one of the best
ones out there. But I constantly update this list for each chapter.The Youtubers are
more than welcome to contact me.
Also, don't forget to Subscribe to our Youtube channel - Wiscus
Watch
Operating System,
Compilers,
Interpretors &
Utiity Softwares
Operating system
An operating system is a system software which enables you to perform system
functions and also provides a platform to perform other application softwares.
There are many functions which are provided by the operating system:
o User interface
o Program-hardware interface
o Memory management
o Device management
It stores a list of all the hardware and peripherals connected to the computer
and also controls the signals sent or received by them.
o Resource/process management
o File management
o Security management
The Os controls the access rights for each user by using passwords and
usernames.
Also the Os contains sofwares such as the firewall to prevent hacking.
Usually they ask you to state a use. So we usually don't need to explain it much.
Utiltiy Softwares
It too is considered as a system sofware as it is a softwares which perfoms a
specific system function such as the examples below:
These are Utiltiy softwares which are usually used to recovery accidental
loss of data or to fully erase a disk.
Also there are applications which are called disk checkers or repairs. These
scan the disk for any problems such as hardware or software bugs and
identifies them and sometimes fixes them.
o Disk defragmentation
Usually over a long use of a hard disk, we may delete and add data.
Sometimes these could lead to holes in the storage - meaning unused free
spaces which are not able to be used directly
So the disk defragmentation software make sures that data is stored in the
most efficient form without any spaces unnecessarily left out.
o Backup softwares
o Antivirus software
Performs regular scans and checks for malwares and viruses on the system
Make sure the database of the Antivirus software is up to date.
Quarantines or deletes any detected malware
Programs Liabries
Subroutines is the general name for a function or a procedure.
So modules or subroutines are block of code which are able to perform a
specific task.
Usually they are tested and can be used more than once in a computer code.
Program liabries are documents or files which contains a collection of
modules or subroutines which a program can refer or call
These files are usually called dll (dynamic linked liabries).
So this make the code more reliable as these modules are already tested.
Also it reduces the size of the code as they are written once and called.
Makes it easier to build a program
Language Translators
It is a software which converts or translates a
programming language to machine code.
All programs and websites are written using programming languages and
script languages.
Revisezone is built using 3 Languages
HTML,CSS & JS - however html and css are not programming languages
There are two types of translators - interpreter and compilers
Programming languages are broken down to two types:
o High level Language
Compilers
The translator first translate the source code into a intermediate code
and the code is compiled as a whole.
If there are errors present at the end of the process it will display an
error diagnostics but it will not produce any final machine or compile
code.
If no errors are detected the intermediate code is then converted to a
machine executable code.
This compiled code is in binary and so it runs directly on the
proccesor.
- Advantages
An executable code is produced which can be distributed. This is also
more secure as the users will not receive the source code.
Doesn't require the translator software to run the compiled code
Executes very fast and directly on the processor
- Disadvantages
Compiled programs can have viruses
The compilation process is quite long and resourceful and also
provides a compiled code after all the errors have been corrected
Higher chance of system crashing
Interpreter
This type of translator executes the code line by line and not the
whole code at once
It produces an object or machine code for each line and executes it.
If an error is identified the execution stops and thus alerts the user to
correct the error
- Advantages
Best for debugging and testing purposes as it produces an alert as
soon as the error is found
The whole code doesn't have to be written as the code is translated
line by line
- Disadvantage
The execution of the procces is very slow
The source code is seen by the user so it less secure
The translator is used everytime the program is executed
Bac k Ne xt
Recommended
These are things you might like. Clicking these ads can help us
improve our free services in the future...
End of Chapter Questions
Collection of Topic Questions to understand the topic more.
Try out
Remember these videos are handpicked by me and I feel these are one of the
best ones out there. But I constantly update this list for each chapter.The
Youtubers are more than welcome to contact me.
Also, don't forget to Subscribe to our Youtube channel - Wiscus
Watch
Data Security,
Integrity & Privacy.
Verfication &
Validation
We will need to know some of these definition
Data Integrity
Making sure that data is accurate and up to date
This means that that data must be accurate and not be changed accidentally or
corrupted
Data Privacy
Making sure that data is available to authorised users only
There is a law which is related to data privacy and this is called data protection
law.
This makes sure the data is kept confidential
Data Security
Making sure that data is accurate and only available to
authorised users and is made available to access. Also data can
be recovered if lost or corrupted
This make sures that both data integrity and data privacy is maintained and that
data can be accessed if lost or corrupted by recovering it
Sometimes the user will be the one accidentally harming the computer
This includes using a pendrive which contains malware
Also sometimes the user may download files from the internet which may
contain the malware
The user might have a poor password making hacking easier
The user may open email attachments containing malware
This is due to the poor security of the firewall and also due to the bad
antivirus software
We need to have a server which is away from the main server in case the
main server is damaged due to a natural disaster
This stores the data in a remote area which is protected against the disaster
and can be used to retrieve data
o Back up
o Encryption
This makes sure that data stored is encrypted so when data is hacked the
hacker is unable to read them and so data privacy is maintained, however
the hacker can still corrupt or delete the data.
This will be covered in A2
o Firewall
o Good practice
o Antivirus software
Validation
It means that data is within acceptable boundaries and in
range or type
This makes sure the data entered is reasonable
We have some rules usually in some softwares like in databases to validate
whether data entered is acceptable
Some of the checks are:
Presence check - ensure that data is entered and not left blank
Range check - ensures that data or the number entered is within a particulare
range
Type check - ensures that the data entered is of correct type example String
Format check - ensures that data entered is of right format
Length check - ensures that data entered has the correct number of
characters
Existence check - ensures that the data entered is present in the system
Limit check - checks if the value entered is above or below a certain value
Check digit
Another point to remember is that check digit is a validation. The
calculations will be discussed later
All you need to know is that the check digit is calculated depending on the
other digits
If the check digit fits the calculated value then it is acceptable
Verification
Ensures that the data entered is that of meant to be
entered and it matches the original data
This also doesn't mean that data is accurate as the user may have the wrong
value but type in what he think is right. This is verfied but not accurate
There are 2 methods of verifying data:
Double entry - data is entered twice to make sure it matches the original
value
Visual check - a manual check done by the user to see if he has typed in the
correct data(proof reading)
Checksum is calculated at the senders' end and it is sent with the data block
during transmission
At the receiving end the checksum is recalculated and then compared with
the received checksum
If they match it means no error has occurred so it is verified
If there is an error the data is resent and the location of the error is not
known
The advance and better version is parity block where data is sent in many
bytes
So each byte is checked and also the bits are checked vertically
In parity block the location of the error could be found by finding which row
doesn't follow the system parity and which column doesn't follow the
system parity. The intersection will give us the corrupted bit.
To that end we need to know how the parity blocks are formed before
sending and also how to check whether an error has occured
It's quite simple just count the number of 1's and see if it follows the system
parity.
When forming a parity bit the bit must be either 1 or 0 to make the byte
follow the system parity
Example if 0011010(?) and the system follows even parity then this must be
0011010(1)
Bac k Ne xt
Recommended
These are things you might like. Clicking these ads can help us improve our
free services in the future...
Try out
Remember these videos are handpicked by me and I feel these are one of the best
ones out there. But I constantly update this list for each chapter.The Youtubers are
more than welcome to contact me.
Also, don't forget to Subscribe to our Youtube channel - Wiscus
Watch
Ethics, Shareware,
Freeware & AI
A set of rules or principles which regulates the actions of people
or computers within an area of profession.
So ethics is just a set of rules to decide if something is right or wrong
We need to remember the IEEE/ACM code of ethics and there are 8 rules to be
remembered:
o Public
o Judgement
o Profession
o Collegues
o Management
Questions
Usually in questions, they give an example of a situation and ask whether it
is ethical or not and we must explain the points to support it.
Here is the catch! Sometimes they accept both answers or sometimes it's
quite obvious. So the explanation is where you need to work on
Ownerships and
Softwares
Copyright
A formal recognition of ownership of a created and
published work.
A work could be anything such as music,website or a software. You can't
copyright ideas, this is known as patents.
And so the Copyright law protects others from using another person's work
to generate revenue or for other uses
The copyright law records the date which the document was made and
records until which date the copyright law applies. Also the procedure to be
taken when the copyright law expires
Copyrights are not part of ethics as these are laws implemented around the
world and if broken have large consequences. Also usually the copyright
law states how the document is to be used
To use a copyrighted material requires permission from the owner
Commercial softwares
These softwares are distributed to the public in exchange for a fee. However
there are two types of commercial softwares which are free but have some
connditions:
o Freeware
They are given free of charge and they are usually the beta version or
the version which has limited features.
This can be used by the user but he wont be able to take advantage of
all the features of the original one.
Freewares do have copyright legistations and the source code is not
distributed(only the compiled code)
o Shareware
A software which is usually distributed and is free to use but only for
a limited time or trial
Most of the time this version has all the features but only for a limited
time
Copyright laws still apply and also the source code is not sent
Artificial Intelligence
This is more of an A2 topic however we will cover it briefly.
AI is the study of computers being able to perform things which
humans are better at than computers. There are 5 main behaviours or
qualities the computer needs to mimic to become truly AI.
o Problem Solving
The computer must be able to come up with new and original ways to
approach a solution to a problem
o Perception
o Linguistics
o Learning
Being able to learn new things and come up with new ideas and
outputs based on the data fed to the system.
This is part of machine learning where the computer gathers a large
set of data to make predictions of the future or to make suggestions or
provide preferences to the user
o Reasoning
Impacts of AI
If AI does indeed becomes perfect, they could be very useful as they
can perform things which even humans can not do and judge
situations and problems more efficiently and faster.
They could be used in medical systems to predict solutions and also
be used in the manufacturing process
They could be used also in driverless cars
The problems caused by AI would be that this would cause lack of
jobs to human workers and also cause more laziness. Also as AI has
the upper hand it can manipulate data and be entirely up to no good as
they have there own mind to decide what is right and wrong
Infact destroying the human race could be the robot's reasoning for a
better future! This is why many don't like the idea of AI.
Bac k Ne xt
End of Chapter Questions
Collection of Topic Questions to understand the topic more.
Try out
Recommended
These are things you might like. Clicking these ads can help us
improve our free services in the future...
Remember these videos are handpicked by me and I feel these are one of the
best ones out there. But I constantly update this list for each chapter.The
Youtubers are more than welcome to contact me.
Also, don't forget to Subscribe to our Youtube channel - Wiscus
Watch
Database,
Normalisation &
SQL coding
Differences between data stored in files
and in Databases
There are 4 things you need to comment in the exam
o Data integrity
o Data privacy
Databases allow access rights which limits the users access to the data
stored in the databases
Files do not have any proper access rights. However, the only method to
restrict access to data is to make copies of the file and distribute the edited
files to the individuals which contain the data only for that particular user
o Data redundancy
If files are distributed and copied then data is unnecessarily redundant and
so this will take unneccessary storage
The database organises the data in the most efficient way possible to remove
data redundancy. And also many different users of different access rights
can access the same and only database
o Data dependancy
When data is stored in a file the structure of the file data must be known but,
the databases uses queries to store and retrienve data without knowing how
data is stored in the database(this is known as the external level).
Also when storing new data the programs may have to be changed where as
in databases this is handled by the DBMS software and the users just has to
add new data
Relational databases
You may have heard what databases are, it contains tables which store data
However, in AS we need to know what relational databases are
A flatline table is table which is considered to be a stand alone table and has no
relation with other tables
In the relational database model the tables have links between other tables
You will need to know some new terms in this model
o Relation
o Attribute
Candidate key
One or more key attributes which contain unique values
for each tuple
In the table(relation) there might be attributes which contain unique values.
So this could be used to uniquely identify each record or tuple
Primary key
This is a candidate key which is used to uniquely identify
each tuple
Each table must have a primary key as it prevents data redundancy as each
tuple in the relation is automatically unique when the primary key is unique
So as we can see the primary key is chosen from the candidate keys
Secondary key
A candidate key is not used as a primary key
This is mainly used for indexing which we will learn later
Foreign key
A key which is used to link to a primary key of another
table
This is how the relationship between tables are made
Referential integrity
The use of a foreign key ensures that a value can only be
entered in one table if the same value already exists in the
referenced table
This means that foreign key of a table can not be different from the primary
key of the referenced table
This ensure that the values in the foreign key must match the primary key
values
Firstly, the attributes are made, then the foreign and primary key are defined
Also the primary key can not be updated or changed/deleted if the foreign
can't refer to the primary key
Cardinals or relationship
When finding the relationship between two entities we need to use logic
There are 4 types of relationships between entities and for each we will give
an example
However we could also add some additional information
These are
detailed E-R diagrams which has the maximum and minimum values
for each entity also. We can see a zero meaning it could have a
mimimum of zero recordsThis | symbol means that the minimum
value is one
Detailed E-R diagrams are not usually tested so you can ignore them
but you need to know how to draw a normal one
o One to One
o Many to many
There are few things you need to remember everytime you see these
questions
The table/entity which contains the foreign key is the Many side and
the table/entity which contains the primary key is the one side.
ALways remember this
No matter what keep this in your mind
Normalisation
Normalisation is very similar to the E-R diagrams however, in
normalisation this is organising already recorded data in the most
efficient way possible whereas E-R diagrams are made before data is
recorded
Usually groups of data in a flat line table or a stand alone table may
have repeating groups and other inefficient things. Normalisation
helps to break the single table to several tables called entities and
links them together
There are 3 steps in normalisation:
1 NF or 1st Normalisation
The relations can't have repeating groups and so repeating groups are
removed
Repeating groups are when the attributes have more than one set of
the same values
Like the below example
Newton HR $28
Xian Accounts $25
Jobdetails
Department
Accounts
HR
Employeedet
Department Surname
Accounts Donaldson
HR Newton
Accounts Xian
As we can see the 2nd table has the repeating groups for the
department field but not for the pay rate. So this ensures data
redundancy is minimized as possible and it is very significant in large
sets of data where many attributes have repeating groups
Also we can see the 1st table could be called the Jobdetails entity
which the department field acts as the Primary key. The
Employeedetails entity is referenced to the Jobdetails entity by using
the foreign key department
So again by using the rule, the place which has the foreign key is the
many sides and the one with the primary key is the one side
The relationship is one to many
Another point to remember is that the foreign key of the
Employeedetails entity is department but what is the primary key. As
the department field is not unique it is not enough to uniquely identify
each record. So we need to define another key as a primary key.
The last name can be used as the primary key. However, we use both
the departments and the last name as primary keys. This is because
the foreign key of the new table must be also the primary key. So we
will use the surname and departments as both primary keys
2 NF or 2nd Normalisation
A rule in the relational database model is that non-key attributes or
the other attributes must depend fully on the primary key or keys.
This means we must be able to identify each record uniquely
depending on the primary keys only
However, sometimes the other attributes may not be dependant on
both primary keys but only a single primary key. This is known as
partial dependancy
I just realized the example above is very poor and just focus on the
method. So I will state that the Country and city are dependants on
the surname but not on the department key
The 2nd normal form removes any partial dependency and it must be
already in the 1 NF to do this
Jobdetails - Surna
Department
Accounts
HR
Accounts
Surname ori
Surname Country
Donaldson USA
Newton UK
Xian China
As we see we made a separate table so that the country and the city
are dependant on the primary key only. In the Surname origin table
the primary key is the surname. Now in the previous table, the name
changes from Employeedetails to Jobdetails - surnameorigin
This example is completely fictional and i just created it.
Now in the 2nd table(jobdetails-surnameorigin) both the Surname and
Department keys are foreign keys as they link between the two tables
They are also both Primary keys
The relationship is many to one
This is the same as the link entity method to display a many to many
relationship logically/practically
3 NF or 3rd Normalisation
Again back to the point that the non key attributes must depend only
on the primary key.
Sometimes the non key attributes could be dependant on another non
key attribute
For example the city depends on the country and so the 3rd normal
form removes any Transitive dependancy(non - key dependancy). So
a 4th table is made
Surnameorig
Surname
Donaldson
Newton
Xian
Countrydeta
Country
USA
UK
China
o External level
This is the level used by the external users of the data in the
database. Where they store and retrieve data without any
knowledge of the structure of the database. They have access
rights to control which data they are able to access
The employees in a company use this level
o Conceptual level
o Internal level
DBMS Software
This software controls the whole database and allows the DBA
to create tables and the external usere to store or retrieve data
In other words the DBMS software handles the internal
operations of the database
Usually the DBA doesn't require to know SQL to be able to
create the databases or to access or store data
The Developer interface provides an interface for the DBA to
create the structures easily
The Query processor is a special software which is used to
retrieve/ manipulate data in the database
You will need to know the features provided by the DBMS
software
1. Performs daily and incremental backups
2. Sets access rights for each user
3. Validates data when entered - maintains data integrity
4. Indexing function to access data faster
5. Data dictionary - which gives the detal of how the data in
the database are stored in the physical memory to the DBA
Indexing
A small secondary table which contains an
attribute of unique values so it can point to the
tuple of the table much faster
This concept makes accessing data from a large table much
faster
A separate table called an index table contains an attribute of
the table which contains unique values(candidate key)
We usually use the secondary key for this , so the index table
points it to the corresponding tuple for fast access
SQL
We need to learn some scripting of the SQL language
SQL is divided into two categories
DDL
We will see an example
Creating Database structures:
CREATE DATABASE ClientDatabase;
DML
SELECT DOB
FROM Clientdetails
WHERE Client ID = 2345;
So this will return 23/7/2002
We need to select which field name you need to
be displayed and from which table and also the
where statement gives us the condition or else the
whole DOB attribute will be displayed
SELECT DOB
FROM Clientdetails;
Has no condition so it displays all the values in
DOB attribute/field
We can also display all the fields using the *
SELECT *
FROM Clientdetails
WHERE ClientID = 2345;
So this displays all the fields in the table
clientdetails
o Updating/Changing existing
data
Summary
I will give a small summary of each keywords
CREATE - DDL for creating databases or tables
DATABASE or TABLE - DDL used for defining
the name
ALTER - DDL change the structure of an
existing table such as adding a new field/attribute
ADD - DDL used in adding new fields
INSERT - DML inserting new data to a table
VALUES - DML order of the values to be
inserted in to the corresponding fields
SELECT - DML retrieving data
FROM - DML Identifys from which table
WHERE - DML conditions
GROUP BY - DML groups displayed data
ORDER BY - DML orders displayed data
INNER JOIN - DML used to compare field
values from two different tables
UPDATE - DML used to update a table
SET - DML sets a field to a value
DELETE - DML deletes a record from a table
Bac k Ne xt
Recommended
These are things you might like. Clicking these
ads can help us improve our free services in the
future...
Watch
Loops, Selections,
Arrays & Loops
Basic algorithms won't be taught here
You need to know what an algorithm consists of:
1. Assignment
2. Sequence
3. Selection
4. Iteration
Sometimes assignment is not include as a separate point. So the Sequence ,
Selection and Iteration is the most important parts of an algorithm
Structured English
This is a different form of representing an algorithm
The program is written using command words such as SET and DO
Let's see an example:
This is in pseudocode
INPUT Number
Total←0
WHILE Number <> -1 DO
Total←Total+Number
INPUT Number
ENDWHILE
OUTPUT Total
In structured english:
ENTER Number
SET Total to 0
WHILE Number Not equal to 0 INCREMENT TOTAL BY
Number,ENTER Number
DISPLAY Total
You will need to know some points
For assignment
SET X to 36
INCREMENT X BY 1
For selection
IF A IS GREATER THAN B
THEN
.....
ELSE
.....
For Repetion
REPEAT UNTIL A IS GREATER THAN B...
WHILE A IS GREATER THAN B ...
For input and output
OUTPUT A
DISPLAY A
INPUT A
ENTER A
Assignment
When you assign a value to a variable this is called assignment
x ← 20
We use an arrow in pseudocode to show that it is an assignment, the equal sign (=)
is used in conditions and for comparisons
Totalling is a specific part of assignment
As totalling has the same principle but, the value is incremented by a certain value
x←x+1
However, x must be first initialised to 0
Identifier table
Most questions asks you to draw an identifier table for your algorithm or code
This means to draw a table which contains the list of variable used in the program
and their corresponding purposes and datatypes
This is a simple example
Identifier Table
Total REAL
Count INTEGER
DoB DATE
Selection
Selection is when the output or code to performed depends on a certain condition
being true
IF (condition)
THEN
OUTPUT (statement)
ELSE
OUTPUT (statement)
END IF
This is in psudeocode and this is known as the IF statement
Notice how it is indented and also the keywords like IF are uppercase
If statements can have many condition to compare - for example if you want to
check condition 1 and if it is false then check the second condition
IF (condition1)
THEN
OUTPUT (statement)
ELSE
IF (condition2)
OUTPUT (statement)
ELSE
OUTPUT (statement)
END IF
END IF
This is simialr to an OR boolean condition
So the program will check the next condition if the previous one is false. If
condition 1 is true it will not check the 2nd condition.
Also this is not Nested if statement
Nested If Statements
Is an If statement within the if statement
IF (condition1)
THEN
IF (Condition2)
THEN
OUTPUT (statement1)
ENDIF
ELSE
OUTPUT (statement2)
END IF
This ensures that both condition 1 and 2 must be true to do statement1
So first it checks the first condition then the second condition - Infact this is the
same as an AND operator condition but, an order to it
Case Statements
This is used when there are many conditions and a single output for each
CASE OF (Variable)
(value1):(OUTPUT)
(value2):(OUTPUT)
(value2):(OUTPUT)
.
.
.
OTHERWISE:(OUTPUT)
ENDCASE
The above code shows that the output to be performed depends on the value the
variable contains
Below is more complex example
CASE OF GRADE
'A':OUTPUT"Excellent"
'A','B':OUTPUT"Good"
'C' TO 'E':OUTPUT"Moderate"
.
.
.
OTHERWISE:OUTPUT"Fail"
ENDCASE
Rogue Value
When you need to loop a program but you don't know how times it will be running
for and to loop it until you input all the values in an unknown list - we use a rogue
value
A rogue value is a input value which terminates the loop when entered and this is
usually a value which is not common in the set of input values - example (-1)
It is better to use a while loop rather than a repeat loop because the repeat loop will
run atlEast once
So if the list is empty and so the first input value is a rogue value then this would
either complicate the repeat loop or cause an error
Let's see a simple example
INPUT Number
Total←0
WHILE Number <> -1 DO
Total←Total+Number
INPUT Number
ENDWHILE
OUTPUT Total
This totals the numbers in an unknown list which the list ends with -1
FLOW-CHARTS
We will not discuss flowcharts as it is simple and just requires you to convert the
psueduocode in to a graphical manner
You wiil need to know the shapes used for each type such as for conditions and
outputs
1D Array
This is used to store data of the same data type, we need to know how to declare an
array
DECLARE (Arrayname):ARRAY[x:y] OF DATATYPE
Data type means whether it was REAL or STRING..
x and y are the boundaries, x usually start with 1 but, it could also start with 0
If we need to modify a value in the array:
Arrayname[i] ← 20
Where i is an integer(index)
More about arrays will be talked in the next chapter
Linear search
This program must be remembered as they usually ask this
This is used to find a value in an array
i=0
FOUND = FALSE
MAX = 5 // This is actually the upper index
INPUT Search
REPEAT
i ← i+1
If Array[i] = Search
THEN
FOUND ← TRUE
END If
Binary search
This is an A2 topic so we will discuss this later
Bubble Sort
In order for contents to be sorted in an array we could use some functions to do
this, however we need to know the method used and so remember the code below
NEW ← MAX-1
INPUT ArrayName
FOR COUNT ← 1 TO MAX-1
FOR i ← 1 TO NEW
If ArrayName[i]>ArrayName[i+1]
THEN
TempVariable ← ArrayName[i]
ArrayName[i] ← Arrayname[i+1]
ArrayName[i+1] ← TempVariable
END If
ENDFOR
NEW ← NEW-1
ENDFOR
Another point to remember this code is used to order from lowest to the
highest(ascending), if you want to switch it just change the conditions
We will explain the above code:
So we first enter the array to be sorted
The reason why we use two loops will be explained
First inside the inner loop, the value in an element is compared with the next
element. If the current element is larger than the next element then the values are
swapped using a temporary variable as shown above
This gives us the idea that this sorts from Lowest to highest (ascending)
Moreover, the loop increments i to repeat the process and make sure the first
element is compared with all other elements
The reason why we use MAX - 1 is that we only need to compare the elements one
less than the number of elements in the array or else a value out of the array will be
compared
The inner loop makes sure that the highest value is gone to the end of the array.
After one cycle has passed the program must repeat the process, this is because one
cycle only makes sure that a single value is gone to the end(highest value). There is
the new value(which was before the second element)and now it is at the top(but
this depends)
To make it more efficient(this is important) we do not have to compare for each
element in the array every time, this is because we know that for the first cycle the
highest value is at the end. So for every cycle, we can compare one less of
elements for every cycle
That's why we use NEW-1 , the code will still work if you don't put that but, it will
compare the whole array and sometimes this is very inefficient if the array is very
large
This is a more improved version and in my opinion I think you should use this
NEW ← MAX-1
INPUT ArrayName
REPEAT
SORTED ← TRUE
FOR i ← 1 TO NEW
If ArrayName[i]>ArrayName[i+1]
THEN
TempVariable ← ArrayName[i]
ArrayName[i] ← Arrayname[i+1]
ArrayName[i+1] ← TempVariable
SORTED ← FALSE
END If
ENDFOR
NEW ← NEW-1
UNTIL SORTED = TRUE
So this checks until the array is completely sorted and there is no more sorting
done then obviously this means the array is already sorted and so this will end the
sort when the sorted variable is true
Text Files
We will need to to know the pseudocode and python for how to read and write files
Appending Files
This is used when you need to add something to an existing file
OPENFILE "Doc.txt" FOR APPEND
WRITEFILE "Doc.txt","Hello"
CLOSEFILE "Doc.txt"
The only thing which changes is the mode(append)
Reading Files
OPENFILE "Doc.txt" FOR READ
READFILE "Doc.txt",Variable
CLOSEFILE "Doc.txt"
The variable stores the string or line which is read from the file.
Remember this only records a single line from the file and everytime the file is
read, it reads the next line
If we want to read the whole file - line by line then we use:
OPENFILE "Doc.txt" FOR READ
WHILE NOT EOF("Doc.txt") DO
READFILE "Doc.txt",Variable
OUTPUT Variable
ENDWHILE
CLOSEFILE "Doc.txt"
The EOF() function checks whether the end of the file is reached. If the end is
reached then the function will return true
Closefile is required
Python uses the same principle but, it doesn't have an EOF function and so it is a
bit different
Usually these text files are asked with built-in functions so let us see what are built
in functions
Built-in Functions
These are some built-in functions used in pseudocode and in python. You will get
this sheet in the exam however, you need to know the ones for python
Built-in Functions
Purpose Psudocode
Slicing
This is to obtain part of the array or the string
Let's take an example and use the word MR Beast
MR Beast
Each character is separated and has its own index where the first character is index
1
When we use LEFT("MR Beast",4) we should get "MR B"
This means from the start, take the first 4 characters
When we use MID("MR Beast",4,2) we should get "BE" - so we start at the 4th
character and take the next two characters
When we use RIGHT("MR Beast",4) we should get "East" - so this starts 4
characters before the end
In python it is a bit different
Truncating Numbers
The INT(x) function only takes the whole number part of the real number
Example if we take INT(56.6) then we would get 56 not 57
Random Function
The random function is used to generate any integer between two values, inclusive
RANDINT(0,20)
So this program returns an integer from 1 to 20 - it is different everytime
In python:
randint(0,20) or randrange(0,21)
Bac k Ne xt
Recommended
These are things you might like. Clicking these ads can help us improve our free
services in the future...
Try out
Remember these videos are handpicked by me and I feel these are the best ones out there.
But I constantly update this list for each chapter. The Youtubers are more than welcome to
contact me.
Also, don't forget to Subscribe to our Youtube channel - Wiscus
Watch
Procedures,
Functions, Record
Types & 2D Arrays
1D Array
We have seen what is an 1D array in the previous chapter
We will see how to access the elements in a 1D array
FOR i ← 1 TO 10
OUTPUT Array[i]
Array[i] ← 0
ENDFOR
This code first outputs the elements in the array and then sets the value of each
element to 0
2D Array
We will see how to declare them
DECLARE ArrayName:ARRAY[1:10,1:20] OF STRING
This creates an array which has 10 rows and 20 columns and which can store only
string values
If we want to store a value in the 2D array
ArrayName[1,5] ← 20
This stores the value 20 in 1st row and the 5th column
If we want to access the elements in the array
FOR Row ← 1 TO 10
FOR Column ← 1 TO 20
OUTPUT ArrayName[Row,Column]
ENDFOR
ENDFOR
This displays all the elements in each row, row by row
Modules
These are functions or procedures which are able to do a sub task. These could be
broken to further procedures and functions
Functions
A block of code which performs a specific task and returns a
single value
You will need to know how to write them
FUNCTION
functionName(parameter:datatypes,parameter2:datatypes) RETURN
DATATYPE
.....
RETURN Value
ENDFUNCTION
Procedure
A block code which performs a specific task and can return
either one or more values or no values at all
PROCEDURE
ProcedureName(parameter:datatypes,parameter2:datatypes)
.....
.....
.....
ENDPROCEDURE
To call this:
CALL procedureName(arguments1,argument2)
This doesn't return a value but values(parameters) are given to perform a task and
output the result
Modules are considered to be self-contained and so the variables in the modules
have no link with the main program
Let's see an example
PROCEDURE Totaller(value1:REAL,value2:REAL)
DECLARE value3:REAL
value3 ← value1+value2
OUTPUT value3
ENDPROCEDURE
CALL Totaller(Num1,Num2)
Any variable created in the module, it must de declared inside the module
This reduces the size of the main code and make it easier to build a code
Also as, premade modules are tested it makes the code more reliable
Record Type
These are also called userdefined types
These variables are very simialar to a record which can store different types of data
of a particular item in one variable
In A2 we call it an instance and we use classes to implement these
So the variable can store many properties(field) of a particular item
We will see how to create a record type
TYPE RecordName
DECLARE FIELDNAME:DATATYPE
DECLARE FIELDNAME:DATATYPE
DECLARE FIELDNAME:DATATYPE
DECLARE FIELDNAME:DATATYPE
.
.
ENDTYPE
At first, even I was confused. But it's actually pretty simple
This defines a record. The fieldname defines a specific property of that particular
record.
Let's take an example
TYPE Studentdetails
DECLARE Name:STRING
DECLARE Age:INTEGER
DECLARE DateOfBIrth:DATE
ENDTYPE
So this record format tells us what a variable defined in this record type must have.
So it is divided to age and all
Now if we declare a variable using the record type
DECLARE User1:Studentdetails
This is why it's called a user-defined type
So the variable John can store 3 different types of information under one identifier
User1.Name ← "MR Beast"
User1.Age ← 28
User1.DateOfBirth ← "7/5/1998"
This is very similar to an array but can hold different datatypes under one identifier
and there is more structure to it than an array
Also remember that record datatypes are composite datatypes
Actually in advance python this is very similar to a dictionary in python
Abstract Datatypes
A collection of data with associated properties
These are not actual datatypes but they are an idea or a concept
This is more of an A2 topic but, you need to know the basics
There are three types of abstract datastructures :
o Stacks
Stores data in way that the data retrieved was the first one stored.
This is similar to the FIFO principle
So the data entered recenty will eventually be retrieved over time
o Link lists
This has no proper order in which how data is stored or retrieved. This is
defined by the user itself by using another array to define the order
We will talk about it more in A2
Bac k Ne xt
Recommended
These are things you might like. Clicking these ads can help us improve our
free services in the future...
Try out
End of Chapter Videos
Remember these videos are handpicked by me and I feel these are the best ones out
there. But I constantly update this list for each chapter. The Youtubers are more
than welcome to contact me.
Also, don't forget to Subscribe to our Youtube channel - Wiscus
Watch
Stages of Software
Development
Features provided by a IDE or IDLE
There are some features provided by an IDLE editior which helps you to create
programs more easily:
o Pretty printing
This color codes or changes the style of the code for keywords and other
components such as functions,comments and identifiers which helps us to
identify each type easily
o Context-Sensitive prompt
The editior checks for syntax errors even before the code is run and alerts
the user
These are used to collapse codes such as functions classes or similar code to
a single line so it can help reduce the code in the editor and make it easier to
scroll
o Debugging
IDE provides debugging features such as breakpoint to help debug the code
o Analysis/Requirements
Identifying the problem and the purpose of your program. Also the
requirements it needs such as hardware and software
These stage identifies the efficient solution to the problem the
algorithm offers. The problem can be solved by either breaking down
the large problem to smaller sub problems(stepwise refinement) or
expanding on a subproblem to create the full complete
program( bottom - top )
o Design
This stage deals with the design of the solution(algorithm) and any
datastructures and identifiers that are used.
In order words, this deals how the code must work
This is also the stage where the code is written in pseudocode or
represented using structured charts
o Implementation or Coding
o Testing
After the code is released for the users to use, errors and bugs may
arise and also the program may have to improve on somethings
Analysis
Not required in detail
Design
This stage deals with how the code must be written
Usually the solution or the algorithm must be wriiten in pseudocode
The program may contain sub-tasks called modules and a structured chart is
used to show the link between these modules
For example , if your program was to perform additions of two numbers,
then one module could be used to enter the two numbers and the other
module could be to calculate the total ( Just remember this is a very simple
code ).
So the structured charts is the graphical representation of how data should
flow from one module to another
So the Input module can take two values and send it to the totalling module
If you don't know what are structured charts, I recommend you to watch the
video section below which explains the key things in structured charts
A thing to remember is that structured charts is a collection of modules
linked to each other. And so to represent it in pseudocode we need to call
the procedures
Coding
This is very simple and involves writing the algorithm in the most suitable
language
Python is a powerful language which uses an interpreter.
It can be used to produce many games and graphics. However, we use C++
to write games. This is because C++ runs extremely fast compared to python
Testing
There are 3 Types of errors:
o Syntax errors
o Logical errors
o Run-time errors
Stub testing
This makes sure that a procedure is callable.
So the procedure contains an output statement to show that the
procedure is callable when it is called from the main program
Black-box Testing
It is used and run by a person who has not seen the algorithm
So this compares the expected results with the actual results the
program outputs.
White-box testing
It is tested by a person who has seen the program code and so the
program is tested in every aspect by using specific input data called
test data
So this is done by carefully testing the data by putting extreme,
erroneous and normal data.
Normal data - is data within an acceptable range
Extreme data - is data which are boundary values but must be
accepted/correct
Erroneous data - is data out of an acceptable range. So it is considered
wrong and not accepted
Then the algorithm is traced using a tracing table which stores the
current contents of the variable as the program executes
Integration
Once the individual modules are tested by the software developers
and are error free, the collection of modules must work properly as a
whole complete system. This is known as integration testing
As this checks makes sure that data is passed to the right modules
This is done by incrementing the modules to the testing. So it makes
it easier to identify the errors between modules
Alpha testing and Beta testing
Alpha testing is when the program is heavily tested in house by
dedicated testors
In-house means testing done within the company or the organisation
Beta testing is when the program is issued to a limited number of
users which use the program for their use and reports any feedbacks
or errors to the company
Acceptance testing
Softwares which were designed for a specific customer will receive
the program and test to see if it meets their specific requirements.
This is known as acceptance testing.
If it does meet the requirements then the customer will sign off the
software completion
maintenance
maintenance could mean alot of things, so we will discuss 3 types of
maintenance
o Corrective maintenance
o Adaptive maintenance
Ammending the program so it contains
enhanced functionaility and can respond to
changes in requirements
Such as a program may have to be adjusted to meet the new
updated requirements
o Perfective maintenance
Methods/Models of Software
development
There are 3 ways the company can approach to develop
softwares:
o Waterfall Model
This is a methodology which ensures the requirement or
analysis of the program is clearly identified before the
program is built
The development occurs in stages where each stage is
completed before it goes to the next stage. This is
because the output of the current stage is the input of the
next stage
There are some advantages of the waterfall method:
1. Each step must be completed before the next step is
handled so it makes it more simpler
2. Very easy to manage and follow and easier to
understand
3. Used for small softwares where the requirements are
easier to identify.
Recommended
These are things you might like. Clicking these ads can
help us improve our free services in the future...
Watch
Data
Representations &
Data Types
In the A level Syllabus 9618, you will need to know further advance data types.
But before we go into detail, we classify the data types into 2 groups which can be
further broken down into another 2 groups
There are two types of data types:
o User-defined
These are data types that are defined by the user or the programmer itself.
This means that they are designed by users. Examples are record types,
enumerated data types
These are data types that are already defined by the programming language
itself, for example str is defined by the programming language as a string.
Each Group can be further broken to two more groups, depending on if the
data type is independent or not...
These are data types that refer to other data types. For the record type, we
can declare each field inside the record type as String, Real or Integer etc
TYPE RecordName
DECLARE FIELDNAME:DATATYPE
DECLARE FIELDNAME:DATATYPE
DECLARE FIELDNAME:DATATYPE
DECLARE FIELDNAME:DATATYPE
.
.
ENDTYPE
Examples are important to remember and they include: Sets, Lists, Classes,
Arrays, Record Types
Classes and Record Types have the same principle
These are data types that has no reference to other data types.
Examples include: Real, Date, String, Integer, Enumerated Data Type
Real Numbers
You are familiar with the concept that we use two's complement to store
numbers in the computer. There are two ways in which the computer can
store Two's Complement numbers to represent signed real numbers, not just
integers.
A thing to remember is that this has a fixed number of bits for the whole
number part and number of bits for the decimal part.
0111 0011
Has 4 bits for whole and 4 bits for decimal
Which can be converted to:
0111.0011
7 . 1875
7.1875
It is clear how we got the 7 but how did we get the decimal part. There is a
way to do this
0111. 0 0 1 1
We convert it to denary almost the same way. You can almost convert it to
sign and magnitude form and do the same thing
1010 0100 → 11011010
1 | 101.1100
which is also -5.75
There is no fixed position for the decimal point or a fixed defined number of
bits for whole and decimal. So we use something called the mantissa and the
exponent
Do you remember the concept of scientific notation 1.6*10 -19
The same is for floating point...
Let us convert the value 5.75 to floating point representation
First we write it in the sign and magnitude form
5.75
0101.1100
then put in the decimal point to either 0.1 when positive and 1.0
when negative
0.101 1100
so the dot moves 3 sides left
then exponent part must have the value of 3
in other words:
0.1011100 * 23 gives us 0101.1100
The answer is overall 0.1011100 for mantissa and 0011 for exponent
The decimal doesn't necessarily have to be in the form of 0.1 or 1.0 for
example:
01.1000 for mantissa 0010
means *22
0110.00
which is just 6
In this case, this called the non-normalised form or the mantissa is not in the
normalised form
This normalisation is not the same as the one in databases
If it is in the normalised form then it must be either in starting with 0.1 or 10
not 11 or 00
For small numbers, the exponent is negative and when you're handling with
negative numbers, you must always convert them to two's complement:
0101000 for mantissa 1110 for exponent
Remember these are always in two's complement so for the exponent 1110 it
is -2. So must be multiplied by 2-2
0.00101000 then convert to denary which is 0.15625
If the value is negative it is the same principle but we put it to 1.0
I always found converting to small negative values to mantissa very hard. So
let us try out one:
10100010 for mantissa and 1110 for exponent
So this means 10100010 * 2-2 but how do we go back, a principle you need
to remember is that adding leading 1's to a two's complement negative value
doesn't change its value. For example 1000 is same as 11000, both gives -8
111 | 1010010 convert to sign and magnitude which is 100 |
0101110
It is important that you put leading 1's first then convert to sign and
magnitude. Then move the decimal point 2 left so you get 1.0
1 | 000101110 is a very long negative small decimal place which you can try
to find...
Precision & Range
You don't need to go that in depth, all you need to know is:
1. More bits for mantissa, higher the precision
2. More bits for exponent, higher the range
Usually there is a compromise between these two factors
The main problems comes when the number stored is highly precise so it
can not be represented causing a rounding error, also if the value is too
great, it can cause an overflow error and make the system crash
Types Mantissa
File Organisations
There are 3 types of files:
o Serial Files
These type of files has no ordering of data within the files and so data is just
appended at the end of the file. The only order is the time order it was
entered in so it is very useful for recording measurements of a sensor or
recording bank transactions of a person
These are never used when data is required to be searched and read from
o Sequential Files
These type of files has data ordered using a specific order by using a specific
unique key. When searching data from this file, each line must be read line
by line and only the unique key is compared or else it will be very slow
This is used in Banks to record customer details and the balance called the
master file
If there is a new record or line of data to be added it must be put into the
specific order using its unique key
These files have direct access to a specific line or record of data in the file.
There is no need for a sequential search for the record line by line
How this works is that the data itself has a unique value in which can be
processed by a hashing function to produce a hash address. which is used to
store the data
Random files are used for batch processing and for validating usernames
and passwords of a person as it is faster and has approximately the same
access time for any size file
The Hashing Function will be discussed later...
o Combinational Circuits
This is a combinational circuit that is designed to add 2 bits and give the
sum and the carry bit. So there is 2 inputs and 2 outputs
We can take the summing and the carrying section separately and construct
it using basic logic gates.
The Carry bit can be represented using a simple AND gate as both inputs
must be 1 to make it 1
The Sum bit can be represented using an XOR gate. It easy to draw a xor
gate, but questions may construct the XOR gate using other gates.
Full Adders
They are used to add a series of bits together. For example, 2 binary
numbers that have more than 1 bit each.
So it is two half adders combined to make a full adder. The full adder takes
3 inputs, the two input bits and a carry input bit from the previous carry
output bit. This will output the new carry out bit and sum bit
Note that you can get the impression that full adders are part of sequential
circuits but they are not. There are no explicit links between the input and
output points
o Sequential Circuits
o SR Flip flops
You can use either a NOR or NAND gate for this but the most common is
the NOR Gate
First note down these rules:
NOR GATE:
When one of the input bits is 1 then Output is always 0
When both are 0 then Output is always 1
Please look at the logic gate below
Truth Table
A B
0 0
0 1
1 0
1 1
We will ASSUME that initially the output bit Q is 1 and Output bit for Q is
0
Remember that we always need the previous values Q and Q to continue the
tracing or truth table for the system. Below is the truth table
Truth Table
R S
0 0
0 1
1 0
1 1
It's always better to have an order or fixed flow of data. Start from the top R
which gives Q and then it goes down and compares with S to give Q. Better
to remember it like this!
Also Note that the Q and the Q is used in the next cycle for the new sets of
R and S. Remember that R is compared with Q and S with Q. This may
change depending on different diagrams
The flow is a ZIG ZAG movement from previous Q to next Q
There is a rule you need to remember and that is that Q and Q must be
inverted so both can not be the same. Then why is the last condition both 0.
This is in fact an errornous state where the bits are invalid. There are
measures taken to prevent both S and R being 1 or else this is an error
o JK flip flops
More advanced version of the SR flip flops and this has 3 inputs as it has an
additional input called clock or pulse
We usually use NAND gates for JK flip flops. So let us see the truth table of
a NAND gate
Truth Table
A B
0 0
0 1
1 0
1 1
Only when both inputs are 1 the output is always 0
So if one of the inputs are 0 then the input is always 1
Let us now see the truth table for JK flip flops
It is not required to have 8 columns as we will only see the outcomes when
the clock is 1, If it isn't 1, the JK flip flop is inactive or not started
Truth Table
Clock J K
1 0 0
1 0 1
1 1 0
1 1 1
You can't trace the first set of Q and Q as they are given
The meaning of toggle is somewhat confusing, it means the value of Q
and Q is switched from the previous Q and Q states. This means if the
before state is 0 for Q and 1 for Q then the value for Q is now 0 and Q is 1
Booloean algebra is written using special notations such as . for AND and +
for OR and Overline for Complements or NOT
It is required that you memorise this table
Laws
Identity 1.A=A
Null 0.A=0
imdemponent A.A=A
Inverse A.A=0
Distributive A+B.C=(A+B)(A+C)
Absorption A(A+B)=A
De Morgan's A.B=A+B
Some laws are hard to predict such as the distributive law, we will prove it!
(A+B)(A+C)
A.A + A.B + A.C + B.C
A + A.B + A.C + B.C
//USE ABSORPTON LAW NOW
AS A(1+B)=A
A + A.C + B.C
A + B.C
Solving and simplify boolean algebra are like normal algebra, you do not
have to put A.B but can write it as AB. All the complex laws are derived
from the top laws, so please remember the basics
K-MAPS
Is the Graphical method for simplifying boolean algebra or logic circuits
Most of the time, they will give a truth table and tell us to draw the K-Map
table. To do this we need to understand the sum of products
You know that the truth table considers all the outcomes of a logic gate.
Likewise the sum of product is the sum of all possibilities in a written form.
For example, look at the AND GATE truth table
Truth Table
A B
0 0
0 1
1 0
1 1
I will not show the diagram of this truth table and we will use Boolean
Algebra to simplify this
Forming the Sum of products
Simplifying using Boolean Algebra
Let us see another example where we can use K-maps
ABC + ABC +ABC +ABC
The place where is it NOT then we consider it as 0
The format is very important for the K-MAP table as the order on how you
arrange matters. So remember it is 00 01 11 10 for two input on one side
Also you only can circle pair or 1's that are in groups of 2, 4 or 8 or 16 and
that's all. In the above example, there are 3 groups of 2's.
You always take the highest group number rather than splitting them
In some scene, we can circle from one side and continue on the other side as
it acts like a cyclic shift like this
Also you can't circle diagonally like this
Internet &
Networks
There are two ways in which data can be transmitted. It can either be broken down
to smaller bits or packets and be sent along many routes but, all of the packets will
reach the same destination or we can just send the data in a continuous stream
along a single route or wire
o Circuit Switching
Disadvantages
1. More slower and takes more time at the start before transmission to verify
and set up links. However, speed is a hard factor to conclude on
2. More Expensive to maintain or use
3. If connection fails no other alternatives
Remember that these questions can come in different way. They may be ask
this directly or they might ask it indirectly. For example, they can ask you the
advantages of a leased permanent wire
Packet Switching
Data broken down to packets in which are sent along
many routes that reach the same destination
Think of a parcel which contains 3 items. I can ship the 3 items separately to
the same address along different routes or use the single route
The same principle applies for packet switching in which data is broken
down to packets and in which each packet has an ip address to direct it to its
destination.
Disadvantages
1. Bits can get easily corrupted
2. Shared Bandwith
When we decide which one we chose we always consider if the data to be
sent is confidential and must be error free and must be sent in the same order
as arrived. Then we use Circuit Switching. If we don't need these
requirements and want to send a normal large file over the internet, the best
is packet switching
We have come across the basic stuff in the AS level, this chapter will cover
the most advance sections in Networks.
It is Router's responsibility to make sure that the data packets are sent to the
correct destination through the best route. So each router has its own routing
table which holds the network address of it adjacent routers and there
condition ( whether active or not ) and etc
It is important to remember what is in a routing table:
1. Next hop address ( Adjacent Routers )
2. Subnet Mask
3. Network ID ( Current Router )
4. Outgoing Interface
Protocols
A protocol is a set of rules in which both the sender and
the receiver follows when transmitting data
The most famous protocol is the TCP/IP protocol but, this is called a
protocol suite as it has many layers. We will discuss each layer in detail:
TCP stands for Transmission Control Protocol
o Application Layer
This layer handles the type of message of the data to be transmitted. The
way we determine the type is by changing the port number of the data
packets but what do you really mean by different types of data?
Many Protocols that are under this layer are the HTTP, FTP, SMTP POP3,
IMAP etc protocols
Remember protocols are a set of rules. HTTP is a protocol, so is an IP
protocol but both have different functions and HTTP is a subset protocol of
the main protocol TCP/IP suite protocol. Each Protocol in the Application
layer will be further discussed
o Transport Layer
Controls and handles the breaking of data into packets and making sure the
headers of the data packets have the correct details. Some examples are the
TCP protocol
I know it's confusing when the TCP protocol is within the TCP/IP Suite
protocol but really the TCP/IP suite is a protocol that handles all data
transmission across the internet. Whereas the TCP and the IP protocols are
two independent protocols in the suite
o Internet Layer
Controls the movement of data packets within the networks and between the
routers until it reaches its source destination. Some examples are the IP
protocol which is responsible for sending data depending on the IP address
in the data packet header.
o HTTP
o FTP
o POP3
The Pull protocol is used to extract emails from the server to your computer.
Same as downloading emails on Gmail onto your computer...
However, these emails are not stored on the server. And can only be stored
on your computer which is not exactly Gmail...
o IMAP
It stores the emails on the server itself so it can be accessed where ever you
want if you have an internet connection. For this reason, IMAP is better and
popular and the recent version
However, the server may have full access to the emails so they can be
deleted or leaked so it is less secure
Nevertheless, Gmail and most email services offer both IMAP and POP3
I forgot to mention this when they say, why do we use encryption like SSL for
the Application protocols. Always mention the word "secure" like secure file
transfers and secure email transfers
Ethernet Protocol
Remember, it is a protocol. That handles and avoid data collisions
you may remember the CSMA/CD from the AS section, there is a bit more
you need to include in your answers when they ask you to describe how the
ethernet protocol avoids collisions
1. A collision is when the voltage rises to a peak because both signals
combine
2. Checks or listens to the Activity of the line.
3. It waits for a random time if the line is busy which increases every time
it's busy. So the random time increases
4. Also, send a jamming signal
5. If free, data is sent and there is a continuous check for other signals
6. Data is sent to devices using MAC / Network addresses
It is good to remember that the ethernet protocol is part of the Datalink or
Network layer as this suggest that down the layers of the TCP/IP protocol it
is mostly hardware
Ethernet Protocol is further broken down into other 4 layers
Top most layer that is responsible for the transmission of data between the
device and the network layer. It is also responsible for the integrity of data
o MAC
The MAC protocol is responsible for assigning the mac address to the
header of each packet and handling errors due to collisions
o PCS
The Physical hardware responsible for sending data and receiving data
To make it easier to understand, let us take a laptop connected to the internet
using an ethernet cable. The First 3 layers are done inside the laptop itself
and the last layer is only the cable...
Uses the processors hardware such as use of registers and logic gates to
execute instructions. So they have a hard-wired control unit
It has a reduced simple instruction set as it handles very simple instructions
Executes very simple and reduced instruction which takes one clock cycle to
execute
Uses mainly the registers to store data
Uses Fewer addressing modes and fixed length instructions
Supports pipelining which we will discuss later
Pipelining
The idea of pipelining is to make more efficient and faster way to execute
instructions. Each instruction can be broken down to five steps:
1. Instruction Fetch
2. Decode
3. Operand Fetch
4. Execute
5. Write Back
In pipelining, each step is handled by a separate unit within the processor.
So multiple steps could be done simultaneously. For this reason, pipelining
is a form of instruction level parallelism
Make note that a single instruction is divided into separate steps and handled
by different units.
We will discuss an example now:
Note the image is a 6 stage pipelining system. You only are required to know
the 5 stage one
So for the first clock cycle, one step of the 1st instruction is processed. Then
in the next cycle, the 2nd step of the 1st instuction is processed and the 1st
step of the 2nd instruction is processed
In another way, for each clock cycle, there are many parts of different
instructions processed. It is important you understand the basics of this table
above and how it increases the speed of the processor. Alternatively, there
are 5 units proccesing each step, the speed is 5 times faster so if a processing
of instruction with no pipelining is 0.1 then with pipelining it is 0.02sec.
This is an average as there are 5 instructions completed every 0.1 so we
assume it takes 0.02 but no need to go that in depth
Limitation of Pipelining
The main problem is that previous instructions may have to be fully
completed for the current instruction to be executed
For example:
A←B+C
E←A+2
So this shows the first instruction must be completed to give the value for
the 2nd instruction. Usually, this could be improved by changing the order
of the instruction to make it more efficient
Note that this problem is called data dependency and cause bubbles or holes
to form in registers called stalling until the previous instruction is fully
completed
Another big problem is when there are interrupts generated by the CPU. In
this case, the contents of the first 3 clock cycles are erased to load the base
address of the ISR which can cause disruptions. If there many interrupts,
there must be ways to avoid this...
Computer Architecture
This will discuss the types of processors:
o SISD
o SIMD
o MISD
o MIMD
Virtual Machines
These are not actual hardware systems but software systems. A virtual
machine is a system that is able to host a different environment. The Virtual
machine is hosted by the host OS. This is the original OS of your system.
The Virtual machine is able to host many other guest OS that runs within the
host OS. See the diagram below.
The software between the host OS and the Virtual Machine Software
handles communications and signals between the host OS and the virtual
machine.
The Guest OS handles any request between the guest software ( software to
be tested ) and the virtual machine. It also handles any virtual hardware
The Host OS handles any request between the virtual machine software and
the actual hardware of the computer. Note that there is a specific path of
data flow.
A very good example is JAVA. JAVA is a virtual machine that emulates a
new environment. For you to run Minecraft ( testing software ) you need to
run and have JAVA installed
Process Scheduling
The reason we need this is because the cpu can only handle one instruction at a
time. This is an important thing to remember which means that an algorithm must
be used in order to decide which process or instruction is to be loaded to the CPU.
This type of scheduling is called low-level scheduling.
The other type of scheduling is high level scheduling in which a decision must be
made on what process can be stored in the main memory from the hard drive. Note
that the Main memory can hold many processes or instructions but it is a small
number as the storage of Main memory is small
What is a process?
This is the AS level definition
An execution of a program
This is the definition for A2
Process States
There are 5 stages of a process in which we will discuss about:
o New Stage
In this Stage, the process has just entered the main memory and is getting its
associated data ( PCB ) to be ready to be running
o Ready Stage
The Process is ready to start running and performing it's task
o Running Stage
o Terminated
A good thing to remember is that the process must exist in the memory for
the cpu to access it as the cpu has direct access to main memory only!
For the above diagram, an interrupt can be generated to move the state from
running to ready or another input/output interrupt can be generated to move
the state to the waiting state
o Non-Preemptive
This does not consider the priority of each task and does not halt the process
half way but makes sure the full process is completed and then the next
process is fetched
This is very time consuming and can be sometimes inefficient. For example,
the cpu may have to wait for the printer to send signals and stay idle as it
can only handle one task. So this does not allow for multi tasking!
o Preemptive
Does consider the priority of each task and uses interrupts to halt processes
and multitask. Which means each job recieves a time slice to execute the
process.
Page Faults
Interrupts are generated all the time in the processor especially during the
end of a time slice. However, there is a special type of error
If the processor requires a process, then it must be present in the Main
memory as discussed before. If it is not present in the main memory then
this condition is called a page fault. An interrupt is generated so the process
is to be fetched from the virtual memory. If it is still not present, then the
process can not be executed
Disk Thrashing
This is a very interesting situation and somewhat very easy to understand
When a large job is loaded from the virtual memory to the main memory
and the loaded job needs to load another job from the virtual memory, in
some cases both can't fit inside the main memory. But both jobs are
dependent on each other and both must be loaded in the Main memory. But
the Main memory can not do that and so there will be swapping of the two
jobs between the Virtual and Main memory and as both are dependant on
each other, this will lead to infinite loading called disk thrashing. Disk
Thrashing could also occur for finite swapping but it is usually very large
Compiling
We have discussed compilers in the previous chapters. Here we will see the
steps of compiling. There are 5 steps in compilations and these 5 steps fall
under 2 categories
o Lexical Analysis
In this stage, the comments are removed, and also whitespaces and errors are
detected and removed. Also, the identifiers and operators are separated and
identified using tokens that are stored in the keyword table.
For example:
A + B = Total
A, B, Total + and = are lexemes
Look at the other example:
Total = (A*B)+C
Total = ( A * B ) + C
Each lexeme is a separate item
o Syntax Analysis
BNF
This is Similar to the Syntax Analysis. In this, it handles the format of data
Some notations you need to remember are:
| The Or Symbol
<Variable> is an item
::= Assign or equals to
For example:
<Letter>::=A|B|C|D
<Number>::=0|1|2|3
<Password>::=<Letter><Letter><Number><Number>
So in this case the password must start with 2 letters and have 2 numbers
So AC12 is a valid password but, AH12 is not as H is not an
option in letters and also AHE2 is not valid as it must have 2
letters and 2 Digits also. Finally AA2 is also wrong
Is 33AA a valid password
See Answer Here
Recursive BNF
If the person is able to enter as much as data items they want then they can
use a recursive function. For example if the password must start with a letter
but can have many digits or letters after that we show it like this
<Password>::=<Letter><Letter><Letter>|<Password><Letter>|
<Password><Number>
The above shows the password must start with 3 letters and stop or continue
adding futher digits or letters. Think of it as a value. Once the password has
3 letters it can be used as a new variable again and added with digits or
letters
Is AAAA a valid password
See Answer Here
Syntax Diagram
A Syntax diagram is the graphical representation of the BNF form. BNF is
written in words where as in Syntax diagrams we need to draw diagrams.
Below are the corresponding diagrams for each BNF notation or symbols
To show a recursive BNF then we use the one for constant above
o Code Generation
o Code Optimisation
This makes any improvements in the code to increase efficiency and reduce
memory usage. For example,
LDD A
ADD B
STO C
LDD C
ADD E
STO E
#THIS IS A COMMENT
Could be simplified to this to reduce memory usage and lines of code
LDD A
ADD B
ADD E
STO E
Encryption &
Digital Signatures
Encryption is the process of converting a message to a form that can not be
understood. We need a key to encrypt the message and a key to decrypt it. The
Message before encryption is called the plain text whereas, the message after
encryption is the ciphertext/cypher text
Types of Encryption
There are two types of encryption:
o Symmetric Encryption
The same key is used to encrypt and decrypt the message. Only the sender
and receiver should know the key. The key is usually 256 bits long but the
main problem is transferring the key from the sender to the receiver. So if
the key is intercepted everything is compromised
o Assymetric Encryption
A key is used to encrypt the message and a different key is used to decrypt
the message. But one key is hidden and the other key is known to the public.
The key known to the public is called the public key and the key that is
hidden is called the private key
Any key could be used to encrypt the message or decrypt the message but in
each condition, it will be different.
In order to verify the source of a message or to make sure the message came
from a trusted person, then the sender would use his private key to encrypt
the message and the sender's public key is known to everyone and they can
decrypt the message and prove it's from that person as the private and public
key pair is a match
In order to send a message so it can be read by that person only then we use
the reciever's public key to encrypt the message and so only the receiver
will be able to decrypt it using their private key
The main problem is verifying whether the private key is actually the senders.
We can prove the public key matches with the private key but how do we
know that the private key is some else pretending to be the sender
To illustrate this point, let's consider a website that is pretending to be
Apple.com. You will be able to communicate with them but you can't
authenticate them. So to get around this we need a digital certificate
Digital Certificate
A Digital Certificate is not an actual hardcopy certificate. It is a certificate
that holds the details of the owner's public key that is verified by a trusted
3rd party called the CA.
The Below diagram explains how a digital certificate is made
1. First, the details of the owner and his public key are given to the CA
2. The CA will verify the owner that requested the digital certificate using
the National Card
3. The CA will encrypt the holder's public key using the CA's private key to
form the digital signature
4. The digital certificate is sent to the holder and he puts it on his or her
website
5. When a person views this website, he accesses the certificate and uses the
trusted CA's public key to decrypt the digital signature to get the websites
public key to start communicating
Digital Signature
What's the difference between a digital signature and a digital certificate?
Digital Signature is the encrypted hashed message
Message Digest is the hashed message
Now another thing that is important in security is duplication or making sure
that the message is not altered. In this case, we need the idea of a message
digest. Below shows the steps of transferring data
1. Data is hashed to form the message digest. A Hashing algorithm makes
sure the message is converted to a fixed length of data
2. The message digest is encrypted using the sender's private key and this is
the digital signature formed
3. The Hashing Algorithm is sent also
4. The Digital Signature is received and decrypted using the sender's public
key to get the message digest. The message digest could be used to get the
actual message.
5. The actual message is hashed using the hashing algorithm again to form
the message digest
6. The two message digests are compared to see if they match. If they match
then, the message is not altered
Understand that we use the message digest to prove that the message is
unaltered
Quantum Cryptography
These use light through special medium or wires such as fiber optics to
encrypt messages
Yous don't have to read this paragraph as it is a highly advance explanation
In Quantum cryptography, light signals are sent at different polarisations
of light. We know light waves are transverse waves that vibrate
perpendicular to the energy of the way and it is clear that in most
diagrams, the waves vibrate up and down but, actually in the 3d world,
they can vibrate horizontally or even diagonally. According, to
Heisenberg's Uncertainty principle, the exact position and momentum of
a wave or particle can not be known due to the wave-particle duality.
which means if a hacker tries to intercept the fiber optics and tries to
measure the polarisation of the light he himself destroys the message and
does not allow it to pass. The idea is that the act of measuring can cause
data to be destroyed
The basic idea is that the polarisation of the light is hard to determine
without destroying the message itself and so it is highly secure
1. It is non-repudiation or can not be altered
2. More secure or harder to tap
3. Can be used to send longer keys
Quantum Cryptography is used heavily in the symmetric encryption process
and is used mainly to transfer the key for symmetric encryption. I will
explain how this key is transferred and is considered to a be secret code
Explanation of Quantum
Cryptography
Both the receiver and sender decide the value for the polarisation of
lightwaves. For example, Up & Left are 1 and Diagonals are 0. The tricky
part is that this is not fixed and this is done randomly. For example, one bit
could be 0 for diagonal and another bit could be 1 for diagonal again. The
assigning process is done randomly by the sender. Then the sender sends the
polarised light (that was randomly generated and corresponds to each bit)
and also the receiver assigns randomly the polarisation basis for each bit
POSITION at the receiver's end. Now according to probability, there is a
chance that some are going to match. Then the sender will tell the receiver
the basis of his polarised value for each bit POSITION to the sender and the
reciever will see which ones are matched and tell the sender the position
where they match. The Polarisation where they match is the bits used. This
somehow creates a secret code (the key) between them only
Let me put it in an easy illustration of the similar concept. Say the sender
randomly generates 24 bit keys in a specified order only known to the sender
0110
0001
0111
...
Random order
Say the sender also randomly generates
0111
0110
0001
...
Random order
The receiver sends his set of 2 4 keys and the sender compares it and tells
which position matches. If this was done using quantum cryptography then
the hacker can't read what is sent and they don't know the position that
matches. In some cases, there can be no matches but this is unlikely
Likewise, in actual cryptography, polarisations of light are sent randomly
and are assigned with 1 or 0 and the places where they match are sent
Artificial
Intelligence
Dijkstra's Algorithm
Many textbooks give unnecessary information such as the code for Dijkastra's
Algorithm. This is unnecessary and you are only required to know how the code
works and does. Below is a summarised note on how the algorithm works
Points are considered to be nodes. Note that these nodes are graphical and
theoretical. These nodes can represent a location or destination or even a decision
to take...
1. The Starting node is set to 0 and all other nodes are sent to infinity
2. The smallest adjacent node route is considered. The value of the distance is
checked whether it is lower than the stored value of the node. It should be as the
node was inititally set to infinity. If it less then we set that current node with the
distance value \ edge value
3. Then it checks any nodes adjacent to the current node and goes towards the
lowest distance node. If the SUM of the distance (previous distance + distance
taken to move to current node) is less than the current node value, then it is
updated
4. It will show the total distance for a single route or possibility of the diagram.
Now the remaining nodes should be explored and adjusted until it reaches the end
node
5. Sometimes the values of the node may get adjusted more than once as there is a
more efficient and lower distance diagram
To understand it more, I got a small graph from the internet below.
First it records the distance of adjacent nodes and if it is less than infinity or the
previously stored value of the node, the node is then updated
It goes initially at the shortest route and then explores adjacent nodes again
A* Algorithm
This is more improved version of the Dijkstra's Algorithm as not all outcomes or
routes have to be considered
The concept is similar to the above code. However, in addition to the above, each
node has a unique coordinate. For example the start node has the coordinate 2,3
and the end coordinate has the coordinate 5,8
By applying this we can find the shortest possible distance or route it can take
which is the displacement. Here is the way to calculate the displacement between
the start and end node
(X1-X2)2+(Y1-Y2)2 = Displacement
This is the pythagoras theorem used to find distance between two points or a line.
This function is called the heuristic function
So the displacement or the heuristic value between EACH node and the end node
is calculated. This gives us the idea that the length can not be shorter than this
So when a single route has been discovered and the sum is recorded for that route,
then another route can be discovered but if the distance to that node plus the
heuristic value is greater then there is no point going further that path as the path
distance is definitely going to be larger.
I have put video to explain how it works down below
Machine Learning
The process of learning from experience to improve its
performance
There are 3 types of Artificial Intelligence learning depending on the data they
handle and their specialty
o Unsupervised Learning
o Supervised Learning
o Reinforced Learning
A system that handles both labeled and unlabelled data and learns from
experience to optimize its future task and functionality. It uses rewards to
reinforce the machine to indicate that it is getting better and better
An example would be a chess computer that rewards or punishes every
move it makes depending on how effective the move was
Regression Analysis
This is by finding patterns in large collections of past data to predict future
events or suggestions. For example, you may have done scientific
experiments where you need to draw graphs and draw lines of best fit or
curve. Using the graph, you can predict other values that you have not tested
so as long there is a trend then the machine can predict.
If it is a linear pattern ( line of best fit ) it is called linear regression, other
complex ones are called polynomial regression
An example is a school system seeing a trend between Maths and Science
Student's Marks. The higher the mark for one subject, the higher they are for
the other subject. Another popular system is Google, where they use it to
give search suggestions
Note that Categorized data means data that have some form of labeling and
can be identified or in other words, it is highly specific data
Deep Learning
It is Artificial Machine Systems that uses Artificial Neural
Network and has many hidden layers to handle very
complex task
These are the type of AI you may have watched in movies. Where there AI
specialty is clearly visible
Binary Search
Psuedocode
#Coded by Stefan Ralph | Indenting is required
DECLARE ARRAYLIST:ARRAY[1:11] OF INTEGER;
//Enter Values inside the ARRAYLIST
PROCEDURE BinarySearch(search:INTEGER,Array:ARRAY[1:10]
OF INTEGERS)
Max←10
Min←0
Found←False
NotPresent←False
while (Found=False) AND (NotPresent=False) DO
Mid←(Max+Min)DIV 2
IF search=Array[Mid]
THEN
Found=True
ELSE IF Min>= Max
THEN
NotPresent←True
ELSE IF search < Array[Mid]
THEN
Max←Mid-1
ELSE
Min←Mid+1
END IF
END IF
END IF
END WHILE
IF Found=True
THEN
OUTPUT("The position is at ", Mid," using binary search")
ELSE
OUTPUT("Not Found")
END IF
END PROCEDURE
This searching algorithm will only work for arrays that have numbers stores in it as
there must be way to compare the weight of each value in each node. This could be
improved for any sorting by converting characters to ASCII values but for school
knowledge, this is enough...
Python Algorithm
The code is in python for this algorithm
The code is free for anyone to copy and use...The copied code must have the same
code and indentation as above
Linear Search
Psuedocode
//ARRAY ALREADY DECLARED AND STORED
Found←False
INPUT SearchValue
INDEX←0
REPEAT
INDEX←INDEX+1
IF ARRAYLIST[INDEX]=SearchValue
THEN
FOUND←TRUE
END IF
UNTIL (INDEX=(LENGTH(ARRAYLIST))) OR FOUND=TRUE
IF FOUND=TRUE
THEN
OUTPUT "THE VALUE IS AT ", INDEX
END IF
//LENGTH FUNCTION COULD BE USED IF THE MAX
BOUNDARY OF ARRAY IS NOT KNOWN
Only the location of the first occuring match is found...This code is fully
explained here
Python Algorithm
The code is in python for this algorithm
The code is free for anyone to copy and use...The copied code must have the same
code and indentation as above
Bubble Sort
Psuedocode
#Coded by Revise Zone | Indenting is required
//ARRAY IS ALREADY PRESENT AND RECORED
SWAP←FALSE
MAX←10
n←MAX-1
//This means that the array has only 10 items
REPEAT
SWAP←FALSE
FOR COUNT ← 1 TO n
IF ARRAYLIST[n]>ARRAYLIST[n+1]
THEN
TEMP←ARRAYLIST[n]
ARRAYLIST[n]←ARRAYLIST[n+1]
ARRAYLIST[n+1]←Temp
SWAP←TRUE
END IF
n←n+1
UNTIL SWAP=FALSE
This sorting algorithm will only work for arrays that have numbers stores in it as
there must be way to compare the weight of each value in each node. This could be
improved for any sorting by converting characters to ASCII values but for school
knowledge, this is enough...
Python Algorithm
The code is in python for this algorithm
The code is free for anyone to copy and use...The copied code must have the same
code and indentation as above
Insertion Sort
Psuedocode
#Coded by Revise Zone | Indenting is required
//ARRAY ALREADY CREATED AND STORED , THE RANGE IS
FROM 0 TO 9
FOR POINTER 1 TO (MAX)
ITEM←ARRAY[POINTER]
Current←POINTER-1
WHILE ARRAY[Current]>ITEM AND Current>-1 Do
ARRAY[Current+1]←ARRAY[Current]
Current←Current-1
END WHILE
ARRAY[Current+1]←ITEM
END FOR
OUTPUT ARRAY
This sorting algorithm will only work for arrays that hae numbers stores in it as
there must be way to compare the weight of each value in each node. This could be
improved for any sorting by converting characters to ASCII values but for school
knowledge, this is enough...
Python Algorithm
The code is in python for this algorithm
The code is free for anyone to copy and use...The copied code must have the same
code and indentation as above
Linked List
The python code is approved and is functioning properly...
Psuedocode
#Coded by Revise Zone | Indenting is required
TYPE NODE
DECLARE Data:STRING
DECLARE:Pointer:INTEGER
END TYPE
DECLARE List:ARRAY[1:10] OF NODE
//TO INITIALISE THE ARRAY
Nullptr←-1
Freeptr←0
Startptr←Nullptr
FOR i ← 0 TO 9
List[i].Pointer←i+1
List[10].Pointer←Nullptr
END PROCEDURE
PROCEDURE POP(DATA)
//START AT THE TOP
CheckNode←Startptr
WHILE CheckNode<>-1 AND List[CheckNode].Data <> DATA
Previousptr←CheckNode
CheckNode←List[CheckNode].Pointer
END WHILE
IF CheckNode<>Nullptr
THEN
IF CheckNode←Startptr
THEN
//Makes it unaccessable
Startptr←List[Starptr].Pointer
ELSE
List[Previousptr].Pointer←List[CurrentNode].Pointer
END IF
List[CurrentNode].Pointer←Freeptr
Freeptr←CheckNode
FUNCTION FIND(Search)
Checkptr←Startptr
WHILE Checkptr <>-1 AND List[Checkptr].Data<>Search DO
Checkptr←List[Checkptr].Pointer
ENDWHILE
RETURN Checkptr
END FUNCTION
PROCEDURE ACCESS()
Checkptr←Startptr
WHILE CheckPtr <>-1 AND List[Checkptr].Data<>Search DO
OUTPUT Checkptr
Checkptr←List[Checkptr].Pointer
ENDWHILE
Python Algorithm
The code is in python for this algorithm
The code is free for anyone to copy and use...The copied code must have the same
code and indentation as above
Combined
Algorithm
Python Algorithm
The code is in python for this algorithm
The code is free for anyone to copy and use...The copied code must have the same
code and indentation as above