Theory of Computation Flashcards

(74 cards)

1
Q

What is an algorithm?

A

A sequence of steps that can be followed to complete a task that always terminates.

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

What are the 4 constructs of algorithms?

A

1) Iteration
2) Selection
3) Variable assignment
4) Sequence

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

What must we consider when evaluating different algorithms?

A

Efficiency, how many cases does it work, and error handling

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

What are the 4 main techniques of computational thinking?

A

1) Abstraction
2) Decomposition
3) Pattern recognition
4) Algorithmic thinking

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

What is abstraction?

A

Removal of detail from a a problem to focus on what is necessary to solve

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

What is decomposition?

A

Breaking a problem down into smaller problems, each of which is easier to solve

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

What is pattern recognition?

A

Comparing a problem to similar problems that are already solved and applying the same or similar solution

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

What is algorithmic thinking?

A

Writing a solution to a problem using algorithmic constructs (iteration, sequence, assignment, selection)

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

What are the different forms of abstraction?

A

1) Procedural abstraction
2) Functional abstraction
3) Data abstraction
4) Problem abstraction / reduction

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

What is representational abstraction?

A

The representation arrived at by removing unnecessary details from the problem.

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

What is an example of representational abstraction?

A

Maps

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

What is information hiding?

A

The process of hiding all details of an object that do not contribute to its essential characteristics

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

What is abstraction by generalisation?

A

Grouping common characteristics to arrive at a hierarchical relationship of the inheritance type

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

What is procedural abstraction?

A

Abstracting values used in a computation to leave a single computational method (procedure)

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

What is functional abstraction?

A

Abstracting the method of computation and the resultant function only focuses on inputs and outputs (functions)

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

What is data abstraction?

A

Isolating how a compound data structure is used from how it is constructed

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

What is problem abstraction (reduction)?

A

Removal of detail until it is possible to solve because it reduces to one that has already been solved

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

What is decomposition?

A

The process of breaking down a complex problem into smaller sub-problems. Each sub-problem accomplishes a specific task that is easier to solve. These can be further subdivided until a problem is solvable.

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

What is composition?

A

Form of abstraction which combines procedures to form compound procedures to solve a complex problem

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

What is automation?

A

The process of using abstractions of real world phenomena (models) to solve problems

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

How is automation done?

A

Create algorithms, implement in code, making models in data structures and executing code on data structures

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

What are the components of a finite state machine?

A
  • Finite set of input symbols (alphabet)
  • Finite set of states
  • Initial state (S0)
  • State transition functions
  • One or more accepting states
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is a finite state machine?

A

A model to show how a machine changes from one state to another based on external input.

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

How can we represent a finite state machine?

A

