0% found this document useful (0 votes)
281 views

Computer Science Notes

This document discusses key concepts related to binary numbers, data representation, and arithmetic. It defines terms like most significant bit (MSB), least significant bit (LSB), and discusses how to convert between binary, decimal, and hexadecimal numbering systems. Two's complement representation for signed integers is explained, including how to convert between sign-magnitude and two's complement forms. Properties of two's complement and binary arithmetic operations are also covered at a high level.

Uploaded by

Kimberly
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
281 views

Computer Science Notes

This document discusses key concepts related to binary numbers, data representation, and arithmetic. It defines terms like most significant bit (MSB), least significant bit (LSB), and discusses how to convert between binary, decimal, and hexadecimal numbering systems. Two's complement representation for signed integers is explained, including how to convert between sign-magnitude and two's complement forms. Properties of two's complement and binary arithmetic operations are also covered at a high level.

Uploaded by

Kimberly
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 226

Graphics, Sound,

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 number = 111111102


You keep dividing by 2 until we get the final value as 0. Then we read the remainders from
bottom to top
We will also talk about the next method also
These requires you to know the binary weight properly such as 1 , 2 , 4 , 8 , 16 ,
32....
This is very useful to convert a decimal number to a binary number (This is an A2
topic so we will discuss that later)
254 - 128 → 1
126 - 64 → 1
62 - 32 → 1
30 - 16 → 1
14 - 8 → 1
6 - 4 →1
2 - 2 →1
0 - 1 → 0 // as 0 is not large enough to reduct 1
from it
For this method we read from top to bottom
It is better to chose one method or else you would get confused

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

Hex to denary (Vice versa)


There is a method to convert hex to denary and back directly but I won't
recommend it to you
Its better to convert denary to binary then Hex ( vice versa ) as this is more simpler
and less error prone

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

Internal Coding Numbers


The computer follows two's complement when storing numbers
There are two types of integer which the computer can store - unsigned and signed
integer
Signed integers are integers which can be either positive or negative whereas
unsigned integer is always positive

Sign and Magnitude


This is the common form when we display signed integers
The Most significant bit determines the sign ( 1 - negative and 0 - positive ) where
as the rest of the bits define the magnitude
For example 10110110
The Most significant bit is 1 and so this is a negative number
If we convert the rest of the bits to denary 54 which is the magnitude
So this byte represents -54 only if this byte is a signed integer
If it is not a signed integer we just use normal conversions like the above examples
So most questions give the byte in a sign and magnitude form ( unless they state
the form ) and this must be converted to two's complement
They might ask like this
Convert this signed integer to 2's complement -
10011110
Remeber this is in sign and magnitude form
Before you know how to convert it we need to first define 2's complement

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

Here's the catch!


The computer follows 2's complement and so sign and magnitude numbers must be
converted using the above method
However you use this method only when the sign and magnitude is negative, infact
this is a very confusing part
If the binary number is positive then the sign and magnitude is the same as the
two's complement form
Lets see an example:
Convert 01101111 to 2's complement
The answer is again 01101111 and we will see why later
Convert 10010010 to 2's complement
So for this we need to use the above method and so you will get 01101110
However this is not the answer because the first bit(MSB) is changed from 1 to 0
and so it will become a positive number
For this reason the Two's complement should have the same sign as the sign and
magnitude form
The final answer must be 11101110

Why do they follow this


There is a reason why they follow this wierd method and it's because it makes
converting from Two's complement to denary much quicker and direct
To convert a 2's complement to the corresponding denary value can be done by
reversing the process such as finding the sign and magitude form and then finding
the denary value
Or
There is another simpler method
The below binary value is in 2's complement. Find the denary value
11011010
The most significant bit is 1 so the number is negative
We know that the MSB carries the highest value of 128
The method follows like this:
First find the value of the sign which is negative and then add the positive value of
the magnitude(remaining bits)
-128 + (64 + 16 + 8 +2 ) = -38
As the MSB is 1 then the value would obviously be negative
This is the easiest and fastest method
So this makes sense why the sign and magitude of positive number is the same as
the two's complement
The below binary value is in 2's complement. Find the denary value
01011010
By following the same method above we will get 38
I don't know if textbooks follow this explanation but in my opinion this is the most
simplest explanation I could give

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

BCD - Binary coded decimal


