Sei sulla pagina 1di 8

A2 COMPUTING COMP3 - KEY POINTS

SECTION 1: PROBLEM SOLVI NG


Comparing Algorithms

Big-O Notation

Time Complexity How long an algorithm


takes to complete

Uses Worst Case to analysis time complexity referred


to as the order of complexity.
Complexity
Form
Exponential
O(an)
Polynomial
O(na)
Linear
O(n)
Logarithmic
O( log(n) )

Space Complexity How much Memory an


algorithm needs to complete

Table ordered in worst to best

Intractable Problems

Arithmetic Rules for Big-O Notation


Property
Example and Answer
The
Product
of the two functions is used.
Product

A problem that can be computed but not in a


reasonable time for large inputs.
An exponential complexity is not reasonable.

O(H) * O(J) = O(HJ)


The bigger function is used.
O(J) + O(T2 ) = O(T2 )
Constants are ignored
kO(H) = O(H)

Sum

The Travelling Salesman Problem


Well Known Problem. Finding the shortest distance to
travel though as many different towns.
It is a NP-Hard Problem and cannot be solved in a
polynomial time in any known way.
Heuristic Approach:
The nearest neighbour approach is a smart way of
calculating the Travelling Salesman problem, with a list of
cities each path with the closest distance is chosen till all
cities are visited. Note that this is probably not the best
option and a quicker router can usually be found.
It is simple and fast but does not guarantee to give a
solution
The Halting Problem
An unsolvable problem that means you cannot
determine if the program will stop given a particular input.

Constant

NP Problems
A NP problem is a set of decision problem if I can be verified by a
polynomial time O(na).
P means the problem can be solved in a polynomial time using a
Turing machine.
NP-Complete: Every problem in NP can be reduced to X.
NP-Hard: Non-Deterministic Polynomial Time shows a problem is
not solvable in a realistic time.

Turing Machines
A Turing machine is a hypothetical machine that can determine if something is
computable. Anything a modern computer can do, so can a Turing machine.
It consists of: An infinitely long tape, a header and a transition table.
The Turing machine header can move left and right. These are denoted by the
symbols << and >>. An empty square means empty space. A # separates the list.
Using the diagram and state transition it can be decided if an algorithm can be
computable.
A universal Turing machine can simulate other Turing machines, with this concept
any machine can be built with a UTM and executes the given data. An interrupter.

Finite State Machines


A state transition diagram is where the nodes represent states and the transition is
labelled a|b where the b part denotes an output and the represent input.
A transition table tabulates the states and next states during progression.
In a mealy machine the state is changed during the transition. In the state circles
are the state indicators.
In a Moore machine states of the outputs are represented inside the state circle. So
the output is only changed when the state has changed.
Finite State automaton produce a Boolean once the final state has been reached.
A non-deterministic FSA is where a transition can have two different paths.
2014- Charlie Knight

Regular Expressions
Regular Expressions are a way of matching an input
to a pattern by describing a set of valid string.
Components of a Regular Expression
Symbol
Meaning
Example
Alphabet of a language
{ a, b, c }
{}
The OR Operator
abc|bca
|
abc?
Could be zero or one
?
Repeated zero or more times
ab*
*
One
or
more
exist
ab+
+
Enables Grouping in Expression
(a|b)
()
One character must match
[a-z]
[]
Escape Character.
\*
\
Negation. Characters NOT
^[a-z]
^
Attach to end of string
.+Finish$
$
Match
any
character

.
Sequential
Range
[A-C]
Represents a Space
\s
Represents a Digit
[0-9]
\d
Represents
Not
Digit
(^\d)
[^0-9]
\D
Union. Logical AND.
[a-z && ^p]
&&

Reverse Polish Notation


Known as Post-Fix Notation.
Allows expressions to be written without brackets by
adding the operation at the end of the op-ands. It uses
a stack which is Last-In-First-Out Operations.
When a symbol is read then it gets pushed on the stack.
When an operator is read then the last two get popped
and performed.
Note that Infix notation is our current way of processing.

