4.4 Theory of Computation Flashcards

(37 cards)

1
Q

What is an Algorithm?

A

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

Algorithms are fundamental in computer science and programming.

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

Define Pseudo-code.

A

A way of expressing an algorithm in the style of a program, but without worrying about language-specific syntax

Pseudo-code is written for humans to understand.

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

What does Pseudo-code show?

A

The structure of any planned program using the standard constructs:
* Sequence
* Assignment
* Selection
* Iteration

These constructs help in visualizing the flow of the algorithm.

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

What is Sequence in programming?

A

A series of instructions that are executed in order

Sequence is the simplest form of control flow.

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

What does Assignment refer to in programming?

A

A value being assigned to a placeholder (variable)

Assignment is a fundamental operation in most programming languages.

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

Define Selection in programming.

A

Running instructions only if a condition is met (if)

Selection allows for decision-making in algorithms.

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

What is Iteration?

A

Repeatedly running instructions depending on a condition (for, while)

Iteration is essential for tasks that require repetition.

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

What is a Hand-trace?

A

Manually stepping through an algorithm line by line, adding to a table of placeholders (variables) each time a value is assigned to one

Hand-tracing helps in debugging and understanding algorithms.

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

In a Hand-trace, when is a new row used?

A

Each time the code loops, or a value is replaced

This helps to keep track of changes in variable states.

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

What is procedural decomposition?

A

Breaking down problems into sub-problems that accomplish identifiable tasks

Each sub-problem can also be decomposed into smaller sub-problems.

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

What is abstraction in problem-solving?

A

Removing details until the problem is represented in a solvable way

This can involve representational abstraction, generalisation, or procedural abstraction.

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

What is representational abstraction?

A

A representation arrived at by removing unnecessary details

Example: The London Underground map, which shows connections without geographical accuracy.

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

What does abstraction by generalisation or categorisation involve?

A

Grouping by common characteristics to define concepts

Example: Defining a cat as a kind of mammal, which is a kind of animal.

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

What is procedural abstraction?

A

Abstracting away actual values used in a computation to create a procedure

Example: Finding the mean average of numbers by outlining the procedure rather than using specific values.

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

What is functional abstraction?

A

Hiding the procedure used to achieve a result and presenting a function

Example: A mean() function that calculates the mean without exposing its internal workings.

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

What is data abstraction?

A

Hiding the real data structure to present a simpler, compound data structure

Example: A stack created using an array and a pointer, abstracting the details of data storage.

17
Q

What does composition abstraction entail?

A

Combining procedures to form compound procedures

Example: Creating a mean average procedure by combining sum and divide procedures.

18
Q

What is automation in problem-solving?

A

Putting models into action to solve problems

This involves creating algorithms, implementing them in code, and executing the code.

19
Q

What are models in the context of automation?

A

Clean, abstract versions of real-world objects or phenomena

The challenge is deciding what details to include or discard for accuracy.

20
Q

True or False: Procedural decomposition can lead to smaller sub-problems.

A

True

Each sub-problem can be further decomposed.

21
Q

What is a set?

A

An unordered collection of unique values

22
Q

How is set notation represented for a set A containing values 1 to 5?

A

A = {1, 2, 3, 4, 5}

23
Q

What does set A = {x | x ∈ Natural Numbers, x ≥ 1} represent?

A

Set A consists of those objects, x, such that x is a member of the Natural Numbers set and x is greater than or equal to 1

24
Q

What does the notation A = {0^n 1^n | n ≥ 1} indicate?

A

Set A consists of all strings consisting of n 0s and n 1s where n is greater than or equal to 1

25
What does {} or Ø denote in set theory?
An empty set, a set containing no elements
26
What is the cardinality of a finite set?
The number of elements in the set
27
What is an infinite set?
A set containing infinite elements
28
What is a countable set?
A set with the same cardinality as a subset of the natural numbers
29
What are the two types of countable sets?
* A finite set * A countably infinite set
30
What is a subset?
A set that consists only of elements contained in its parent set
31
Is {3, 5, 2} a subset of {2, 3, 4, 5, 6}?
Yes, because all of 2, 5, and 3 are in the main set
32
Can a set be a subset of itself?
Yes, a set is still a subset if it is equal to its parent set
33
What is a proper subset?
A subset that contains some, but not all, of the elements of its parent set
34
Is {1, 2, 3} a proper subset of {1, 2, 3}?
No, because it contains all elements of its parent set
35
cartesian product
X x Y the set of all ordered pairs where a is a member of A and b is a member of B e.g. {1,2,3} x {6,7} = {(1,6), (1,7), (2,6), (2,7), (3,6), (3,7)}
36
difference
A\B all the elements of A except for the values also in B {1,2,3,4}\{2,4,6,8} = {1,3}
37
finite state machine
models the behaviour of a system has a finite number of states a state transition diagram is used to represent a FSM