4.4 Theory of Computation Flashcards

1
Q

What is a set in the context of regex

A

an unordered collection of values in which each value occurs at most once.

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

A language is regular if it can be represented by

A
  1. A regular expression
  2. A Finite State Machine
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does a.e mean in regex

A

Matches any word that starts with a and ends with e

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

what does ^Hello mean

A

Matches any line that starts with Hello

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

What are regular expressions

A

Special sequences of characters that can be used to find or match patterns in text

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

If there is no symbol between symbols what does that mean

A

Members side by side must appear in that sequence

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

What does the pipe symbol mean|

A

Separates alternative options

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

What does the symbol * mean in context of regex

A

Indicates that there are zero or more of the preceding element

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

What does the symbol + mean in the context of regex

A

Indicates that there is one or more of the preceding elements

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

What does the symbol ? mean in the context of regex

A

Indicates that there are zero or one of the preceding element.

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

What does () symbol mean in the context of regex

A

Used to identify groupings

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

An 01 pair repeated any number of times

How is it represented in regex

A

(01)*

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

In the context of set comprehension

A = { x | x ∈ N ^ x != 0 }

define the variables

A

A represents the set

{}: This denotes a set. Sets are collections of distinct elements.

x: A variable that represents the elements of the set.

∣: The vertical bar is read as “such that” or “where”. separates the variable from the condition that the elements must satisfy.

natural numbers (N)

∈ = “is an element of”

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

What is a turing machine

A

A computer with a single fixed program expressed using:

A finite set of states in a state transition diagram.
A finite alphabet of symbols.
An infinite tape with marked off squares.
A sensing read-write head that can travel along the tape, one square at a time.

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

A⊆B

A

A is a subset of B

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

A⊂B

A

A is a proper subset of B

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

Difference between subset and proper subset

A

A is a proper subset of B if every element in A is also in B, but B has at least one extra element not in A

A normal subset does’nt have to satisfy this last condition.

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

What is the cartesian product

A

The cartesian product of two sets A and B is the set of all ordered pairs (a,b)

Let’s say A = {1, 2} and B = {x, y}.

The Cartesian product of A and B would be {(1, x), (1, y), (2, x), (2, y)}.

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

What is cardinality and what is denoted by

A

Cardinality- It represents the count of distinct elements within a set.

|A|

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

In any one transition the turing machine can: (3)

A

Read the symbol on the tape.

Erase or write a new symbol on the tape.

Move the head left or right by a single machine.

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

What is Backus Nuar Form

What is a meta language

A

a formal notation used to describe the syntax rules of a language unambiguosly

A language that describes a language

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

Why does Backus Nuar form exist when there are RNF (2)

A

Because not every language or pattern can be represented as a regular expression

meta-languages such as BNF have been devised

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

In the context of BNF what does this symbol mean ::=

A

Is defined as

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

In the context of BNF what does this symbol mean |

A

Or

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

In the context of BNF what does this symbol mean <>

A

Surrounds category names

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

In the context of BNF what does it mean items are ( Side by side )

A

they should appear consecutively or in sequence.

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

In the context of BNF what are terminal symbols

A

basic symbols or literals that appear in the language being defined.

They cannot be broken further down.

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

What are the two ways of representing context free languages

A

Syntax diagrams

BNF

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

What are syntax diagrams

A

graphical equivalent of BNF

30
Q

In the context of syntax diagrams what does a rectangle represent

A

a non terminal symbol, which will be defined in another syntax diagram.

31
Q

In the context of syntax diagrams what does an ellipses represent

A

a terminal symbol, cannot be further broken down

32
Q

What is a finite state machine (1)

A

An abstract machine that can be in any one of a finite number of states

33
Q

What are the characteristics of a finite state machine (FSM) (3)

A
  1. Can only be in one state at time.
  2. can change from one state to another in response to an event, known as a transition
  3. Defined by a list of its states and the conditions for each transition
34
Q

What is a finite state automaton (2)

A
  1. An FSM which has no output is known as a finite state automaton
  2. It has a set sequence for the final state
35
Q

What is a mealy machine

