Aqa Comp 3 - Key Notes
Aqa Comp 3 - Key Notes
Big-O Notation
Intractable Problems
Sum
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.
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]
&&
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.
Syntax Diagrams
Similar to BNF, The language can be represented in a diagram.
Structured Programming
Logic Programming
A program that contains facts and rules. The
program backtracks the rules to find an answer.
Example Language: Prolog
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.
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.
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.
Tree Transversal
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.
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
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.
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.
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.
table
Relational Databases
A relational database is a structured database that
includes relations between information.
Attribute: A property of an entity
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
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.