Denary digits are represented using nibbles or 4 bits
4 bits can be used to represent a single denary digit from 0 to 9
If the nibble contains a value of more than 9 then it is called an invalid BCD
There are 2 types of BCD - packed BCD or one BCD per byte
In packed BCD it means that 2 digits of denary can be represented using 1 byte,
whereas in one BCD per byte only one digit is represented(the remaining bits are
0's)
Example, Packed BCD - 11011001 and One BCD per byte - 11010000
So how do you convert it to denary digits
For example 00100111 is a packed BCD
We can break it to two nibbles
0010 1001
Each nibble could be converted to the corresponding denary value

0010

This gives a value of 29


If the nibble had a value of more than 9 then it is invalid
BCD is used to display denary digits in calculators and watches
You also need to know how to perform calculations and addition with BCD
When we do addition with BCD we isolate each nibble such as the example below
29 + 45

0010 1001 (29)


0100 0101 (45)
____ ____
0110 1110
0110
0110 (1)0100

0111 0100 (74)


We can see that 1110 that this is an invalid BCD 1110 which has a value of 14. So this must
be corrected by adding 0110 or 6

So to correct this we need to always add 0110 or 6


We can see after adding 0110 we get a carry of 1 which taken to the next BCD and
added
If the next BCD also was invalid then we had to add 0110 and 1 = 0111 and there
will be a carry to the next BCD

Internal coding of character


There are two ways which text and characters can be represented

o ASCII

American standard code for information interchange


Originally ASCII uses 7 bits to store each character(this is known as the
ANSI ASCII)
The bits required to store each ASCII character are known as character
codes
This could be used to represent 128 different characters which is enough to
represent the english set and numbers and other command keys
The new ASCII is called the Extended ASCII as it is used to represent
modified alphabets such as the ISO - Latin characters
This uses 8 bits or 1 byte to store each character and this could represent 256
characters
This is still not enough to represent other characters from different
languages

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

Graphics made out of drawing objects and their associated


properties
So these drawing objects are shapes
A drawing object is component which is defined using
geometric formulae
This follows a very simple idea, the image is made up of shapes or
components which are defined using a drawing list
A drawing list is a list which contains one set values that
contains many attributes for each drawing objects
So the drawing list contains a list of attributes which defines a property of
the drawing object
A property is an aspect of the appearance of the drawing
object
An example of the property includes the radius or the color or the border
Vector graphics are stored in the SVG format and requires a graphic plotter
to output them directly
Vector graphics are relative to the canvas and so it is scalable without geting
distorted and pixelated
Also when image is scaled both the dimensions are scaled so the image
doesn't get squashed or stretched
Another important point is that vector graphics uses a lot of processing
power however less storage compared to BMP graphics and it is also used to
represent simple images such as shapes
If an vector graphics must be displayed on a screen or printed then it must
be be converted to bitmap form

o Bitmap Graphics

An image which is made out of elements or components


called pixels which stores a color and its position in the
BMP matrix
The pixels are displayed in a 2D matrix where the color of each pixel and its
position in the 2D matrix is stored
Pixel is the smallest component which is identified using its
color and position in the 2D matrix
So each pixel can represent a color and the number of bits required to store
each pixel is known as color depth
Color depth is the number of bits required to store each
pixel
The color depth of the pixel determines how many possible colors the pixel
can represent
For example 24 bit color depth means that 2 24 colors can be represented
Some questions use the word bit depth for images and this means the
number of bits required to store each primary color
For example if you have a bit depth of 8 bits it means it requires 8 bits to
store each primary color of RGB and so the color depth will be 24 bits
Bit depth is the number of its required to store each
primary color
So back to BMP images it is made of many tiny pixels in a 2D matrix. To
find the number of pixels in a image we need to find the product of the pixel
high and pixel wide of an image, this is known as the image resolution
Image resolution is the product of the number of pixels
high and number of pixels wide an image is
In a simpler terms, it means how many pixels are there in an image
The same concept could be applied for display screen
The screen resolution is the product of the number of
pixels high and number of pixels wide the screen can
display
So whatever we see through the screen, it is limited by the screen
resolutuion - for example if the screen is 2K but the image is 4K we will
only see a 2K image

There are some points on Bitmap graphics - it uses the file


extension .BMP(raw file) where as the compressed versions are .PNG
and .JPG
Also the bitmap images can be enlargened but, when we enlarge the image
even the pixels are enlarged and so the image seems pixelated and distorted
Bitmap images are good for storing photographs and pictures but uses way
alot of storage

Image file size


They will ask us to calculate the file size of an image
We find the number of pixels(using the image resolution) and multiply it by
the color depth
File size = Resolution * Color depth
Even bit depth could be used but we need to then multiply by 3
File size = Resolution * Bit depth * 3
Depending on what you took for the color depth ( if we took it in bits ) then
the file size will be in bits
In my opinion it's better to use bytes as you may have to convert it to MiB
Let's take an example
What is the image size if the pixel height is 500 and the pixels wide
1000 and the color depth is 24 bits
File size = Resolution * Bit depth * 3
Resolution = Pixels high * pixels wide
File size = 500 * 1000 * 3
Notice that i used 3bytes instead of 24 bits so my final answer will be in
bytes
File size = 1500000 Bytes
To convert it to MiB we need to divide by 1024 and again by 1024

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

Sound file size


The method for calculating sound file size is also required
File size = Sampling resolution * Sampling frequency *
Duration * channels
The channel parts are usually not asked - but it could be either 1 or 2The
duration means the time length of the sound
Again if we use bits for the sampling resolution we get the answer in bits
Duration must be in seconds

Compression Teachniques
Remember that there are two types of compressions:

o Lossless Compression

This when no data is removed and the process could


be reversed to obtain the original file - these include
RLE and Huffman coding algorithms
Usually there are two algorithms used for lossless compression:

RLE - Run length encoding is done by specifying the number of


times a character is repeated followed by the value of the character
For an example AAAAAAAA - 8A
RLE is not strictly marked as it is the concept which matters, usually
RLE can be in Hex or Binary and the order of the representation
doesn't really matter - so 8A is same as A8
Huffman coding - this replaces the most frequently used characters or
words with shorter codes
Huffman is known by many other names such as indexing, dictionary
Usually we have a table which contains the character which is being
replaced and their shorter codes
Huffman coding can be used for sound also to replace most frequent
amplitudes with shorter codes

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

When defining each type of compression give an example for each

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

It is Network connecting computers on different


connecting sites which can be 1000's of Km wide.
That is why this is called a wide area network
This is owned by the PSTN ( company ) but can be leased or used by an
organisation
The transmission medium is fibre optics
Communications with in the network is done by switches. You don't need a
router for this as a switch contains the mac address of the device connected
to the switch.
A router is bit more advance but we will talk about it later

o LAN

The lan is a network connecting devices in a single room or


building
An example - Office uses
So this is owned by the organisation and it enables communications with in
the building or room
The transmission medium used are wireless or twisted pair
There are many advantages in setting up a LAN as this enables
communications within computers
For Example you can communicate with your collegues without actually
accessing the internet
Also Centralised servers such as application servers and file servers can be
connected to a LAN so the people can access files or softwares from these
servers rather than installing the software to each individual computer. This
makes it more efficient and cheaper
These centralised servers highlight a very important model called the client-
server model.

o Internet

Is the largest network linking computers from


geographical separate locations. It stands for
interconnected network
This definition is very important infact, they usually ask what's the
difference between internet and WWW
All we have to know is that internet is the largest or a massive network
which connects networks together such as WAN. It also uses the TCP and
IP protocols.
The reason why other networks don't use this protocols as the internet is a
interconnected network and so it links computers of separate locations. This
must be used in order for data to be sent to the correct location

Client server model


You only need to know these points

o One computer acts as a server and it provides a


specific service or application.

o One computer acts as a client which sends requests to


the server and receives the services

This model is very important as they usually ask this.


Lets take a simple example .You may know the app Google drive
So Google drive helps you backup data or files onto a (file) server. This is the
service provided by the server and the client is the browser or you. This is a
specific type of service called cloud computing services
The client server model can be broken into two categories

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

Peer to peer network


This is fully covered in A2
In this model there is no fixed server or client. Whenever a computer wants
to retrieve data it is called a client or a seed. If another computer wants to
access data from it, then it acts as a server.
So in this model parts of the document is stored in individual computers and
it is not stored in a centralised server.
In other words the services are shared.
Advantages and disadvantage
Indeed each model has its own advantages and you need to remember this as
exams ask this

Advantages of Client-Server model


So as all the applications are stored in a central server. This improves the
security of data and allows access rights. So users will be able to acces data
if they are authorised to
We can also perform centralised backups
Store a virus guard to protect the data
Much more efficient and cheaper as the services doesn't need to be installed
on individual computers

Advantages of Peer to peer network


So usually the data is spread over many computers
Part of the documents can be accessed rather than the full file
It avoids congestion of the medium to the main server as not everyone will
be accesing the main server simulataneuosly.
And usually there are copies of data from many hosts

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

Data is sent in one direction only


Example is a radio station
o Half-Duplex

When data is sent in both direction but one direction at a time


Example is a walkie talkie

o Duplex

When data is sent in both directions simultaneously


Example is playing online games. The internet is basically duplex

Broadcast and more..


Message or data can be transmitted different ways. If data is sent by a single
device to all the devices in the network it is broadcasted.
If data is sent to many destinations but selected it is multicast.
If data is sent only to a single device it is unicast

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

A single transmission medium between two devices


Think of a leased wire. This is actually a point to point network as you only
can communicate with the other device only.
o Bus topology

Endsystems or devices connected to a shared link.


So in this a single shared link is used to connect device to this network

o Mesh topology

It contains direct links with in the devices.


Think about it. If you have 3 devices , one device can communicate directly
to the other 2 and its the same for the other 2 devices. In this data can be
sent only to a single device or all

o Star topology

Devices connected to a central device


Think of a router. Usually all the devices are connected to this central device

Advantages and disadvantages

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...

End of Chapter Videos

Collection of Videos to Support Your Understanding.

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

Twisted pair Low High

Coaxial Cable Relatively high Lo

Fibre Optic Highest Low

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

Radiowaves Lowest High

Microwaves Medium Med

Infrared Waves Highest Low

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

Practical uses of Wireless and Wired


transmission
Wireless transmission is used in connecting mobile phones to the WAP
It is used in Lan networks to reduce the amount of cabling but usually we use
twisted pair for LAN networks
Wired transmission is used for internet communications and also telephone
communications

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

A device which connects two segments of LAN. It records


the Network addresses of the devices in each connected
segment.
For example if we want to extend a bus topology with a star topology we
could use a bridge and a repeater to produce a larger LAN and a hybrid
network.

o Switch

A central device which is used to connect devices in a star


topology which can send a unicast message
So for commmunications within a particular network such as a WAN we
don't need a router. All we need is a switch
The switch is the advanced version of the hub as it provides more features
than the hub. The hub is also used as a central device but the message is
usually send to all the other devices. This causes data collisions and thus
corruptions

o Server

Is a computer which provides a specific service or an application


o Network interface card (NIC)

This is not a device but actually a component in a device


which uniquely identifies a device on the internet. It
contains a hard coded MAC address which is a 48 bit code
in hexadecimals

o Wireless Network interface card (WNIC)

This provides the NIC function in a wireless network

o Wireless Access point (WAP)

A central device used to connect device to a wireless


network
A good example is a wireless router
However for the WAP to communicate with the device it must have WNIC
This is specially used in cell phone networks

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

Each router acts as a node

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.
.

Nowadays Modern ethernet we don't use this method because a switch is


used instead of a hub
The Switch can end the message to the required device. Also the switch
contains a buffer which can temporarily store data until a transmission
medium is freed. So then it can send data without collisions
Remember that usually the LAN network follows the star configuration.

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

Public switched telephone network


(PSTN)
As we know that the PSTN is an infrastructure of the WAN network and it
is owned by a company
So the PSTN owns the infrastructure which was original used for telephone
communications which now is used as the infrastructure for the Internet.
The transmission medium is fibre optics.
There are some important things you need to know.

o The PSTN can send both analogue signals and digital


signals

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 The PSTN doesn't need power for


telecommuniciations but requires power for internet
commmunications

As analogue signals can be transmitted without power.

o A dedicated line is made for Telecommunications

Whenever you're in a call a dedicated line is made temporarily between the


two telephones. However the internet uses a concept called package
switching where data is transmitted in the most appropriate route, decided
by the router

Application which uses the internet


You will need to know some applications which makes use of the internet

o World wide web WWW


It is a distributed application which contains
documents in the form of webpages structured in to
websites which has been made available for anyone to
access
Usually they ask what is the difference between the WWW and the
internet.
So the WWW does not follow any protocols (Ex IP/TCP) and it
stands for World wide web. Also it is not a network but an
application which contains documents and data

o Cloud Computing

Computing service provided through the internet


These services are like file servers and application servers (Ex Google
Drive)
There are 3 types of Cloud computing services and it could either be
public or private
Private Cloud: Cloud servers owned and maintained by organisations
and are used by the organisation only.
Public Cloud: Cloud servers which are used by the public for general
use
The establishment of the cloud server on a particular location must be
known
The 3 types of services which are offered by public clouds:
1. Infrastructure provision - These include the hardware requirements
of a computer system and so these can be used to back up files or
store data or provide requirements to execute a particular software
2. Platform provision - These provide debugging services to be able
to run softwares on different platforms for testing.
3. Software or application provision - similar to a application server
as it contains softwares which could be used by the user

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?

During streaming data, data is sent in sequence of bits


from the media servers to the receiver through the internet
and is temporarily held in a buffer until it is played by a
media software.
The above one is a brief explanation and so you need to include more points
1. There are two types of bit streaming - on demand and real time bit
streaming
Real time (live feed) bit streaming is when the bits are transmitted as soon
as it is captured and recorded
On demand bit streaming is when bits are streamed at a time chosen by the
user
2. In bit streaming data is compressed from bytes to bits and decoded at the
recieving end and so the order of bits sent is same when received
3. The buffer has a high watermark and a low watermark which maintains
the amount of data stored in the buffer.
4. The bandwidth of the connection is higher than what is being played by
the media softwares.
5. Requires bits to be sent at high speeds to avoid buffering
The above points are enough to score full marks

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

These are Ip addresses which remains permanent and doesn't change.

o Dynamic IP address

Changes whenever you log out and connect to the internet

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.

Classless Inter domain routing


(CIDR)
In this scheme they use network IDs and host IDs however they were not
arranged into fixed classes.
At the end of the IP address there was an 8 bit suffix to define the number of
bits for network ID.
This made it more flexibe as the organisation can get the Ip addresses which
are most suitable for them. So they can contain the right number of network
connections and the number of Host connected to each network.
Also now bits are not required to define the class used so this allows more
space for Host and Network IDs
Remember the above explanation are for organisations which uses a large
number of networks. These include access ISP and Tier1 ISPs.
For example if the Middle Tier 1 ISP had many access ISP connected to it.
It will use a IP address which have a high number of bits for Network ID
and somewhat reasonable number of bits for Host .

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

Domain name server (DNS)


We will need to know some definition

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

Collection of Videos to Support Your Understanding.

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

Input & Output


Devices
Data input and output
There are many examples of input devices such as the scanner, keyboard and more
- if data is send to the the system from a device this is a considered as an input
device.
There are many examples of output devices such as speakers and storage devices -
if data is sent out by the processor it is an output device

General and special purpose computers


General purpose computers are computers which are used in day to day life like
your laptop
They can be used to do a variety of jobs such as watching videos and games
There are also computers which are the size of chips and are usually installed on
large devices such as a car
These are known as embedded systems or special purpose computers which are
able to perform a specific job or function
As usual a computer must have a processor and I/O system and a memory unit.
Usually this is built in to one chip and is usually called a microcontroller.
Embedded systems are usually installed on devices to connect the devices to the
internet and provide more functions
However as the embedded systems doesn't have an Os and only some simple code,
it makes it easier to hack them

Main or primary memory


The computer has main memory which is divided to two types of main memory
RAM and ROM

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

Electronically erasable PROM


Data in the ROM can be removed using an electric signal and data can be
written to it, but this is done very rarely

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

Magnetic strips and magnetic cards


These store data on magnetic strips as there are varying magnetic field dots
across the strip.
Depending on the magnetic field the dots can either store 1 or 0
So usually a read head is used to read the data and due to the varying
magnetic fields it induces and a varying current

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

The above points are enought to score full marks


For more information - similar data are stored on different disc of the same
sectors
Data are stored in sequence on the concentric tracks

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

Data is stored in concentric tracks so data can be read or written


simultaneously
Uses red laser however the wavelength is slighlty smaller
DVD - ROM contains two discs so it can store more data
The data is read using read heads
The disc is also spin at high speeds
This also stores data in pits and lands

o CD - RW

A disc which is rewritable means that data can be burned/recorded


and also erased
The surface of the disc contains a special alloy
When the red laser in focused on to the surface the alloy it forms a
liquid which either cools down to a crystalline solid or a amorphous
solid depending on the intensity of the laser.
The crystalline solid reflects more light than the amorphous solid.
This can be decode into binary data
This process of storing data is usually known as burning

o Blu-ray

This uses a blue laser light which has a shorter wavelength


This means the light can be more focused and so the pits and lands
are closely together and so higher storage

Solid state media


This is the technology used by flash sticks and pen drives
This stores data in transistors called memory cells
This controls the movement of the electrons through the ciruits using
either NAND or NOT gates
NAND Gate is used most frequently than NOT whereas NOT gates
are very expensive
Also data in the memory cells could be all deleted and written at once

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

We will need to know some advantages of HDD over SSD


1. The main advantage of HDD is that it usually has a higher capacity
than SSD
2. Also HDD is very durable under heavy use and thus used in
gaming
3. Cheaper than SSD

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

This controls the direction of the electron to display images on


the screen
The screen is coated with a substance which when an electron
collides with it a light is produced
Each dot on the screen is made when electrons collide with the
fluorescent screen and glows
The screen is full of dots which produces an image
This is the old technology of screens and it is not used now

o LCD/LED Screens

The screens is made out of pixels however each pixel is


divided into sub pixels which have the color red green blue and
sometimes yellow
The Liquid crystal display is able to change the structure in
order to polarise light differently by passing a voltage through
it
Usually the backlighting is from LED bulbs that is why the
newer versions are called LED Tvs.
The older technology is uses CCFL bulbs as backlightings and
they were called LCD screens
The white light is able to change color as it passes through the
LCD display and so this is done by controlling the voltage
passed in each pixel
Finally there is a polariser(filter) which makes the image more
clearer and crisp

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

Virtual Reality Headset


This contain both input and output components
The displays and speakers in the VR headset are output devices which
provide the user with 3D graphics created by the CAD software
The sensors in the VR Headset are input devices which feed data
about your position and all

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

Touchscree made out of two conducting layers


where when touched causes the top flexible layer
to contact with the lower layer and so it
completes a circuit
So once the circuit is complete the microprocessor detects the
position or coordinates of the touch
This is then decode to binary
The main problem with this technology is that it doesn't
support multitouch and also the screens have to be pressed
quite hard
However, this technology works with gloves and doesn't
require hands
It is also the cheapest type to manufacture

o Capacitive

Touchscreen in which when the screen is


touched it undergoes a capactive or electric
change and this is then detected
Moreover, the screen layer conducts electricity and so can
change its electric state
When we touch the screen the electric charge is flowed from
the screen to the finger and so there is an electric change and
this is detected by the sensors on the corners of the screen
Then the position of the touch is calculated and decoded into
binary data

The good feature of this technology is that it can support


multitouch if the screen is made out of an array of capacitors,
which means the screen is divided in to cells which can
undergo its own electric change
The main problem of this technology is that it can not be used
with gloves and it requires a finger or a capacitive pen
Also the technology is relatively expensive to manufacture

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

Microphones and Speakers


The reason why I combined this is because they are basically the
reversed process
o Microphone

This is an input device


You will need to know the components in a microphone
1. Diaphragm
2. Coil
3. Magnet
When the sound is entered due to vibrations in the air, it causes
the diagraphm to vibrate and so the coil vibrates inside a
magnet
This induces an alternating current which is then converted to
digital data using an ADC convertor

o Speakers

This is an output device


You will need to know the components in a speaker
1. Diaphragm
2. Coil
3. Magnet
They have the same components however most of the time
they have extra components such as a filter and a amplifier
This is basically the reversed process. Data or signals sent from
the computer must be converted to analogue data using DAC
convertor and so then the varying electric signals causes the
coil and the digraphm to vibrate and cause sound

Rarely asked devices


We will discuss some rarely asked devices
Graphic plotter
This device is an output device which is used to display the
vector graphics on to a paper
This uses a pen which can move to draw the vector graphics
and also the paper can move. This produces high quality vector
graphics on to paper

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

Collection of Videos to Support Your Understanding.

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 &


Truth Tables &
Logic Circuits
Logic circuits are made from logic gates

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

This only has a single input, so this leads to 2 1 possibilities.


So the gate outputs the value opposite from which was entered. For example
if a 0 was entered, it then outputs 1 (vice versa)

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

It is very important to note down that if we have 2 inputs this gives us


22 possibilties and so we have 4 combinations.
Also it better if you memorise the pattern of the input values as it is very
useful.
So the first column is half 00 and half 11
The next column we have 0101

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

It can have 2 or more inputs


The Output is only TRUE if the neither the input values are TRUE.
So if one of the input values are true the output values is false.

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 need to Memorise this form of inputs


The 1st column is half 0000 and half is 1111
The 2nd column is 00110011
The 3rd column is 01010101

We create the truth table based on the number of input values the ciruit begins with
and not with the intermediate values

Logic expressions and Problem


statements
The definitions are not required to be remembered but the understanding is
important.
Usually questions gives us problem statement as the example below:
The systems reorders if the inventory level is below 10 units or if the user makes a
large order
A logic proposition is the statement which can be either TRUE or FALSE. Ex - the
user makes a large order can be true or false.
This must be converted to a logic expression which then we replace the the logic
proposition with simple variables such as:
System reorder(output) - X
Inventory below 10 units - A
Large order - B
This is like a normal simple logic gate but usually most examples contains 3
inputs.
X = A OR B
There are somethings you need to remember. By default we name the variable of a
logic proposition with a variable A - this when the value of the variable is
1.However, if we want to represent the variable which has a value of 0 (FALSE).
We must use NOT A
Lets see an example - the system sends an alarm if the chemical process is not
working - 0 or if the user has switched off the system - 1
X = NOT C OR S
The reason why we define it this way is that we expect the output X to be 1 and
usually they state this in logic expressions

Truth Table for logic circuits


After finding the Logic expression we must draw the logic circuits and there is a
simple way to do this
This is an example
X = (NOT A AND NOT B) AND C
Usually the brackets will be given but sometimes they don't give brackets such as
the below example:
X = NOT A AND NOT B AND C
In this way we read from the left to the right when drawing the logic ciruits so this
means we draw NOT A AND NOT B first then we Add the AND C. Note that I
didn't make an intermediate variable for NOT A OR NOT B as they are very easy
to do.
So when we draw the truth tables for these its best to get the intermediate values
D = (NOT A OR NOT B)
We name a new variable for the intermediate steps. Then the D AND C are
compared
X = D AND C
Usually logic cirucits are not that easy and sometimes there could be many
intermediate variables. Also you need to remember as 3 inputs are used there
should be 8 possibilites.
If we want we could make intermediate variables for NOT A - E and NOT B - F

The logic circuit

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

D - NOT A AND NOT BE - NOT A.F - NOT B


This shows that the output is only true when both A and B are FALSE and C is
TRUE

Simplifying the circuits or removing


variety
In some questions they give a logic ciruit and ask us draw the logic circuits to draw
only using a single type of Gate - NAND or NOR
There are some points you need to note:
There are infinite possibilites of replacing a gate with another gate and so there is
no proper answer. Also if you do want to find the gates used to replace a particular
gate, you can use my method
Say for example the AND gate must be replaced using only NAND gates
I know my output must be 0001
And the output for NAND is 1110
I need to see a connection between these two outputs
In other word if I compared the output of NAND gate with another NAND gate(or
more)it must give me 0001

NAND values Missing Input

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

AND Gate can be replaced using NAND Gates only


AND Gate can be replaced using NOR Gates only

OR Gate can be replaced using NAND Gates only


OR Gate can be replaced using NOR Gates only

If we need to simplify just reverse the process

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

Collection of Videos to Support Your Understanding.

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:

o General purpose register

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

o Special purpose register

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

Memory data register MDR

Index register IX

Program counter PC

Current instruction register CIR

Status register SR

The points related to CIR and SR is important

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

The CIR has many functions such as decoding the instructions to


operand and opcode. Then the opcode of the instruction is sent to the
control unit and the control unit then sends control signals to perform
the action and execute the intructions
The definitions of opcode and operand will be covered in the next
lesson

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

Arithmetical logic unit


A component of the CPU which performs arithmetical
calculations and comparisons
It is the same as ALU and contains one general purpose register - the ACC

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

More on System buses


There are more things about system buses such as the bus width and
the word. We will discus that next.
But before that we need to know where address buses and control
buses and data buses are used
Address bus - Used to transfer addresses from the CPU to memory or
the I/O. Remember this is unidirectional
Data bus - Used to transfer data back and forth from the I/O or
memory to the CPU.
Control bus - Send signals back and forth from any system
component such as the I/O or the memory or other components to the
CPU.

Factors affecting the system


performance
There are few factors which you need to know:

o Clock frequency and the number of cores

Higher clock frequency means that more activities can be done


per second and so the execution of programs are faster.
A core means an independant processor which can perform
calculations independantly. So when there are more cores it
means more calculations could be performed simultaneously.

o Word length

A defined number of bytes which the system


handles as one unit
The word length is usually same as the bus width
So the word means how many bits are sent or processed at a
time. So usually you computer has an architecture of 32 or 64
bits and this means for each cycle of the clock the CPU
processes 32 bits or 64 bits.
Usually the size of the register is equal to the 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.

o Address bus width

This is sometimes given in mark shemes so write this last.


The bus width of the address bus determines the maximum
number of memory locations.
This is why some computers has a maximum memory of 8 or 4
Gb RAM sticks

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

Fetch execute cycle


The process of instructions stored in the
memory being fetched , decoded and executed in
sequence is known as the fetch execute cycle
You need to remember these steps
1. First there is a check whether there is anymore instructions
to be executed
2. If instructions are required to be executed then the address
will be loaded to the PC
3. The address in the PC will be copied to the MAR and then
the PC will increment by 1 and the next address will be loaded
4. The MAR points to the memory address ( through the
address bus ) and the instruction will be fetched and loaded to
the MDR
5. The MDR then sends it to the CIR where it is decoded to the
operand and opcode.
6. The CU will send control signals and excute the instructions
- example load a value to the ACC
7. After one cycle is complete the CPU then looks for any
interrupt to be handled - we will discuss this next.

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]