A
  1. A type of FSM
  2. generates an output on each state transition
  3. The output is determined by its current state and its current input.
36
Q

What is the notation used for mealy machine

A

input/output = 0/1

37
Q

Functions of a mealy machine

A
  1. Can be used to map an input sequence to an output sequence.
  2. And it is used in language parsing (language analysis)
  3. Can be used to translate from one language to another.
38
Q

In order for source code of a given language to be translated into machine code:

A

All the rules of a given language must be defined totally ambiguosly

39
Q

What does BNF consist of (3)

A

A set of terminal symbols
A set of non-terminal symbols
A set of production rules

40
Q

what is the BNF representation for digits

A

<digit> ::= 0|1|2|3|4|5|6|7|8|9
</digit>

41
Q

If letter has been defined as:

<LETTER> ::= A|B|C|D...etc

How do we define a two letter word
</LETTER>

A

WORD ::= <LETTER> <LETTER></LETTER></LETTER>

42
Q

What are the applications of regular expressions (3)

A

Searching and locating files and folders

Find or search and replace text strings in a block of text

Input validation

43
Q

What is procedural abstraction

A

Procedural abstraction is a programming concept that involves breaking down complex tasks into smaller, reusable procedures

44
Q

What is functional abstraction

A

Same as procedural abstraction, but whilst ignoring the internal computation and simply outputting the result

45
Q

What is data abstraction

A

hiding the implementation details of data structures and exposing only the essential features

46
Q

What is problem abstraction

A

Removing details from a problem until you can represent it in a way that it is possible to solve, as you reduce it to one that has already been solved.

47
Q

What is procedural/problem decomposition

A

The process of taking a large problem and breaking it down into several smaller problems

48
Q

What is composition abstraction

A

Combining of appropriate procedures to form compound procedures

49
Q

What is automation

A

use of computational thinking and programming to create systems that perform tasks automatically without human intervention

50
Q

What is a finite state machine in logical terms

A

A model of computation used to design computer programs

51
Q

What does the set of values denoted by N represent

A

Infinite set of natural number

52
Q

What does the set of values denoted by Z represent

A

Set of all integers

53
Q

What does the set of values denoted by Q represent

A

Set of all rational numbers

54
Q

What does the set of values by R represent

A

Set of all real numbers

55
Q

What is meant by an infinite set

A

A set that has no end value represented by … at the end of the set

56
Q

What does it mean if a set is countable

A

A set that can be counted off against a subset of the natural numbers

57
Q

What is a subset

A

When every member of set is A is also a member of Set B this is a

subset

58
Q

What is a proper subset

A

If every member of A is in B, but b has additional values not in A, therefore A and B are not equal,

The A is a proper subset of B

59
Q

What does A/B mean in regex

A

Everything that is in set A but not in set B

60
Q

Which symbol represents “is an element of”

61
Q

What is parsing

A

Parsing is the process of analysing a sequence of symbols (such as text or code) to determine its grammatical structure based on a given set of rules (syntax)

62
Q

What is parsing in the context of BNF

A

Working out if a statement is valid according to BNF production rules

63
Q

What is meant by time complexity

A

How much time an algoritihm needs to solve a given problem

64
Q

What is meant by space complexity

A

The amount of memory an algorithim requires to solve a given problem

65
Q

What is meant by the permutation of a set of objects

A

The number of ways you can arrange those objects

66
Q

what is meant by the domain, range and codomain of a function

A

Domain is All the possible inputs of a function
Codomain is what the function could output (defined by the function).
Range is what the function actually outputs.

67
Q

What is meant by O(n) linear complexity

A

An algorithm whose performance is proportional to the size of the data set, where performance declines as the data set grows

68
Q

What is meant by O(logn) linear complexity

A

An algorithm that halves the data set in each pass, making it efficient for large data sets

69
Q

What is meant by the halting problem

A

Is it possible to write a program that given a description of another program and its inputs without executing the program, whether the given problem will halt.§

70
Q

What is the universal turing machine

A

a single machine that can be used to compute any computable sequence.

special type of Turing machine that can simulate any other Turing machine