1) State transition diagram
2) State transition table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is the initial state symbol in state transition diagrams?
26
What is the accepting state symbol in state transition diagrams?
27
What is the transition symbol in state transition diagrams?
28
What is transition symbol **with output** in state transition diagrams?
29
What are the columns in a state transition table?
Current state, input, output, next state
30
What are the uses of FSM's?
- digital (hardware) systems - software compilers - syntax parsing - network protocols
31
What does it mean for a finite state machine to be deterministic?
The next state is only dependent on the current state and input and hence **requires no memory**.
32
What do you call a finite state machine that doesn't produce an output?
Finite State Automata
33
Which set is the subset of any set?
The empty set
34
What is a set?
An **unordered** collection of values where each value **occurs at most once**.
35
How to denote set where each element is dependent on certain predicates?
*S = { e | p }* where e is the **expression** and p is the **predicates**
36
How to show AND and OR in set notation?
- ∧ is AND - upside down ∧ for OR
37
What datatype is compact representation used for?
Strings
38
How to show a compact representation of a string with equal numbers of 1s and 0s?
{ 0n1n | n >= 1} where n must be a **countable** number
39
What is a finite set?
A set whose elements can be counted off by **natural numbers** (at which point the set stops). The number of items in the set is referred to as its cardinality.
40
What is an infinite set?
A set with an infinite number of items.
41
What is the difference between a countably infinite set and a non-countable infinite set?
A countably infinite set is an infinite set where the items can be counted off by the natural numbers. R is non-countable infinite set.
42
How to do the cartesian product of sets?
A x B is the set of all ordered pairs (a,b) where a is an element of A and b is an element of B.
43
What is a subset?
A subset (X) of the set S is a set whose values are all members of S. denoted as X ⊆ S
44
What is a proper subset?
A subset that does not contain **all** of the elements of the original set. denoted as X ⊂ S
45
What are the different operations that you can do on sets and what do they do?
- Union - ∪ - all elements in either set or both - Intersection - ∩ - elements shared by both sets - Difference - / - A/B is all the elements in A but not in B (also written as A-B)
46
What is a tractable problem?
If a problem can be solved in polynomial time, it is described as **tractable**.
47
What happens to the tractability of a problem if the size of the dataset increases?
It will remain the same tractability as tractability is not dependent on the size of the dataset. // Sorting algorithms are always tractable.
48
What are heuristics?
A heuristic approach employs a method of finding a solution that might not be the best. (reducing problem space or changing constraints)
49
What is a regular expression?
A way of describing the set of strings that conform to a particular pattern in a simple way.
50
What are the metacharacters in regular expressions?
| - or **takes everything on both sides unless contained by brackets** ? - 0 or 1 occurence of the preceding element * - 0 or more repetitions of the preceding element + - 1 or more repetitions of the preceding element () - used to group regular expressions
51
What are the uses of regular expressions?
- Expressing regular languages including those of FSMs - Validating user input
52
What is a regular language?
A regular language is one that can be represented by a regular expression.
53
What is a context-free language?
A language (set of strings) that are defined by context-free grammars, which are made up of production rules.
54
What is the difference between context-free languages and regular languages?
All regular languages are context-free but not all context-free languages can be represented as a regular expression.
55
What are the elements of context-free grammars?
- Terminal symbols - characters in a string that **cannot be broken down further** - Non-terminal symbols - defined in other production rules - Production rules - the rules for replacing the non-terminal symbols
56
What is Backus-Naur Form notation and what symbols does it use?
It is a **meta-language** used in order to define **context-free grammars**. Symbols: - - non-termincal symbols - n - a terminal symbol - :: = ab - a production rule, in this case is an a followed by a b
57
What are syntax diagrams used for?
A way of expressing context-free grammars using BNF rules.
58
What are the symbols for terminal symbols, non-terminal symbols and moving from one symbol to another?
59
What are the benefits of Backus-Naur Form?
- nested brackets cannot be represented in regular expressions - can represent irregular languages
60
When is a context-free language not regular?
If recursion occurs **between other symbols** it is irregular
61
How to write a recursively-defined production rule in Backus-Naur form?
= |
62
What is used to classify an algorithm?
- The time they take to complete - The space (memory) that is required to process the algorithm - For a given size of dataset
63
What is a function?
The mapping of a domain of values to a co-domain.
64
What are the time complexity graphs?
65
What time complexity is associated with permutations?
- O(n!) - factorial time complexity, increase at a greater rate than exponential functions - Considered to be intractable
66
How to determine time complexity of an algorithm?
The step with the worst time complexity determines the overall Big O.
67
What problems cannot be solved computationally?
Problems where there is **no certain outcome** or because **limits of hardware** make solving the problem with a certain outcome impractical
68
What time complexity is nested loop?
O(n^2)
69
How to recognise constant time complexity?
Time is independent of input
70
How to recognise logarithmic complexity?
Halves the number of items each iteration
71
How to recognise linear time complexity?
In a worst case scenario, go through each item once
72
How to recognise O(n^2)?
Nested loop
73
What is the Halting problem and what is the significance of it?
- An algorithm cannot be written that can determine whether another algorithm will finish with a given input - The halting problem demonstrates that there are some problems that are non-computable
74
Define the set of real numbers.
The set of all possible real-world quantities; Includes all rational and irrational numbers; A value that represents any quantity along an infinite number line;