This is very important to remember . You need to know that


the registers which data is stored to is always recorded on the
left.
Also we use [] brackets to show that the contents of that
register is transfered
Sometimes we use double brackets [[]] This is used for
[[MAR]] because to highlight that the MAR contains the
address which contains the contents or data.

The next register notation is a bit advanced and this is usually


known as the decoding stage where part of the
instruction(opcode) is taken and sent to the CU. We will
discuss this in the next chapter.
CU ← [CIR[x:y]]

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

The CPU must be able to identify the priority of the interrupt


and so there is an interrupt register which flags the interrupt
type.
Usually the interrupt service is done at the end of the fetch
execute cycle.

1. Firstly the contents of the execution is stored safe in


memory so it can be accessed later.
2. The CPU then loads and executes the start address of the
ISR ( interrupt service routine ) which handles and services the
interrupt.
3. The CPU checks for anymore interrupts (using the interrupt
register) and then repeats the execution of the ISR
4. If no more interrupts are found then the contents are
retrieved to the registers and the process continues normally.

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
End of Chapter Videos

Collection of Videos to Support Your Understanding.

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)

Assembly language programs


Programs written in assembly language uses Mnemonics to represent opcodes -
example ADD and SUB
The use symbolic names for the operands - example TOTAL
Usually a code written in assembly language will have:
1. Comments
2. Directives
3. Mnemonics
4. Labels(operand)
5. Macros
All of this must be converted or adjusted to machine code using an assembler.

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