Backus-Naur Form
A notation to express rules for a valid string.
Structure of a Backus-Naur Form
Symbol
<>
::=
|

Meaning
Meta-Component (The Definition)
Definition of the Meta-Component
OR operator. Having more than one term.

Recursion is common in BNF by using the definition


in the same Meta-Component.

Syntax Diagrams
Similar to BNF, The language can be represented in a diagram.

Structure of a Syntax Diagram


Symbol
Meaning
Oval
Rectangle
Arrow

Direct meaning using the text in the shape


Relation to a named meta-component
Direction of the path thought entities

SECTION 2: PROGRAMMI NG CONCEPTS


Object Orientated Programming

Structured Programming

Object Orientated Programming means types of data, procedure


and functions can be grouped together. Object Orientated
programming has many benefits by reducing duplicate code and
hiding information.

The structure a programmer follows is called a paradigm.


The structured programming technique is used to
improve the clarity and quality of a computer program.

Terms Used in Object Orientated Programming


Term
Meaning
Encapsulation
Abstraction
Field
Access Modifiers
Class
Object
Instantiation
Inheritance
Polymorphism
Interface

At imperative program manipulates variables and data


structures. It uses loops, conditions and stops the use of
GOTO statements.

Data should only be visible to an objects


procedures. Procedures are manipulated.
Putting common data and filling on Instantiation

Procedural Orientated Programming

Variables that are stored somewhere

This paradigm is also known as Functional Programming

Public, Private. The visibility status of something.


The Recipe to create something
The runtime data of an initialized class

A word to describe the object based on a class


Passing data from a parent to a child class
Changing the class for a different object.

Programs define mathematic functions and using a series


of function calls it can solve the problem. There are no
variables instead it uses lists and functions
Example Language: Lisp, Haskell.

Global Knowledge that describes a class.

Logic Programming
A program that contains facts and rules. The
program backtracks the rules to find an answer.
Example Language: Prolog

Event Driven Programming


A program where events occur due to an action or a response.
These are known as event handlers. An example would be the
user clicking on a button.
Example Language: Java or C#

2014- Charlie Knight

Recursion
Recursion is where a procedure calls itself.
Usually a recursive function has a parameter in
which changes on each call.
The recursive routine uses a stack (LIFO) to store
information. The last element to be added to the
stack is the first element to be pulled off the stack.
A stack overflow is where the stack has become
too large for the memory allocation and mostly
likely due to the recursive routine calling itself too
many times.

Abstract Data Type


Data types that are not defined by implementation but by
how the structure operators. There are four type to know
Name
Definition
Linked Lists
Each item contains a pointer to another
node. More flexible than an array.
Queues
A FIFO (First in First Out) type structure.
Stacks
A LIFO (Last in First Out) type structure.
Binary Trees
Similar to linked lists, but each node has
a left and right link. Following a tree type.

Pointers
A pointer is a link to a memory address location.
The Heap is a pool of memory locations that can be
allocated during the runtime of a program.
Garbage Collectors are in modern languages and aim
to prevent memory leaks in the heap.

Stacks

Linked Lists

A linked list has nodes with a pointer which points to the next.
The linked list requires a starting point and a null pointer.
Deleting an element: Remove element, change previous
pointer to the element next to the deleted element.
Adding an element: Make element before point to the new
element then the new element point to the previously point.
Finding an element: The linked lists need to be sorted.
Two way linked lists point to both the next and previous nodes.

Queues
A queue is a First in First out (FIFO) structure. The element that
was added to the queue first will be executed first. A good
example of a queue is in supermarkets where each customer
is severed in the queue.
Requirements for a queue
Ability to check if the queue is empty
Able to return the value that is at the front of the queue
Able to remove the first element in the queue
Place a new element at the rear of the queue
There are three types of queues: Circular, Linear and Priority.
Circular Queues
A circular queue is a queue that has fixed space and the
ends of the allocation are treated as a loop (circle). So a
head and tail keep track of the first and last element of
the queue. The program will follow the path from head to tail
(the ends the queue are irrelevant) and once it reaches a
head then that is the end of the queue. If the head and tail
are next to each other it means the queue is full.
Priority Queue
Priority queues are queues that remove items based upon
their priority. The order of items is irrelevant.

