Unit 2 - Problem solving and theory of computation Flashcards

1
Q

What is Structured programming?

A

Structured programming is a method of writing a computer program which uses:
Top-down analysis for problem-solving.
Modularization for program structure and organisation.
Structured code for the individual modules.

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

What is top-down analysis?

A

The program is divided into modules, which are called from the main program.
Any of the modules may be further broken down into smaller sub-tasks, with the smallest modules performing a single function.
A hierarchy chart may be used to show the overall program structure.

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

How does a hierarchy chart work?

A

Execution takes place from left to right, always at the lowest level component.
Selection and iteration are not shown in a hierarchy chart.
Any module shown below another module is part of the module above.

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

What are some benefits of structured programming?

A

Programs are more easily and quickly written:
Large programs are broken down into subtasks that are easier to program and manage.
Each module can be individually tested.
Modules can be re-used several times in a program.

Programs are more reliable and have fewer errors:
It is easier to find errors in small self-contained modules.

Programs take less time to test and debug.

Programs are easier to maintain:
A well-organised, modular program is easier to follow
It is easier to find which module needs to be changed
Self-contained modules mean that the change should not affect the rest of the program.

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

What is modular programming?

A

Subdividing a computer program into separate sub-programs

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

Why do we use modular programming?

A

Modular design and programming techniques are most useful for large, complex programs.
Some programs have thousands or even millions of lines of code.

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

What is the aim of structured programming?

A

Can be thoroughly tested and proved to be error free.
Are easy to understand and maintain.
Minimise duplication of effort.

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

Why are hierarchy charts used?

A

They’re a useful design tool for breaking down a large program into manageable chunks.
They’re useful for documentation purposes.

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

What is computational thinking?

A

The ability to think logically about a problem and apply techniques for solving it

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

What are some methods of problem solving?

A

Simulation
Enumeration – list all cases
Trial and error
Theoretical approach
Creative solution

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

What is simulation?

A

The process of designing a model of a real system in order to understand the behaviour of the system, and to evaluate various strategies for its operation.

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

What are the properties of a good algorithm?

A

Has clear and precisely stated steps that produce the correct output for any set of valid inputs.
Should allow for invalid inputs.
Must always terminate at some point.
Should execute efficiently, in as few steps as possible.
Should be designed in such a way that other people will be able to understand it and modify it if necessary.

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

What are some useful tools for designing algorithms?

A

Hierarchy charts – useful for identifying the major task, and breaking these down into subtasks

Flowcharts – useful for getting down initial ideas for individual subroutines

Pseudocode – will translate easily into program code

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

What are some examples of sorting algorithms?

A

Bubble sort and Merge sort.

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

How does bubble sort work?

A

To sort an array of n items, n-1 passes are made through the array, with each item being compared with the adjacent item and swapped if necessary.

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

What does ‘divide and conquer’ mean?

A

This involves finding a solution to a sequence of smaller, related problems until the instance is small enough to be solved directly.

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

How does a merge sort work?

A

Divide the unsorted list into n sublists, each containing one element
Repeatedly merge sublists to produce new sorted sublists until there is only one sublist remaining. This is the sorted list.
An example of a ‘divide and conquer’ algorithm.

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

What are some examples of searching algorithms?

A

Linear search and binary search.

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

How does a linear search work?

A

Starts at the beginning of the list and examines every item.

20
Q

How does a binary search work?

A

Uses the “divide and conquer” strategy to halve the search area each time an item is examined.
Can only be used if the list is ordered.

21
Q

What is the purpose of testing?

A

The purpose of testing software is to reveal errors.
A good test is one which uncovers an error in the program.

22
Q

What are the different stages of testing?

A

Module testing
Program testing
System testing

23
Q

What does module testing do?

A

Make sure each subroutine works correctly.

24
Q

What does Program testing do?

A

Make sure each program in the system works correctly.

25
Q

What does system testing do?

A

Make sure the whole system works as expected, and does what the original specification required.

26
Q

What is normal data?

A

Typical, sensible data that the program should accept and be able to process.

27
Q

What is boundary data?

A

Valid data that falls at the boundary of any possible ranges, sometimes known as extreme data.

28
Q

What is erroneous data?

A

Data that the program cannot process and should not accept.

29
Q

What is information hiding?

A

Means
hiding design details behind a
standard interface.

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

30
Q

What is abstraction?

A

Removing unnecessary details of a problem to make it more manageable and easier to solve.

31
Q

What is representational abstraction?

A

An abstraction arrived at by removing unnecessary details.

32
Q

What is abstraction by generalisation?

A

Means grouping by common characteristics to arrive at a hierarchical relationship of the ‘is a kind of’ type.

33
Q

What is automation in terms of abstraction?

A

Refers to building models of real world objects or phenomena in order to solve a particular problem.

34
Q

What is procedural abstraction?

A

Refers to the mechanisms in computer programming that enable and enforce the abstraction of operations.

35
Q

What is functional abstraction?

A

Referring to the practice of identifying and expressing a task, or function, in a manner that separates what the task accomplishes from how it’s accomplished.

36
Q

What is data abstraction?

A

A specific type of abstraction that involves simplifying data structures in order to make them easier to work with.

37
Q

What is problem abstraction?

A

Details are removed until it becomes possible to represent the problem in a way that is possible to solve.

38
Q

What is procedural decomposition?

A

Breaking a problem into a number of sub-problems, so that each sub-problem accomplishes an identifiable task.

39
Q

What is composition?

A

The opposite of decomposition.
It is the process of combining procedures to form a compound procedure.

Combining data objects to form compound data objects such as a tree or stack.

40
Q

What is a finite state machine?

A

It is an abstract representation of how something changes from one state to another in response to a condition or event.

41
Q

What is a transition in a finite state machine?

A

A change from one state to another in response to an event or condition.

42
Q

What are some applications of FSM’s?

A

Robotics.
Video games industry.
Design of digital hardware systems.
Design of compilers and network protocols.

43
Q

What is a finite state automaton?

A

A FSM which has no output.
They have an initial state and one or more accepting or goal states.
It simply runs through the input sequence of symbols, one by one, changing state or not as a result of the current state
and the current symbol from the input it sees.
On reaching the end of the input, it stops and, depending on which state it stopped in, accepting state or a non-accepting state, it is able to decide whether the input sequence has met the criteria or not - accepted or not accepted.

44
Q

How can you avoid a FSM having to report an error?

A

Ensure that for each state there is an outgoing transition for every symbol in the machine’s input alphabet.

45
Q

What is a state transition table?

A

A state transition table shows the effect of particular inputs on the
current state of an FSM with no output.

46
Q

Why are finite state machines useful?

A

Finite state machines (FSMs) are used extensively in applications in computer science. For example, finite state machines are the basis for
* Any kind of controller, e.g. traffic lights
* Specifying a language, e.g. given any string, an FSM determines if
that string is in the language or not
* Programs for:
– spell checking
– grammar checking
– indexing or searching large bodies of text
– recognising speech
– processing text containing mark-up languages such as XML
and HTML
* networking protocols that specify how computers communicate.