So this uses labels or symbolic names to represent the addresses


Example is ADD NUMBER
The NUMBER is an identifier which stores a particular value in that address

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

It uses the actual address for the operand


Example is ADD 200

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.

Two pass assembler


We will need to know the steps and points when an assembly language
program is translated. Also as we usually use symbolic addressing we must
also convert the labels for the operand to offset values.
This is why there are 2 steps for this translator.

So these must be done before the translation.


The assembler will remove any macros names and replace it with the block
of code. Also any directives are removed and stored for later use. The
comments are also removed.
During the translation
The First pass of the assembler - converts the symbolic names or labels to
their offset values.
This is done by using a symbol table which contains the symbol names and
there corresponding offset values
The second pass of the assembler - converts the opcode to the corresponding
machine code using the processors instruction set
This at last converts the assembly code to machine code which is an
executable file
Addressing mode
It defines how the operand is to be used to obtain the value
or data
There are 4 types you need to know:

o Immediate

The Operand is the value to be used by the


instruction.
For example if we have LDM #34
This means that the value 34 is loaded to the ACC
Always remember if there is a #n or #Bn(binary) or #Hex then it is
immediate addressing and the value of the operand is used

o Direct addressing

The operand is the address which contains the value


to be used by the instruction
An example is ADD 100

o Indirect addressing

The operand is the address which contains a address


which has the value to be used by the instruction
An example is LDD 200
So in the address 200 there is a value of 500 which is actually another
address and the value in 500 is used by the instruction

o Indexed addressing

The value of the operand is added to the contents of


the Index register to form the address which contains
the value
For example - LDX 100 means that 100 is added to the value in the
Index register(300) so we get 400 and this is the address which
contains the value

Assembly language instructions


We have seen some of the opcodes such as ADD LDD LDM and more
We don't need to remember these as the exams always gives us the table
A point to remember is that the Mnemonics usually identifies both the
action and the addressing mode - Example LDD is for direct addressing
whereas LDM #n is for immediate addressing
There will be many Opcodes such as CMP and JMP and Bitwise operations.
They will usually give the instruction set and explain each function
The reason why they give us these is to be able to trace the assembly
language - meaning we need to update the values in the register such as
ACC and the memory locations

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

Used for multiplication and division calculations where the sign


doesn't change

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

End of Chapter Questions


Collection of Topic Questions to understand the topic more.

Try out
End of Chapter Videos

Collection of Videos to Support Your Understanding.

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

To measure the temperature of a system or to keep a chemical process at a


constant temperature. To maintain a constant temperature is a controlling
system

o Ph sensor

Usually used in testing water or liquids or the soil

o Infrared sensor

To detect motion - used in security systems

o Pressure sensor

This measures the pressure of a gas or a system


o Sound sensors and more..

These sensors are rarely asked but it's good to know


Sound sensors- used to measure the intensity of the sound
Light sensor - used to measure the light intensity
Magnetic sensor - used to detect magnetic fields(compass apps) and for
ABS systems in cars

How to answer a general question


They will ask:
Explain the monitoring process in detail
1. Indentify the type of sensor used such as Temperature sensor
2. The sensor measures the physical properties and send electrical signals,
these signals are then converted form analogue signals to digital(binary)
signals using an ADC convertor.
3. These signals are sent to a microproccesor where they are compared with
the desired or stored values
4. If the measured values are not within the desired range a signal is sent to
an alarm to alert the user and the data is stored in a system
5. If it is within the range the process doesn't do anything and continuues to
operate the system until the system is terminated

Infact the only difference between a monitoring and controlling systems is


the 4th point.
Controlling
Systems
A system which measures the physical properties of a system and send
signals to an actuator to alter the system depending on the readings

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.

How to answer a general question


1. Indentify the type of sensor used such as Temperature sensor
2. The sensor measures the physical properties and send electrical signals,
these signals are then converted form analogue signals to digital(binary)
signals using a ADC convertor.
3. These signals are sent to a microproccesor where they are compared with
the desired or stored values
4. If the results are not within the desired range then a digital signal is sent
to an actuator. The digital signal must be converted to analogue signals
using DAC convertor.The actuator will be switched on to alter the system.
5. If within the range, the process continously compares the readings to
make sure the readings are within the desired range.

Closed loop feedback system


This is quite easy to understand. This is a system or an environment which
when the actuator operates , the next reading it measures will be directly
altered by the controlling system
Think of a closed room and the A.C is switched on. The A.C will controll
the temperature of the room but if the room is open the reading measured
wouldn't be directly altered by the actuator.
So the readings which the controlling system measures are actually
feedbacks if whether the actuator is operating properly and doing its
function.

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

Each corresponding bits are compared depending on the operator used. So in


this case, we use AND, so both bits must be 1 for the final value to be 1
This can be applied for different boolean operators such as OR and XOR
Bitwise operations are used heavily in python but it is not in your syllabus

Bac k   Ne xt
End of Chapter Videos

Collection of Videos to Support Your Understanding.

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

The Os provides a interface for the user to be able to communicate or


command applications softwares to perform specific tasks
The recent interface used is the Graphical user interface which uses graphics
to represents commands.
Command line interface is know outdated as it doesn't use an graphics but it
has a very fast execution.
Both of these interfaces must be remembered

o Program-hardware interface

The Os provides a platform for the application softwares to communicate


with the system hardware. In other words, the programs requires the Os to
use the system hardware.

o Memory management

This is very important function done by the Os as it allocates the memory


for each program making sure that the memory locations don't cross and be
used by a different program. This maintains security
Also it controls the usage of memory for each program making sure the
system is running efficiently

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

When a program is executed we call it a process.


Different processes may require different requirements such as the usage of
memory and the GPU power.
Also during a process it will be interrupted as there will be many process
running and so the Os manages the CPU time slices and allocates a time for
each process.

o File management

The Os controls the creation and the management of file properties.


The path of a file or where is has been stored and how it can be accessed is
controlled by the Os
Also the Os manages the file structure - This means a file could contain
many subfolders.

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:

o Recovery tools or Disk Formatter

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

These softwares perfom automated backup at regular intervals and also


perform daily incremental backups.

o File compression softwares