A stack is a Last in First Out structure (LIFO). The most recent item
added to a stack is the first to be removed from the stack.
A good example is a stack of plates, removing from top to
bottom.
Requirements for a stack
Ability to check if anything exists in the stack (Not Null)
Ability to check if stack is full
Able to remove top it (Pop Item From Stack)
Able to add new item on top of stack (Push To Stack)
Stacks are used when calling procedures in a program.
To implement at stack a variable storing the top value of the
stack is used and a list is used to store the items.

Binary Trees
A binary tree is a type of rooted tree. They are more structured
and easier to search than linked lists. This consist of nodes
(vertices) and branches (edges). The nodes that have no
children are known as leaf nodes.
A binary tree must always be kept organised when an operation
is performed on it. Each node has a field and two pointer values.
One pointer points to the left sub tree and the other points right.
Construction
1
Create a root node with data in it.
2
Compare new item with root node.
3
Follow the right pointer first, if not follow the left pointer
4
Compare until the left or right pointer is null
5
Create the node and set both pointers to null.
If greater than node then place on right otherwise place on left.
Searching a binary tree is easy because its a hierarchy. It follows
similar steps in construction, by comparing the value to the root
node, if its greater then go right otherwise less than go left. Until
the item is found or the search hits a null pointer.

Linear Queue
Linear queues are queues where elements are added to the
end of a list and removed at the other end. A head and tail
pointer keeps track of the positions in the list. Items are
added to the list at the tail end and items are removed from
the head end of the queue.

2014- Charlie Knight

Trees

Graphs
A graph has a set of vertices (nodes) and edges that join the
vertices. A labelled graph has the vertices associated with a
label.
A directional graph means that the connecting edges have a
direction arrow point towards the vertices. Each vertices must be
connected to at least two edges (at least an out and an in)
Weighted graphs means giving each edge a weight value. This
could be the distance between cities for example.
Graphs are used for various applications and use abstraction to
remove information that isnt required in the graph purpose.
Adjacency List is a representation of the nodes connection to a
vertex.

A tree is a type of undirected graph, but contains no cycles.


Each vertex can only be reached using one path.
This means there is: n-1 edges (when n is vertices)

A rooted tree is used to represent the hierarchy of the tree. The


tree contains a root node where all other edges direct away
from it. Any node could be the root.

Adjacency Matrix is another representation of the graphs


connecting edges

Tree Transversal

An adjacency matrix is good for a graph that has a large


amount of relationships otherwise it could have lots of
unnecessary nulls. The symbol for null is the infinity sign.

Traversing is following a tree to view all the nodes in it.


Pre Order: Algorithm that looks at root node then follows the
left hand side then right hand side.

Graph Transversal
Two types of graph transversal. Breadth-First and Depth-First.
Breadth-First

Depth-First

Transversal Types
Starting from a particular node and looking at
all connected nodes. Moving on to least great
next and continuing the process. QUEUE TYPE
Following each connecting nodes until it
returns back to the start node. STACK TYPE

Computer Simulation
Computer simulations are used in a wide range of areas in live
including construction, finance or geographical modelling.
All computer simulations suffer from limitations, they are only as
good as the math and data they are created from.
Construction a computer simulator
# Key Point
Explanation
1
Decide on solution
Define the problem and boundaries
2
Gather Information
Observe real system or reasoning
3
Assessment
Decide on the importance of
different tasks in the simulator
4
Design
Running models and creating test
cases. Find any problems
5
Construction
Create the computer simulator
6
Evaluate
Compare data to real-life data.
Supermarkets usually simulate queues. This would mean analysing
old data and creating a simulator which predicts queue times.

