Theory of Computation Flashcards

1
Q

Abstraction

A
  • Abstraction is simplifying complex systems by removing unnecessary details and leaving only the essentials
  • Representational abstraction = A representation made by removing unnecessary details
  • Abstraction by generalisation = A grouping by common characteristics to arrive at a hierarchical relationship of the ‘is a kind of’ type
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Data abstraction

A
  • Data abstraction focuses on hiding the implementation details of data structures and only exposing the necessary features
  • Abstract data type = A high level description of a set of operations that can be performed on a data structure without specifying how
    Provides operations and defines behaviour
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Problem abstraction

A
  • Problem abstraction = Where details are pulled away from the problem until it is represented in a solvable way
    Works because a simplified problem is usually similiar to a problem that has already been solved
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Decomposition, composition and automation

A
  • Decomposition = Where a problem is divided into smaller sub-problems that can be solved individually
  • Composition = Combining procedures to form a larger system - used in abstract data types like trees
  • Automation = Putting abstractions of real world phenomena (models) into action to solve problems.
    This is achieved by creating algortihms that are later implemented into code, implementing models into data structures and executing the code on the data structures
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Finite State Machines

A

Finite state machines are machines that consist of a fixed number of possible states, a set of allowable inputs called the input alphabet that changes the state and a set of possible outputs

  • Finite state automata = FSMs with no outputs
  • Mealy machines = FSMs with outputs

FSMs are represented by state transition diagrams or state transition tables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Sets

A

A set is an unordered collection of values where each value occurs at least once

  • Can be defined by listing its members; the set of Integers = {-3, -2, -1, 0, 1, 2, 3}

Common sets include:

  • Empty set {}
  • Natural numbers; N
  • Real numbers; R
  • Integers; Z
  • Positive integers; Z+
  • Negative integers; Z-
  • Irrational numbers; Q
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Set comprehension

A

Set comprehension describes the properties of the set’s members

S = {x * 3 | x ∈ ℤ ∧ x ≥ -3 ∧ x < 3} means x*3 is a member of the set such that x is an integer which is greater than or equal to -3 and is less than 3

  • | means ‘such that’
  • ∈ means ‘is a meber of’
  • ∧ means ‘and’
  • x*3 is the actual values of the set
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Compact set representation

A

This is a shorthand way of describing sets

S = {0n 1n | n ≥ 1} means 0 and 1 appear n times in the string such that n is greater than or equal to 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Set types

A

Finite set = Sets that contain a finite number of elements

Cardinality = How many members exist in a finite set

Infinite sets = Sets that contain an infinite number of members
These are divided into countable and non-countable infinite sets:

  • Countable infinite = The number of items in the set can be counted with natural numbers
  • Non-countable
    infinite = Sets that contain a larger infinity of items that can’t be counted with natural numbers
    eg. Set of Real numbers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Set terms

A

Subset = A set that only contains items from another set (symbol = ⊆, ‘is a subset of’)

Proper subset = A subset that doesn’t contain all the items from another set (symbol = ⊂, ‘is a proper subset of’)

Countable set = A set that has the same cardinality as some subset of the natural numbers.
Countable sets include finite sets and countably infinite sets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Set Operations

A

Membership = Where an item is in a set (eg. 3 ∈ R; 3 is a member of the set of real numbers)

Union = Merging 2 sets into one - if an item appears in both sets, it will only appear once in the new set (symbol = ∪)

Intersection = The items that both sets share (eg. A = {1, 2, 3, 4, 5, 6} and B = {2, 4, 6}, the intersection is {2, 4, 6} and the symbol is ∩)

Difference = Only contains items exclusive to one set - not shared
(eg. A = {1, 2, 3, 4, 5, 6} and B = {2, 4, 6}, the difference is {1, 3, 5} and the symbol is \ or -)

Cartesian product = the set of all ordered pairs from 2 sets as (a,b), where a is from set A and b is from set B
(eg. A = {1, 2, 3, 4, 5, 6} and B = {2, 4, 6}, cartesian product = {(1,2),(1,4),(1,6),(2,2),(2,4),(2,6),(3,2),(3,4),(3,6),(4,2),(4,4),(4,6),(5,2),(5,4),(5,6),(6,2),(6,4),(6,6)} and symbol is X)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Regular expressions

A

Expressions used to specify a set of strings that satisfy given conditions

Both regular expressions and FSMs are equal ways to define a set