The most famous example is the Winrar software which compresses the file
so it uses less storage.
This uses less storage space and thus can be easily copied or transmitted

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

Usually the source code of a program is written by the programmer in


high level language. This must be converted to a form which can be
understood by the computer.

o Low level language

These are programming languages which are closely related to


machine code.
Machine code is another word for binary code.
Compilers and Interpreters only translate high level languages and not
assembly 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

The main use of interpreters is for building a program

Featurs provided by an IDLE


This topic will be covered in the practical section as it talk about the
features which an IDLE editior

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

End of Chapter Videos

Collection of Videos to Support Your Understanding.

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

Threats to a computer system


There are many threats to a computer system and these include:
1. Malwares
2. Natural disasters
3. Hacking
Usually we need to know the reason for these threats

Reasons for the threats


There are many reasons for the threats:

o Threats due to the internet


Harmful softwares could be transmitted through the internet - These include
viruses and worms and pharming codes
These programs are called malware and it is a code which harms the
computer
Even hacking is possible through the internet and so the hacker can gain
unauthorised data from your computer or maybe delete or corrupt your data

o Threats due to the users poor activity

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

o Threats due to the Operating system

This is due to the poor security of the firewall and also due to the bad
antivirus software

Methods to maintain data security


There are many ways the data can be kept safe and secure
You will need to know these points

o Use a remote computer to backup files

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

Use of regular backups to backup data


Also making daily incremental backups
There is a method called the disk mirror strategy where data is stored in two
servers simultaneously. This makes sure if one server fails the other one has
the exact copy of the other one

o Use of passwords and biometrics

Making use of passwords and access rights to restrict access to users


The access rights is used to restrict data to authorised user
authorization means the access rights to a particular
person
Also using biometrics makes it more harder to hack

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

A software or a hardware which monitors the incoming


traffic and checks them with certain criteria
This makes sure that data is filtered and monitored
Usually the firewall maintains a log of all the undesired IP addresses
It filters data and compares them with certain rules
It can be used to prevent hacking by stopping unauthorised access

o Good practice

This is done by the user


Not to enter any unknown flash drives and not to download any files on the
internet or from emails
Also not writing down passwords on paper
Locking computers away

o Antivirus software

To download a virus guard to detect and quarantine viruses


The virus guard will make regular scans
Also the virus database is automatically updated to detect new viruses
An antispyware could also be used to remove any spyware

The reason why we need to backup data is that:


The hardware can fail
The software or system can fail
Data can be overwritten or corrupted
Location of data is lost

Verification and Validation


We will need to know what is verification and validation

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)

Verification during data transfer


You may know what partiy check and checksum is
These are both verification methods to check whether data is accurate during
transmission - as data can be corrupted due to electrical interference

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

Parity check is much simpler and usually checks a byte of data


Say if the system follows even parity, this means that the number of 1's in
the data block must be equal to an even number
If not an error has occurred - the location of the error can not be found
If no error is found this doesn't necessarily mean that data is accurate or
correct as the parity check could still work if two bits are
swapped(transposition error) or two bits got corrupted
However the possibility of that is very small and so this is considered to be
verified

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...

End of Chapter Questions


Collection of Topic Questions to understand the topic more.

Try out

End of Chapter Videos

Collection of Videos to Support Your Understanding.

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

The software engineers must keep in mind of the best


interest of the public
This includes the public good and the good of their welfare
An example is making sure that data belonging to the public is kept
confidential

o Client and Employer

Software Engineers must keep in mind the best interest of


their clients and their employers and also consistent with
the interest of the public.
A good example is making sure the software made for the client is made
with good quality and standards
o Products

Software Engineers must ensure that their products or


future updates are at the highest standard possible
Products in this sense means the paid software
An example is making sure the product is secure and fully tested.

o Judgement

Software Engineers must have good judgment and also


independent(unbiased) judgement
An example is that software developers make their own good judgment of a
particular problem or situation

o Profession

The Software Engineers must advance or improve the


integrity and reputation of their profession, consistent with
the public interest.
This includes such as removing bad practices in their profession such as lack
of hardwork

o Collegues

Software Engineers must be supportive of their colleagues


and must keep their interest also
This includes helping a staff member by teaching them and not putting them
under great pressure
o Self

The Software Engineer must participate in lifelong


learning in their profession and should promote an ethical
approach to the practice of their profession
This includes attending meetings and workshops

o Management

The Software Managers or leaders must promote an


ethical approach to the management of software
development.
This includes the management of the testing of the software and also making
sure the software is completed within the planned time.
Note that most of these points prospect for the public good - the welfare and
environment and the interest and concerns of the public.
This means using funds efficiently and protecting the environment.

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

Let us see an example


A Software Engineer of a big company has recently been aware that the
company is selling the user(public) data to advertising companies secretly.
The company has bribed you to keep your mouth shut but, you have decided
to go to the police. Explain whether this was ethical or not
Ethical. As the software engineer must look for the best interest of the
general public and also the clients.
Also the software engineer must advance the integrity and reputation of the
business before it gets any worse. However, this may destroy the reputation
of the business
Also the software engineer must have an ethical approach to practicing the
profession. This means rejecting any form of bribery. This also advances the
integrity of the profession

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

Open Source software


Another word for this is the free software
This is a software which users have the liberty to change,modify and
use the source code for their personal use.
Usually there are no copyright laws and so it is free to be distributed.
However if someone does use the source code to make other codes, it
must be also be a free software
This is quite confusing but, the software sometimes comes with a
small fee and sometimes doesn't.
The source code is send for users to do whatever they want
Plagiarism
The act of copying another person's work and recognising it as yours
The copyright law prevents people from plagiarising

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

Detecting changes in the environment(stimuli) using sensors and


being able to respond appropriately

o Linguistics

The ability to understand language and words through the use of


speech recognition

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

To be able to come up with a logical conclusion based on the


evidence. This means filtering out wrong information

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...

End of Chapter Videos

Collection of Videos to Support Your Understanding.

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

Databases maintains the integrity of the data stored by providing validation


and preventing any corrupted or incomplete data
The file just stores the data which it is being supplied with and sometimes
the data could be corrupted or overwritten

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

A Special type of table used in relational databases


o Tuple

Stores data of a particular instance or item in a relation


This is the same as a row or a record

o Attribute

Stores data of a particular property of an item or instance


in a relation
It is same as a column or a field

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

Entity relationship modelling


These are represented using E-R diagrams
An entity is an object,thing or person which can store data in fields and rows
So an entity has to have many instances or items to be displayed as a table
In relational databases the tables must be linked so the E-R modelling helps
us to find the link between the entities
The exam will us scenario where a database is required to store data
1. First we need to identify the entities
2. Identify the type of relationship. Remember one to one relationships can
be ignored

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

It means one instance is linked to one instance in the other table


o One to many(vice versa)

An example is when one band contains many members

o Many to many

We usually say it like this


One is to many and many is to one
For example like a auction center where many people can bid for a
single product(instance) and also many products could be auctioned
by a single person
Forming the relationships are required and need practice
For example what is the relationship between a BAND and the
MEMBER entities?
It is one to many
Representing this relationships in a diagram is called the E-R diagram
and they usually give alot of hints
The E-R diagram doesn't just contain a relationship between just two
entities but many entities

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

Many to Many relationships


It is very hard to represent a many to many relationship in practical
databases using foreign keys and primary keys - as then both tables
must have foreign keys which is not right
So we make an intermediate table called a link entity which joins two
entities which has many to many relationships
So the Link entity table is a separate table which has two foreign keys
which are used to link the primary keys of each entities
The two foreign keys are both used as primary keys
We will see that more in normalisation

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

Surname Department Payrate

Donaldson Accounts $25

Newton HR $28
Xian Accounts $25

We can see Donaldson and Xian have common data


The attributes or fields which have the same value are grouped
together in a non repeated table and it is linked to another table which
contains an attribute which is repeating
So the relationship is one to many
Let's see the same example. This is in the 1NF

Jobdetails

Department

Accounts

HR

So the repeating groups are collapsed together


This table is then linked to a separate table.

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

As we can see we made a separate table so the city field is only


dependant on the country field
The primary key of this table is Country and the foreigh key is in the
previous table
The relationship is many to one

Normalisation is a method and it is very tricky. But just remember


these two principles
Normal forms can't have repeating groups or any partial or transitive
dependancy
Database Management System
(DBMS)
The database management system can be divided to 3 levels

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

This is the level used by the DBA (Database adminstrator) who


creates tables and databases. The DBA is also responsible in
setting access rights for the users in the external level. The
DBA uses the DBMS software to perform these functions

o Internal level

This is the level handled by the DBMS software which


controls the storage of data in the physical storage(internal
schemes). It controls where data is stored in the storages and
this is the level where data is directly accessed or stored
DBA
This is the person who is in charge of the
conceptual level and uses the DBMS software to
create the structure of the database
There are some tasks which the DBA is in charge of and you
need to know these
1. Setting up Regular and incremental Back ups
2. Setting up the access rights for users in the external level
3. Creating databases and tables and their relationships
4. Data dictionary and indexing function could be used by the
DBA

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

o Data Definition Language (DDL)

To define the structure of the database

o Data Manipulation Language (DML)

In manipulating the data in the database such as storing


and retrieving data from the database
In reality we don't really separate the language to these
two parts
We will show an example for each

DDL
We will see an example
Creating Database structures:
CREATE DATABASE ClientDatabase;