Insertion Sort
https://www.youtube.com/watch?v=lCzQvQr8Utw
This a basic sorting algorithm. It is a divide and conquer technique.
It works in two parts.
You compare one element, and start comparing it to all elements
before it. As soon as you find the element that less than it then the
element gets moved to that position.
Moving on the index you compare it with previous elements.

The insertion sort is a simple but insufficient algorithm.

In-Order: The algorithm first searches the left branch then the
root node. Then will work its way down the right branch.
Post-Order: Algorithm follows the left branch then the right
branch and then looks at the root node.
Pre-Order

In-Order

Post-Order

Visit the root.


Traverse the left
subtree.

Traverse the left


subtree.

Traverse the left


subtree.

Visit the root.


Traverse the right
subtree.

Traverse the right


subtree.

Traverse the right


subtree

Visit the root.

Binary Searching
Binary searching is a method of searching a sorted set of
elements. By using a pivot point. The algorithm compares the
node with the pivot. If its greater than. Then everything less
can be discarded as its certain it wont exist in there.
The process repeats until the elements can no longer be
divided or the element has been found.

Hashing
Problems were data cannot be sorted easily can be hashed.
Hashing maps big data into a smaller set. The result is called
an index. The main problem is collision (two sets of data return
the same index). Use overflow lists or next free space to solve.

2014- Charlie Knight

SECTION 3: REAL NU MBERS


Calculating Floating Point Numbers
Floating point numbers are a representation of numbers in binary form. The range of floating point
numbers is far larger than fixed point. The use base two exponents and mantissas.

Errors caused by Floating Point Numbers

Precision & Significant Figures


The precision is due to the limited size of memory.
Which compromises the accuracy of numbers.
Although in most situations the accuracy loss is
not significant.

There are two types of errors.


Absolute: The difference between the wanted
number and computer representation
Relative Error is the ratio of absolute error

Rounding is the method to change the current


number to a closer value. This would mean
making the floating point value closer to the
intended value.

Overflow is when the calculated number


becomes too large to be represented
Underflow is when the number is too small.

SECTION 4: OPERATI NG SYSTEMS


Operating System Classifications

Roles of an Operating System


Operating systems were made to perform system tasks
without the need of an operator.

Memory Management
Shares finite resources on management between different
processes. Tries to avoid running out of memory or collision
in memory. Most operating system use virtual memory.

User Interface (API Calling)


Allows the user to interact with the operating system and
can use API (Application Programming interface) which is
related to Abstraction. Allowing the user to interact with
common features of programs and the operating system.

Multitasking (Process Management)


Only a single process can be handled at a time, the
operating system gives priority to each process and allows
the user to multitask.

Peripheral (Device Management)


Interacts with devices, interrupts are used so the operating
system can perform a devices task (Moving the mouse)

Security (File I/O Management)


File management (I/O) including user account control.
A virtual machine is the idea that means the operating
system is doing all the behind the scenes work.

Operating systems are designed for various reasons.


Name
Definition
An operating system that responds to user
input. Priority is given to programs that the
Interactive
user is currently using. A desktop operating is
always an interactive system.
Responds to external events. Designed so
that events are response in a set time. Using
Real-Time
involve complex timing systems. An example
is the mobile phone masks with multiple calls.
An operating system that enables the
Network
computer to communicate over a network.
Similar to Embed system but usually have
more processing power.
Device
A mobile phone is an example, where
power must be considered.
A limited size operating system that matches
Embedded
the hardware. Example is a microwave.
Usually has more processing power but deals
Desktop
with resources, applications, interrupts and
multitasking. Windows 7 is a desktop OS.
Designed to support multiple users, has
access to network resources and control of
Server
security. Allows services to run in the
background.

2014- Charlie Knight

SECTION 5: DATABASES
Modelling an Database
A conceptual model is a representation of data
requirements that is independent of any software.

Normalising a Database
Normalisation is a technique used to normalise
entities which means removing redundant or
duplicate data. There are three normal forms.

There are four types of entity-relationships:


One-To-One: Only one entity can be linked to another

The First Normal Form (1NF)


Eliminating Duplicate columns that are in the same

One-To-Many: One entity but many other entities