Metacharacters used:

  • | means ‘alternatives / ‘or’ (a | b = a or b)
  • ? indicates zero or one of the preceding element
    (a? = “ “ or “a”)
  • [**] indicates zero or more of the preceding element
    (a* = “ “ or “a” or “aa” etc)
  • (+) indicates one or more of the preceding element
    (eg. a+ = “a” or “aa” or “aaa” etc)
  • () defines the scope of an operator and groups characters together
    ( (ab)* = “ “, “ab”, “abab” etc)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Regular language

A

Any language represented by a regular expression and any language that an FSM will accept

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Context-Free languages

A

A context-free language is a set of strings and symbols that follow the rules of a
context-free grammar.

Context-free grammars describe which strings are and are not
possible in a language by laying out production rules.

Meta-language = a language that describes another language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Backus-Naur Form

A

BNF is a way of notating context-free languages

The left hand side of a BNF statement is defined by the right hand side
(eg. FullName ::= Title Forename Surname)

Symbols incldue:

  • ::= means ‘is defined by’
  • | means ‘or’

BNF consists of a set of terminals that can’t be broken down further and a set of non-terminals written as <name> that can be broken down into terminals</name>

Production rules = The syntax of a context-free grammar
(eg. Fullname = Title Forename Surname)

BNF supports recursion while regular expressions can’t.
(eg. Integer ::= Digit|Digit Integer where integer = 0 | 1 | 2 etc)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Syntax diagram

A

A syntax diagram is a visual representation of a regular language.

Syntax diagrams use
rectangles to represent non-terminals and ellipses to represent terminals.

These shapes are joined by arrows which indicate how strings can be formed from the definitions.

Each non-terminal is defined by its own syntax diagram.

17
Q

Computational complexity

A

The computational complexity of an algorithm measures how economical the algorithm is with time and space (memory)

It’s always taken as the worst case of the most efficient algorithm which solves the problem

Time complexity = How fast the algorithm runs

Space complexity = How much memory the algorithm uses

18
Q

Big O notation

A

Big O notation always assumes the worst case scenarion and expresses time complexity

  • Constant time = O(1), where the time taken doesn’t change no matter how large n is (eg. checking if a number is odd or even)
  • Linear time = O(n), where the time taken grows proportionally to the size of n (eg. Linear search)
  • Logarithmic time = O(log^2 (n)), where the time taken grows logarithmically to the size of n (eg. Binary search and Merge sort with O(n log^2 (n)), which is linear logarithmic time)
  • Polynomial time = O(n^k), where the time taken increases faster than the rate of increase in the size of n (eg. Bubble sort)
    Algorithms that have a loop within a loop are usually O(n^2)
  • Exponential time = O(k^n), where the time taken grows exponentially to the size of n and can only be solved in a reasonable amount of time if n is very small
  • Factorial time = O(n!), where the time taken grows factorially to the size of n) (eg. Travelling salesman problem)
19
Q

Computation limits

A

Tractable problem = a problem that can be solved in a reasonable amount of time (time complexity of polynomial or below)

Intractable problem = a problem that can be solved but not in a reasonable amount of time

Heuristic knowledge is used to solve intractable problems; they create sub-optimal but usable solutions

20
Q

The Halting Problem

A

The halting problem asks “is it possible to write a program that can tell, when given another program and its inputs as an input and without executing this program, whether the inputted program with its inputs will halt?”.
The answer is no.

This proves that not all problems can be solved algorithmically and shows that there are problems that computers can’t solve

21
Q

Turing machines

A

A turing machine is a theoretical machine that consists of:

  • Infinitely long tape; this contains a list of acceptable symbols for a given TM called its alphabet. The tape is divided into squares and the alphabet must be finite
  • Read/Write head; this looks at 1 square at a time and can read / write data onto the tape
  • Control unit; this is effectively an FSM

The control unit specifies:

  • How many states the machine can be in
  • The machines initial start state
  • Any halt states that stop the machine
  • Transition rules; what to do when the machine is in a given state, how to move between states and how the data on the tape changes

TMs are limited to one FSM, meaning they are specific to the problem they need to solve

22
Q

Universal turing machines

A

Universal turing machines are capable of representing any FSM.

A standard description of a TM is fed into the tape of a UTM. The UTM reads the description and writes it back to the start of the tape; the UTM can then execute its operations on the data on the tape exactly how the TM fed into it would’ve done.

This makes UTMs capable of performing any computation that a TM can describe.

23
Q

Importance of turing machines

A

These machines are important to computing because:

  • Anything that a TM can compute can be computed by a real computer and vice versa
  • Defines what is computable and what can’t be solved by computers