CREATE TABLE Clientdetails(PRIMARY


KEY(Client ID varchar(10))
,ClientName varchar(25),DOB
Date,Subscription boolean);
ALTER TABLE Client-booking ADD
PRIMARY KEY(Booking ID varchar(25))
ADD FOREIGN KEY(ClientID
REFERENCES Clientdetails(Client ID);
As you can see we need to remember some points
SQL is Case Insensitive
The program statements can go for many lines but each
statement must end with ;
We use the Keywords DATABASE and TABLE only in
DDL and not in DML
So when we want to define an attribute as a primary key
we need to put it in brackets
The ALTER keyword is used to alter an existing table
such as adding a new field
For each attribute we need to define the data type,
databases don't contain the datatype STRING so we use
varchar(x) where x is number of characters
The Database follows all other datatypes except
STRING

DML

o Adding data to the table

INSERT INTO Clientdetails(Client ID,


DOB)
VALUES (2345, 23/7/2002);
There is another way of entering but this is the
correct one
The clientdetails is the table name and inside the
brackets are the field names
The values must be in the same order as the fields
in the brackets
o Retrieving data from the
database

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

If we need to have some format of displaying the


data we can either use:
SELECT DOB
FROM Clientdetails
WHERE ClientID = 2345
ORDER BY DOB ASC|DSC;
So this orders the DOB in order of the Date. The
default is Ascending Order
or we could use:
SELECT DOB
FROM Clientdetails
WHERE ClientID = 2345
GROUP BY Department;
This means that the date of birth is displayed in
groups of department
If the department has repeating groups then this
could be used

The WHERE condition could be further used to


compare field values of different tables and not
only in the same table
SELECT DOB
FROM Clientdetails
INNER JOIN Client-booking
WHERE Clientdetails.ClientID = 2345
AND Client-booking.BookingID = 2345;
So this is used to display the field value when
both conditions of two different table values are
correct
We need to use INNER JOIN to join the other
table. We also need to use a dot to show it is a
field of a particular table
Clientdetails.ClientID means the field ClientID
from the table Clientdetails

o Updating/Changing existing
data

If we need to change the existing data in the table


UPDATE CLientdetails
SET ClientID = 2678
WHERE ClientID = 2345;
So this changes the clientID which was 2345 to
2678

o Deleting data from the table


DELETE FROM Clientdetails
WHERE ClientID = 2678;
If the client is no longer in the business then we
need to delete it them from our table
This deletes the whole record which has the the
ClientID 2678
Always remember the foreign key records must
be first deleted before the primary key records are
deleted in the referenced table (referential
integrity)

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...

End of Chapter Videos

Collection of Videos to Support Your


Understanding.

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

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

Variable Name Datatype

Total REAL

Count INTEGER

DoB DATE

Studentlist ARRAY[1:10] OF STRING


If they ask you to draw an identifier table then you don't have to declare any
variables

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

Python doesn't have CASE statements but only elif

Count controlled loop


This method is used when the loop is supposed to interate for a specified number
of times and is use when the number of times is known
FOR COUNT ← 1 TO 5
OUTPUT (Statement)
ENDFOR
If you want, you can use NEXT COUNT instead of ENDFOR

Post conditioned loops


The code interated or loops until a certain condition is true and the code is run
atlEast once
REPEAT
OUTPUT (statement)
UNTIL (condition)

While loops are better especially when there is a rogue value

Pre condition loops


First it checks whether the condition is true and then loops while the condition is
true. The program doesn't have to run atlEast once
WHILE (condition) DO
OUTPUT (statment)
ENDWHILE
Conditon means such as comparing variables or checking a variable is larger than a
value. You need to know what are arithmetical operators
Also the conditions could have boolean operators such AND or OR or NOT
An example is WHILE X>3 OR X = -1 DO

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

UNTIL FOUND = TRUE OR i = MAX


IF FOUND = TRUE
THEN
OUTPUT"The value is at position",i
ELSE
OUTPUT"The value is not in the array"
END If
This is infact an easy code to remember and we could use repeat loop because the
program must run atlEast once to compare
The program checks whether the value is present in the array and loops until it is
present or if it reaches the end of the array.
If found the value is displayed

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

Create a file or write to a file


This creates a file or overwrites an existing file
We will take the Doc.txt as an example
OPENFILE "Doc.txt" FOR WRITE
WRITEFILE "Doc.txt","Hello"
CLOSEFILE "Doc.txt"
This shows that the code writes the word "Hello" to the file Doc.txt
Instead of writing "Hello" we can write using a variable which stores a string

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

We will use x as an example for a variable

Built-in Functions

Purpose Psudocode

Returns the length - returns an integer LENGTH(x)

Returns the ASCII value of a character -


ASC(x)
returns an integer

Returns the character of the ASCII value -


CHR(x)
returns a char

Returns an truncated integer - returns an


INT(x)
integer

Converts a number to a string - returns a


NUM_TO_STRING(x)
string

Converts a string to a number - returns a real STRING_TO_NUM(x)

Converts a char to uppercase - returns a char UCASE(x)

Converts a char to lowercase - returns a char LCASE(x)


Converts a string to uppercase - returns a
TO_UPPER(x)
string

Converts a string to lowercase - returns a


TO_LOWER(x)
string

Slices a string(first part) - returns a string LEFT(x,y)

Slices a string(middle part) - returns a string MID(x,y,z)

Slices a string(last part) - returns a string RIGHT(x,y)

Returns a character of a string - returns char String[x]

We will talk about slicing and INT(x) more

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...

End of Chapter Questions


Collection of Topic Questions to understand the topic more.

Try out

End of Chapter Videos

Collection of Videos to Support Your Understanding.

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

To call it from the main program


variable ← functionName(arguments1,arguments2)
This returns a value
What are these parameters and arguments, they are the same thing and these are the
values which must be passed from the main code to the modules
Also the datatypes of the parameters must be defined and also the return datatype
The parameters are entered in the same order as it is received by the procedure or
function
Another point to remember is that the variables in a module are defined as local
variables which means the variables in the module can be different from the main
program code

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

BYVALUE AND BYREF


These are used to indicate how the parameters are supposed to be used
BYVALUE means only the value is passed to the module. So any changes to the
variable has no affect in the main code
This is known as the local scope and by default python follows this
BYREF is when the value and the address of the variable is sent so any changes to
the variable inside the module affects the main program
This is the global scope of a variable. We need to use a global keyword in python
PROCEDURE ProcedureName(BYVALUE parameter:datatypes,
BYREF parameter2:datatypes)
.....
.....
.....
ENDPROCEDURE

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

There are some points you need to remember


I'm not sure why but, the exams usually expect us to do this
Whenever we transfer a value from the array to a record or vice versa, we must use
a temporary variable
Temporaryvariable ← User1.age
Agelist[i] ← Temporaryvariable
It is the same when you output values from a record. You need to have a temporary
variable
Temporaryvariable ← User1.age
OUTPUT Temporaryvariable

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

These store data in a way that data is stored in a stack


So data which is retrieved from the datastructure is the one which was
recently stored( previously stored )
In accounting terms, this is similar to the LIFO principle
So this means that the data at the start remains at the bottom until the whole
datalist is empty
o Queues

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...

End of Chapter Questions


Collection of Topic Questions to understand the topic more.

Try out
End of Chapter Videos

Collection of Videos to Support Your Understanding.

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

These provides suggestions for identifiers or the choice of keywords when


typing the code

o Dynamic Syntax check

The editior checks for syntax errors even before the code is run and alerts
the user

o Expanding and collapsing code blocks

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

Stages of Software development


We will talk about each step in depth
There are 5 stages of software development

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

This stage identifies which programming language is appropriate for


the algorithm and this stage is the where the coding is done by the
software developers

o Testing

This tests the program to check for any errors


There are many testing methods to make sure the program is error
free before it is released
o maintenance

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

We will now see each stage in detail

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

These are errors which the program statements


doesn't follow the rules of the programming language
The code may have wrong grammer or wrong keywords which are
not recognised by the language
These errors are usually identified by compilers and interpreters.
However, interpreters identify them when the line is executed, so the
whole code must be executed

o Logical errors

Error in the design of the code which gives us


unexpected results
If the program doesn't function as it is supposed to or intended to then
there is a logical error
It will give wrong or unexpected outputs

o Run-time errors

Errors which cause the program to freeze or crash.


For example division by zero or memory overflow
errors
These errors are identified when the program is executed and tested
Testing Methods
There are many testing methods which you have to know

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

maintenance in which errors/bugs are identified


and corrected
When the program is released and used by users, errors or bugs
may arise from the use of the program. This must be identified
and corrected

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

This makes sure the program is improved to


have better performance and maintainability
maintainability means the program is more efficient and easily
maintainable
Also the performance improvements could include faster
execution

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.

There are also some disadvanatages


1. It is not suitable for large softwares as the
requirements are very large
2. Not suitable for long ongoing projects
3. Can not accommodate changing requirements. It is
usually costly
4. A working testable program is made only at the later
stages of the development

o Iterative or incremental model

The software developers doesn't require to have the


complete requirement of the system but focuses on the
sub-set requirements of the system. Then there are
repeated reviews for further requirements which
eventually leads to the complete system being built
A good example is when your application receives
updates which the features of the system improves
There are some advantages you need to know:
1. There is working model of the system earlier in the
stages of development so errors and bugs are found
earlier. So this is way easier than correcting errors later
2. Parallel development can be planned
3. Less costly to change the scope or the requirements
4. Suitable for large programs which can be broken
down to sub tasks
5. Each increment produces an operational product
6. Allows customers to test the updated increments and
give feedback to the company

There are some disadvantages


1. This only can be used for softwares which can be
broken in to sub task
2. Requires more resources
3. For identifying incremental requirements it may
require you to define the complete requirement to some
degree
4. There might be errors in the design of the complete
system as the whole system requirement is not fully
understoood in the beginning
Rapid application
development (RAD)
This involves building and testing modules in parallel
and releasing them as proto-types
So these prototypes are part of the complete system and
are tested by users to see if they meet the user
requirement and feedback is given to the company
The company then improves and adjusts the module
depending on the feedback they receive and integrate
them to produce the complete system
The main difference between iterative and RAD is that
RAD requires the user(customers) involvement
throughout the complete cycle where as iterative
implements and tests each increments and releases each
increment at a time
Also RAD releases the modules as prototypes.
RAD requires very little planning and analysis as the
requirements are based on the customers(feedback)
There are some advantages:
1. Faster development
2. Encourages customer feedback as the model depends
on the customers requirement
3. Can accommodate changing requirements
4. Productivity increases with fewer people
5. As the implementation of modules occur at the start,
it can be used to find integrating errors more easily and
faster
6. Produces reusable components such as modules

There are also disadvantages:


1. Only program which can be modularised can follow
the RAD model
2. Requires a team of specialised software engineers
3. Requires the user involvement troughout the
development cycle
Bac k A2

Recommended
These are things you might like. Clicking these ads can
help us improve our free services in the future...

End of Chapter Videos

Collection of Videos to Support Your Understanding.

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

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

o Non User-Defined or Built-in 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...

o Composite Data Types

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

o Non Composite Data Types

These are data types that has no reference to other data types.
Examples include: Real, Date, String, Integer, Enumerated Data Type

Enumerated Data Type


A USER-DEFINED NON COMPOSITE DATA TYPE
This data type declares all the possible solutions or values it can take
For example, the variable "ANSWER" is declared using an enumerated data
type and can only take the value A, B ,C or D. If a Value of E is given then
an error would occur
TYPE
DECLARE ANSWER=(A, B, C, D)
ENDTYPE

When we use this variable we will declare the variable directly:


DECLARE Value: ANSWER
Another point to remember is that the enumerated values are not in "".
The order matters as there is a numerical weightage which means B is
greater than A

Classes & Record Types


USER-DEFINED COMPOSITE DATA TYPE
We use Record types in pseudocode whereas classes in python and other
high-level languages
A class gives us the layout or in other words, a record structure for each
variable. It's easier to think that each variable is considered to be a record
where there are many fields and each field is different
class MyClass:
def__init__(self):
self.__Pointer=1
self.__Value=""
This is similar to the record type.
Set Data Type
A NON USER-DEFINED COMPOSITE DATA TYPE
It is considered to be a composite data type which is a built-in data type
structure. You can store strings, number, or even boolean
What is so special about a set data type is that the values are not ordered or
indexed, so it is not possible to extract them in order
It also can't have any duplicate values in the data structure. This can be
useful especially when we need to store all unique values. You can convert
an array to a set then back again
The Set Data type is mainly used to apply mathematical operations so the set
data type has a set of mathematical operations it can work on

ARRAY & LISTS


Arrays and lists have almost similar functions but, the only difference is that
a list can hold different data types under a single variable whereas the arrays
can store data of the same data type. But why then is an array a composite
data type, this is because the array itself is a data type and it refers to another
data type like string

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.

o Fixed Point Representations

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

8 4 2 1. 0.5 0.25 0.125 0.0625

Behind the decimal is 2-1, 2-2, 2-3, 2-4


Remember this is the same principle in floating point, the only difference is
the decimal place "." is changed
If we get a two's complement value like:
1010 0100
-8 + 2 + 0.25 =-5.75

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

o Floating Point Representations

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

Highest & Lowest Values


We will take 8 bits for mantissa and 4 bits exponent as an example:

Types Mantissa

Highest Positive Value 01111111

Lowest Positive Value 01000000

Highest NegativeValue 10000000

Lowest Negative Value 10111111

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

o Random Access or Direct Access Files

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...

What File Type to Use?


When you don't require to store data in order but only using time order, or if
there is no requirement for data to be accessed quickly, then we can use
serial
When you need to order data in order but the file is sometimes used to
access data then we use sequential
If data needs to be accessed from a large file quickly then we use random
files
Logic Circuit
Types of Logic Circuits
There are two types of logic circuits depending on whether they use the output bit
as feedback for the input bit or not:

o Combinational Circuits

These output bits of these circuit is directly dependant on


the input bits only
Examples are Half adders and Full adders

Summary to binary additions


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
Half Adders

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

The Output is directly dependant on the input and the


previous output bit
So there is a direct link between the input and output side. We will learn
now 2 main types of 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

Here is a common diagram of a SR flip flop

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

Uses of Flip Flops


Used in memory to store the previous bit
Advantages of JK flip flops over SR
flip flops
1. JK flip flops can be synchronised and started when both J and K input bits
arrive by setting the clock to 0 while inactive
2. JK flip flops do not have error states instead it has a toggle state

Boolean Algebra Laws


Logic Circuits can be simplified to simpler circuits so you can use less gates
and circuits. Using Boolean Algebra we can simplify large boolean
expressions to simpler expressions for example:
A AND ( A AND B )
Can be simplified to:
A AND B
#So this uses less gates

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

Name of Law AND Form

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

So back to the example again:

So now so for each group we need to do it like this


ABC + ABC + ABC
001 011 111
011 111 110
Now for each Column we need to see what is
same
AC +BC + AB
01 11 11
01 1 1 11
If the row is 0 we put a dash over it
AC +BC + AB
This the simplified expression
They can ask you for 4 inputs, then it is 4 by 4 which has 16 slots!

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

Sending Continuous streams of data along a single


temporary route
When we make phone calls, temporary links between the sender and
reciever are made in which data is sent thorugh this route only. The building
of links is done by the circuit switching centers which are owned by the
PSTN
This connection only lasts until the phone call or until the activity stays
active. Data is sent through switching centers in full duplex mode.
Advantages of Circuit Switching
1. Doesn't require to share bandwith
2. More secure as there is less errors so no need for error correction methods

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.

Advantages of Packet Switching


1. More Cheaper to maintain and use
2. Can use all of the bandwith so more efficient
3. No need for verification at the start of the transmission

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 Network / DataLink Layer

Its function is similar to the internet layer. It handles communications


between the two networks in which data is transmitted. In fact, the Internet
Layer is a subset of the Network layer. So this includes the LAN Network
also. An example is the Ethernet Protocol

Examples of Application Layer


Protocols:

o HTTP

Sends any request to a website to get a webpage or to send data such as


financial and sensitive data (HTTPS)

o FTP

To send files over the internet


o SMTP

The send mails over the internet


When sending an email, we use this protocol to send the mail to the mail
server. This is called the push protocol
The mail server also uses the same protocol when sending it to another
person's server. Remember, this is old technology and sites like Gmail have
hidden most of these features...
It's very easy to send a mail from one Gmail account to another Gmail
account without using the SMTP protocol as the files are stored in the same
server, However, if Gmail needs to send files to Outlook, both
communicates using SMTP

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

o LLC / Logical Link Control

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

Coding data to be ready for transmitted or decoding data received to be sent


to MAC protocol
o PMA

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...

Peer to Peer File Sharing


You probably have used BitTorrent or Utorrent or QbitTorrent to download
files over the internet. But do you know how it works? We know what is a
peer to peer network and we know that there is no centralized server or
website. In fact, when we download a file we are not downloading from the
website but from many other users just like you
When you have a torrent file, they contain the address of Tracking Servers
that have the IP address and details of all the peers in the swarm network
A swarm is a keyword used to describe the networks and peers are the people
who want to download that specific file
The Tracking website controls the movement of data from one peer to
another
In BitTorrent, when you are downloading a file, you are also uploading the
file so that another person can download it from you. So in a way, a 1GB file
could take 1.5GB of Data Internet
Peers who upload more than they download are called seeds
Peers who download more than they upload are called leeches
Leeches are choked or cut of the network eventually
GIve it a try, go to your torrent settings, and make your upload speed 0, the
download speed will be 0 eventually
There is no control of the movement of data, so it can be illegal but it's very
hard to be caught, and if caught the consequences are dire. But many people
use it by using a VPN which masks your IP address. But remember
torrenting is not always illegal especially with its not illegal contents...
Hardware &
Virtual Machines
There are 2 types of computers with different instruction sets depending on their
functions and uses and structures

o RISC / Reduced Instruction Set Computers

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

o CISC / Complex Intstruction Set Computer

Mainly uses coding and software to execute instructions so they have a


microprogrammed control unit
Uses a large instruction set as it handles very large complex instruction sets
Each instruction will take many clock cycles
Has more addressing modes
Uses Less registers and mainly the memory
Harder to pipeline

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

Single Instruction Single Data Stream


A processor that handles a single instruction at a time and fetches a single
stream of data from the memory
There is only a single unit or core. This is usually used for embedded
systems such as washing machine where the instructions are simple

o SIMD

Single Instruction Multiple Data Stream


Has a single instruction that requires multiple data. For example, in vector
and graphic processing, we need to collect data from different pixels to
execute the instruction
It has a single processor that is divided into many units, called cores but a
different type of core. These cores are usually used in graphics GPU card
where there can be more than 1000s of them

o MISD

Multiple Instruction Single Data Stream


There are many instructions applied to the data. There are no practical
examples of these. The only one which is close is a video encoder that
processes the data each time it processes the video

o MIMD

Multiple Instruction Multiple Data Streams


The Processor has many cores that can execute each instruction separately.
Each Core has its own control unit
Common examples are the intel processors in your laptops and
supercomputers

Massively parallel Computers


A system in which the computers are linked towards performing a specific
task. It is similar to a MIMD processor, but the cores are instead separate
computers
The main problem associated with Massively parallel computers is that a lot
of wiring is required. Also, it will take a lot of space and it is very costly.
There might be some delay when communicating between computers. The
program must also be divided into many sections so that each computer can
handle them and send signals between computers

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

Advantages & Disadvantages of


Virtual Machines
1. It is efficient for testing software in different OS rather than having a
separate computer with that OS so it saves cost
2. Many Softwares can run in parallel so a different system can be running
while another guest software is not working
3. However, there are more lines of code due to the emulation code
4. As many guest Operating Systems run in parallel, it reduces performances
and slows them down.
5. Sometimes the virtual hardware may not be compatible with the actual
hardware
You may have realized by now that Tlauncher, Myboy are common examples
of virtual hardware software.

System Software &


Compilation A2
Kernel Software
The Kernel Software is the interface between the user and the hardware of the
computer. It is a layer of the Operating System in which handles all the underlying
functions of a computer

Input / Output Managements


When you connect an input or output device the operating system will do some
very important functions:
1. Install the driver of the device
2. Handes any interrupts from the device
3. Handles in buffer signals
4. Handles any queue control signals
Due to high speeds of the operating system, it is very rare that an input or output
device will communicate directly with the operating system. So sometimes the
input and output signals are stored in buffer in the main memory and sent to the
processor only when the time slice for the input / output device starts.
This process of dividing time slices is called process scheduling or management
which will be discussed in the next heading.

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

A program in memory with associated PCB


What is a PCB block ( program control block )? It is block that holds the required
data for the process. A PCB is like an array of data that has the required data for
the process to executed successfully

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

The Process is running inside the CPU

o Waiting / Block Stage

In this Stage, the system is waiting for a input or output signal

o Terminated

The Process is completed and 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

High level Process Scheduling


There are two types of Scheduling algorithms depending on whether the
priority of each task is considered or not!

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.

Examples of Preemptive & Non-


preemptive
The Idea is that the examples below can be used for both but their functions
have to be changed. We can use:
1. First In First Out
2. Round Robin
3. LIFO
The reason why we can apply them for both is that the only difference is that
rather than using whole processes in non-preemptive we use time slice or an
allocation period for the preemptive
However, the below can only be used for Preemptive as they consider time
as a factor
1. Longest Job First Out
2. Shortest Job First Served
Round Robin means a cyclic shift in which the process is given an equal time
and once the time slice is done, it circularly moves to the next task
Memory Management
The Main memory has limited memory and sometimes the computer may
require more of it. The way to solve this is to implement virtual memory
The idea is that the computer will allocate some of its storage as memory so
it can act like RAM or Main memory. The only issue is that the speed of a
hard drive is slower than the Main memory
When answering a question just remember these points:
1. Virtual Memory extends the RAM or increases the size of RAM
2. The Virtual Memory is divided into equal size pages
3. The Main memory is divided into equal size frames or page frames
4. The frame size is equal to the page size
5. A page table contains the process page number and whether it is present
in memory and also the Physical (Main memory) Address and the
corresponding Logical ( Virtual Memory ) Address
The New Cambridge A level Text Book confused me for days and I finally
understood that the concept in the book was incorrect. I have verified this
from trusted sources. The Book refers to the page as part of a process that is
misleading the process size must indeed be the same as the frame but it's
called a Job not a page

What is partitioning and


Segmentation?
The idea is similar to pages and frames but, partitioning is the breaking
down of memory to variable sizes whereas segmentation is breaking down
of virtual memory to variable sizes!

What is Stored in the Page Table


In the recent past papers I noticed this question popped up, so I will simply
tell you the points you need to write:
1. If the process is present in memory
2. Logical and Corresponding Physical Address
3. Time of Entry
Time of Entry is the digital time when the process entered the main memory.
Note that this is not the length of time

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

Keyword & Symbol Table


The line of code is separated to lexemes. Each lexeme has a corresponding
token which is stored in a keyword table. For example, operator and
keywords and special lexemes are stored in the keyword table
In the symbol table, we record the identifiers and the corresponding data
types. It is similar to an identifier table
It is sometimes misleading that the symbol table records identifiers and the
keyword table records token. So please practice this!
More on Symbol tables are here

o Syntax Analysis

In this stage, the grammar of the language is understood and converted in a


way that can be understood by the computer. This includes using a parse
tree or syntax tree to determine order of calculation.

Also in the real world, we have rules of precedence in mathematics such as


A+ 2*B
This is called the infix form
By the laws of BIDMAS we do the multiplication first before additions.
When converting this form to a way that doesn't require rules of precedence
or brackets
A+ ( 2*B )
Is the infix form
A2B*+
Is the Post-Fix or RPN form
The RPN form doesn't need the requirement for rules of precedence or any
brackets. Also the code can be read from left to right only
A basic understanding of converting RPN to Normal or Infix form is by
doing the steps below
1. If it is a identifier or variable then push it to the stack
2. If it is an operator then pop the last two variables or values and record the
value, example 23+ is 5
3. Keep repeating the process
Let us see an example:
Convert 23456*+/*3*
By doing the method above keep on repeating until you reach * then
simplify the last 2 variables, Make sure you read from left to right, so when i
mean last i mean the leftmost side
Convert 234(30)+/*3*
Convert 23(34)/*3*
Convert 2(3/34)*3*
Convert ((3/34)*2)3*
Convert (3/34)*2*3
We read from left to right so the infix form must have the correct value. The
values on the right are placed on the right. For example:
If A+ B*C

Then BC*A+ is not correct


but ABC*+ is correct
SO ORDER MATTERS!

To test your understanding convert D/((A*B)+C) infix


to RPN/Postfix form
Reveal Answer
Solving RPN using a Stack
You can solve the RPN using the method above. When adding variables we
add to the bottom of the stack. Then for each step, take a new column.
If it is an operator then pop the last or top two variable and record the value
and so on. Keep repeating the process and read from left to right only
Here is an example:

Parse Tree Or Syntax Tree


The Syntax tree is a graphical representation of the RPN form. It shows the
rules of precendence. The ones at the bottom leaves are done first and the
nodes are the operators
o Senamantic 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

Is AAA a valid password


See Answer Here
It is good to remember these symbols and all and another thing to remember
is that if the BNF has a certain symbol then we need to add them
23.33
<Value>::=<Number><Number>.<Number><Number>

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

This generates the final object code

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

What is in a DIgital Certificate?


This came in a past paper so I will just tell you the points:
1. Serial Number
2. Owner's Public key and details
3. CA's digital signature
4. Hashing Algorithm

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

Types of Symmetric Encryption


There are many methods of generating a key for symmetric encryption and
that is by using permutation and shifting. This is not required for you to
know! If the Key is made available only to both parties then it is impossible
to break by the brute force method. For example, a 256 bit Key will take
2256 tries. The brute force method is the process of trying all possible
combination in order to get the correct key
SSL & TLS
SSL Stands for Secure Socket Layer and TLS stands for Transport Layer
Security
TLS is the new advance version of SSL.
SSL is the layer that enables safe transmission of data across the HTTP
protocol, that's why you see your HTTPS (secure) which is more secure. It
encrypts data so it is usually used for online banking and online eCommerce
sites and for secure file and mail transfer
It is necessary for you to mention the word secure
TLS has advance security such as session caching and enhanced encryption.
This means the session key only is available for a short period.
We will talk about the steps of the SSL protocol:
1. A request is sent to the website by the client for the digital certificate and
SSL certificate
2. If the client or browser is able to verify then a request is sent to the
website using the website public key to start transmission.
3. If the website accepts it then it sends an acknowledgment with the session
key
4. The client uses the session key to start communication that is highly
secure

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

After a single route is finished, remaining nodes are then considered


Note that Dijkstra's Algorithm must consider all possibilities to see which route is
the shortest. You also need to trace the graph by updating the values of each node
for each route

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

Handles and takes in large amounts of unlabeled or categorized data that


outputs categorized data

o Supervised Learning

Uses categorized and labeled data and processes it to perform a specific


function such as send out analytic reports
An example is the youtube or Facebook analytic feeds that tell you how
many views for the past 28 days

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

Artificial Neural Networks


This is based on the idea that the structures and complexity of neural
networks in our body give some form of intelligence and so it is used in
real-life AI
This is very interesting indeed and has been very beneficial to us. I will
explain this briefly so you can understand
Using the diagram, the first layer or the first set of nodes on the left side are
called inputnodes/layer
The Nodes on the right are called the Outputnodes/layer
The Nodes in between are called Hidden layers. Note that there can be
many layers in the hidden layer
Note that this is a graphical representation. It could be hardware or software
Say we need a software that uses AI, it must take in input values that give
values close to the real values. In other words, the prediction must be close
to the real value
The Nodes each have a weightage that adds or multiplies the value it
receives and outputs to the next node. The problem is at the start, the
weightage each node has is incorrect or not calibrated
The system will be given past actual data and give results. However, it's
unlikely to give the expected correct result. So this can be compared with
actual results to see how deviated the calculated result.
By doing this, the system can adjust the weightage of each node so it will
give close to the exact value. This process is called the backpropagation of
errors. The adjustment occurs from the output nodes first and then it adjusts
the node until it reaches the input layer nodes
Back Propagation of errors is the process in machine
learning that optimizes the value for the adjustable
parameters. The adjusting process occurs from the output
layer nodes to the input layer nodes
Forward Propagation of errors is very similar to the backpropagation of
errors but the direction of adjusting is reversed.

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

//To PUSH AND ADD NEW ITEMS


PROCEDURE PUSH(DATA)
//Could also be compared with -1
IF Freeptr <> Nullptr
THEN
CurrentNode←Freeptr
List[CurrentNode].Data←DATA
Freeptr←List[Freeptr].Pointer
Previousptr←Nullptr
CheckNode←Startptr
WHILE CheckNode<>-1 AND List[CheckNode].Data <
DATA DO
Previousptr←CheckNode
CheckNode←List[CheckNode].Pointer
ENDWHILE
IF Previousptr=Nullptr
THEN
//Incase there is only one node in the array
List[CurrentNode].Pointer←Startptr
Startptr←CurrentNode
ELSE
List[CurrentNode].Pointer←List[Previousptr].Pointer
List[Previousptr].Pointer←CurrentNode

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

You might also like