Many-To-One: Many entities to one root entities


Many-To-Many: Many entities connected to other entities

The Second Normal Form (2NF)

table

Separate table for each groups of related data that


each contain a unique identifier

All requirements of the first normal form met.


Remove data that applies to multiple rows and making
a separate table.
Creating relationships between the new tables using a
foreign keys.

The Third Normal Form (3NF)

Relational Databases
A relational database is a structured database that
includes relations between information.
Attribute: A property of an entity

All requirements for the second and first normal form


met.
Removes any columns that arent dependant on the
primary key.

An example would be the name of the column

Tuple: A set of attributes


An example is a row in the database.

Primary Key: A unique identifier for each tuple.


Composite Key: A combination of attributes for a UI.
An example is using a deck of cards. Only one Ace -> Clubs.

Foreign Key: An attribute that is the primary key of


another table.
Referential Integrity: Ensuring that a foreign key does
indeed appear in the other table (as the unique
identifier)

An example that is in third normal form.

Structured Query Language


SQL are query statements that can be divided into two categories: DDL and DML.
Data Manipulation Language (DML)
Used to retrieve or manipulate data.
Select

Data Definition Language (DDL)


Used to define a structure of a database.
Create

Retrieve data from the database using conditions (RO)

Used to create a table in the database

Insert
Adds one or more records into the database

Drop
Destroy a database, table of index. (DELETE does not do this)

Update
Changes the data of one or more records in the table

Alter
Modifies an existing database object.

Delete
Removes one or more records from the database

2014- Charlie Knight

SECTION 6: COMMUNI CATI ON AND NE TWORKI NG


Communication Methods
Serial Transmission: Binary signals are transmitted
one after each other. There are three types
Name
Definition
One
direction
only.
Single Channel
Simplex
Both
direction
but
one
single channel.
Half-Duplex
Both
directions
with
two
channels.
Duplex
Examples of serial transmission: SATA, USB.
Parallel Data Transmission: Bits are sent down
several wires simultaneously. It is used over short
distances as voltage decreases over distances. An
example would be computer to printer communication
Baud Rate: Amount of signal changes a second.
Bit Rate: Bits transmitted per second.
Bandwidth: Range of frequencies that can be
transmitted. Measured in bits per second.
Latency: Time delay between sender and receiver.
Asynchronous Data Transmission
Arrival of data cannot be predicted by the receiver. A start bit
is used to signal the arrival of data and temporarily
synchronise the two systems.

Hand Shaking: Check if the device is ready for


communication. Both send a Ready/Busy Signal
Broadband: Multiple data channel system, can carry
multiple signals at a time.
Broadband: One dedicated data channel at a time.

Local Area Network (LAN)


Local area networks are linked computers in close
proximity. A LAN covers a small area in building in
which storage, peripherals and printers are shared
between one another.
A stand-alone computer is a computer that is not
connected to a network. It requires its own printers
and peripherals and own licence to software.
A LAN is good for short distances.
A LAN usually has very low latency.
A LAN is common in peoples home, and is cheap.

Wide Area Network (WAN)


A wide area network is links that can connect
remote computers and other networks together.
There are various ways of creating a link between
these computers including satellite, internet or
fibre optics.
The mobile telecommunication network is
connected via WAN. Text messages are attached
to packets that link the mobile phone with the
mask.
WAN is usually global, so can be costly to setup
and would have higher latency than a LAN.

Network Topology
The shape, layout, configuration and structure of connections between machines and devices.
Bus Topology
A single cable called a Bus connects workstations together,
It uses less cable than any other topology and computers simply
connect to the bus to join the network. It is simple to run a bus
network however one break in the cable could cause downtime.
Advantages
Cheap and low cable costs
Easy to add new nodes. By
simply connecting to the bus.

Star Topology
A central node that other nodes connect too. Each system is
connected by its own cable. The network is dependent on the
central node and as such any problems would cause problems to
the network. However problems with another node are unlikely to
affect the rest of the network.
Advantages
Disadvantages
No performance loss
Central Node dependence
Secure Communication
Expensive to implement
Easy to add new nodes
Extra equipment required (Hub)
2014- Charlie Knight

Disadvantages
Single point of failure
Network performance
downgrades under load.

Network Types
Segmenting a network means splitting up several
parts.
Peer-to-peer networking is a network that has no
central server. Each node has the same rights. This
type of networking is widely used to download
files. In small networks, this is used to distribute files
onto each computer
Server-based networking is using a central node to
manage security & data.
Thin Client networking is using a low power
computer and using the central server to process
Rich Client is the opposite of thin client, all
processing power is done on the computer itself.
SaaS is software as service. Clients use (rent) the
software without installing it on their own
computers. An example is Google Mail.
AJAX is a technology that creates interactive
scripts where the browser runs them. Scripts are
sent to the client and ran, they can easily be
updated.
Web 2.0 is a word to define the current state of the
WWW. Includes blogs, social networks and stream.
Web Services is accessible API that other programs
use. An example of this is GoCompare where they
likely request data from companies web services.
Network Adapters
A network adapter is the interface for the network.
It has a buffer till the computer can process it. The
network adapter is a serial data flow. A MAC
address is assigned to each adapter (Media
Access Control).
On a bus topology collisions must be avoided.
In a star, the central node queues the packets.
Server-Side Scripting
CGI Common Gateway Interface, allows extensions to
run on the webserver. Extensions can communicate with
a DBMS (Database Management System)
Scripting Languages: HTML produces the page, PHP or
ASP.NET produces server scripts.
GET: Sends a request to retrieve information from server.
SET: Sends a request to the server to accept information.

Computer Security
Authentication: Verifying if the user is who they say
they are. Includes passwords or biometrics.
Authorisation: Verifying the rights to a command
the user requested.
Accounting: Audit records such printing or logins.

Wireless Networking
WIFI is a wireless technology that allows computers
and devices to connect together wirelessly. Using
various technologies (A, B, G, N) it is found
commonly in homes. They are usually slower than
a physical connection and vulnerable to attack.
Usually used for LAN in the home or businesses.
The WEP key was used to prevent unauthorised
access but was easy bypass. WPA became the
new standard for wireless routers.
Bluetooth is a wireless protocol for exchanging
data over short distances. Bluetooth uses radio
technology that has a bit rate of up to 1Mbps. It is
common to use in mobile phones, laptops or other
devices. It is secure and because of it short range,
does not require a licensed.

Inter-Networking
Two LANS become connected to a WAN. So two
networks can communicate with one another. The
two LAN networks become internetworked. The
publically accessible network is called the Internet.
Routers and Gateways
Routable IP (Public IP): Every IP is address between homes and
businesses so other networks know where to send packets.
Non Routable IP (Private IP): Used in local area networks, they
do not connect directly to the internet. NAT (Network Address
Translation) must exist in the router to decide what computer to
send the packets to or from. Ranges for private IP:
10.0.0.0 10.255.255.255
172.16.0.0 172.31.255.255
192.168.0.0 198.168.255.255
A subnet mask is an address that tells a device which IP
addresses it can access directly (without going through
another router). Each number must be 255 or 0.The zero
representing accessible numbers. (See the example in revision guide)
Routers are devices that forwards packets from one network to
another. Router use MAC addresses to decide the goal of the
packets. All routers use the protocol TCP/IP
Gateways are the entrance and exit of a network. They
connect multiple networks together. It routes traffic from
outside networks.

Internet Security
Firewall: Barrier that controls network traffic. Controls port traffic
Proxy Server: Less exposure for the computer. With Firewalls
Encryption: Technique to protect data by making it
unreadable. Ciphers change the text.
Symmetric Encryption: Using the same key for both encryption
and decryption. Asymmetric uses different keys.
Digital Signatures: Prevents messages from being tampered.
Digital Certificates: Unique ID to identify the sender.
Treats: Viruses, Worms, Trojans, Spam, Phishing, Pharming.

2014- Charlie Knight

Potrebbero piacerti anche