2.2 Problem Solving and Programming Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is iteration?

A

Repeating code a set number of times or until a condition is met

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

What is selection/branching?

A

Taking different paths through the code based on a condition

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

What is sequence?

A

The order the instructions are in

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

What is a variable?

A

A space in memory allocated to store a value that can change and be recalled in the program

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

What is a constant?

A

Fixed values that do not change during run time

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

What are naming conventions?

A

Important when programming that you agree within a project team on suitable naming conventions

Variable and constant can’t start with a number or symbol and cannot contain spaces

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

What is recursion?

A

Where a subroutine calls itself

Method of solving a problem where the solution depends on solving increasingly smaller instances of the same problem

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

What are the characteristics of recursive algorithms?

A

Base case (stopping condition)

For any input values other than the one that meets the base case, subroutine should call itself

General case

Must have finite number of iterations or a memory error will occur (stack overflow)

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

What is a base case?

A

Condition to determine when the algorithm should stop calling itself

Point when you know the answer to that part of the problem

Where the problem has got as small as it can get and therefore starts to unwind

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

What is the stopping condition used to halt a recursive algorithm called?

A

Sentinel or rogue value

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

What is a general case?

A

Way of defining the problem which references a decreasing in size version of the problem

Statement that expresses the solution to a problem in terms of a reference to a smaller version of that same problem

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

What are the benefits of a recursive approach opposed to an iterative approach?

A

Can be CLOSER TO NATURAL LANGUAGE AND EASY TO UNDERSTAND

Can be SHORTER AND EFFICIENT

Can be good to iterate through a tree structure (good when algorithm needs to branch off e.g. a flood fill or tree)

Can provide a solution when iterative code is very long and complex

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

What are the drawbacks of a recursive approach opposed to an iterative approach?

A

NOT MEMORY EFFICIENT - lot of local variables

Uses stacks to store all the data and therefore if a recursive algorithm calls itself too many times then it may run out of memory on the stack

Some data will need to be stored for a long time until algorithm unravels

Can be slower to execute because of maintenance of stack that needs to go on during the execution

Can be DIFFICULT TO CODE AND DIFFICULT TO TRACE

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

How can a recursive algorithm be used in binary search trees?

A

On each comparison, sent left or right so values in other subtree don’t need to be searched

Tree must be balanced to be as efficient as binary search

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

What is a balanced tree?

A

Every leaf is around the same distance away from the root as any other leaf

Doesn’t need same number of nodes on each side but should be same length

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

What is an unbalanced tree?

A

One or more leaves are much further away from the root than other leaf

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

How can recursion be used for a binary search?

A

Algorithm returns True if value found and False if not

Takes two arguments: node (current node being examined) and search_item (item being searched for)

As data stored in tree, refer to each element as node rather than item

Node is structure containing data (simple value attached to node); right (reference to node to right); left (reference to node to left)

If no node to right, right value = Null

If no node to left, left value = Null

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

Where local variables declared?

A

Inside the subroutine

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

What is the scope of a local variable?

A

Cannot be accessed outside the subroutine

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

What happens to a local variable when the subroutine has finished executing?

A

Value in local variable deleted and cannot be recalled - meaning memory used only during subroutine then deleted

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

How do subroutines access local variables?

A

Variables have to be passed/returned between subroutines

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

Can local variables be named the same?

A

Yes, if they are in different subroutines

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

Where are global variables declared?

A

Outside of the subroutine

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

What is the scope of global variables?

A

Can be access from inside any subroutine

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

What happens to a local variable when the subroutine has finished executing?

A

Value remains in the variable - stored in memory throughout the entire program

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

When do global variables require memory?

A

Memory allocated at the beginning of the program and throughout the program

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

What is a problem with using global variables?

A

Makes integrating modules tricking as the other module may have a global variable of the same name

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

If there are two variables with the same name (one local and one global), which one will data be written to unless specified?

A

Local

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

What are the different ways that data can be passed into a subroutine?

A

Passing by value

Passing by reference

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

What is passing by value?

A

A copy of the value is sent as a parameter and when changes are made inside the subroutine, they don’t change the original value

Creates increased demand on RAM

Parameter has local scope

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

What is passing by reference?

A

A pointer to the memory location holding the value is passed as a parameter and when changes are made inside the subroutine, they also change the original value

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

What are subroutines?

A

Named section of code that can be called by writing the subroutines name in a program statement

Makes the code more readable and usable as the code is broken into smaller sections

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

What are the types of subroutine?

A

Procedure

Function

34
Q

What is a procedure?

A

Set of instructions that will be executed when the procedure is called

DOESN’T return a value when called

35
Q

What is a function?

A

Set of instructions that will be executed when the function is called

DOES return a value when called

36
Q

What is modularity?

A

Technique for breaking down a complex system into smaller components called modules, which can each be developed independently and contain everything required to execute one part of the overall application

37
Q

What does IDE stand for?

A

Integrated Development Environment

38
Q

What is an IDE?

A

Specialist piece of software that can help you code, interpret your code and show you how it would run

39
Q

What are the IDE tools?

A

Editor

Error diagnostics

Run-time environment

Translators

40
Q

What is an editor?

A

Lets you write and edit code

41
Q

When is an editor used?

A

When writing code

42
Q

What are the functions of an editor?

A

Highlighting key words (colour)

Autocompletion (keywords/brackets)

Auto indentation (to keep code organised and help identify program flow)

Line numbering (to help when debugging code)

43
Q

What does error diagnostics do?

A

Enables you to DEBUG code

44
Q

When is error diagnostics used?

A

When writing code

45
Q

What are the features of error diagnostics?

A

Error description

What line error is on

Breakpoint

46
Q

What is a breakpoint?

A

Added to code to pause the execution of code at a certain point

47
Q

What does a breakpoint enable the developer to do?

A

Examine/trace/watch values stored in variables at that point in code

Step through the code line by line to identify the exact place where the error occurs

Step though the code line by line to watch the values in the variables to identify when and how they change

48
Q

What does step into mean?

A

Steps into execution of a subroutine when called - allows developed to trace the variables and identify the exact actions within the subroutine call

49
Q

What does step out mean?

A

Steps out of a subroutine execution and back to the main code

50
Q

What does step over mean?

A

Steps to the next line of code

51
Q

What is tracing?

A

Traces/watches the values of variables at any certain point within code to see what values are stored within those variables or how values in those variables change as the program executes

52
Q

When is a run-time environment used?

A

When testing code

53
Q

What is a run time environment?

A

Allows the coder to test their code by entering inputs and seeing what the outputs will be

Allows the developer to test their code WITHOUT NEEDING TO OPEN AN ADDITIONAL PIECE OF SOFTWARE OR COMPILER

When coder is happy with code, can be exported

53
Q

What is a translator in an IDE?

A

IDE needs to be able to translate your code into machine code to enable the code to run in the run-time environment

Converts source code to machine code that a computer can process

54
Q

What are other features of an IDE?

A

Enables TEAM OF DEVELOPERS TO WORK TOGETHER as they may be able to check in and out files as they are working on them

Supports VERSION CONTROL so previous code can be relocated if needed

Often generates DOCUMENTATION (e.g. data dictionary)

55
Q

What are the characteristics of a problem solvable by computational methods?

A

Clear definition of problem
- end goal?
- successful solution?
- current situation/problem?
- likely problems whilst solving?

Able to identify calculations
- perform processing/calculations?
- in required amount of time?

Data requirements
- enough storage?
- storing data?

Use of abstraction and decomposition
- remove unnecessary data?
- break problem down?

55
Q

What does it mean a computer can be solved by computational methods?

A

If an algorithm can be developed that SOLVES ALL INSTANCES of the problem in a FINITE number of steps/REASONABLE amount of time

56
Q

What is an intractable problem?

A

A problem that can’t be solved by a computer in a reasonable amount of time

57
Q

What are the different ways we can solve problems?

A

Enumeration

Simulation

Theoretical approach

58
Q

What is enumeration?

A

Where problems are solved using brute force and exhaustive search

Checking through all possibilities until you find the correct one

59
Q

How can a simulation be used to solve a problem?

A

A computer could be used to create a simulation

Used to model a system, predict behaviour and outputs

60
Q

How can a theoretical approach be used to solve a problem?

A

If a problem can be solved by a mathematical formula or theory then it will be solved by computational methods

61
Q

What is problem recognition?

A

Identifying what the problem is that we need to solve

62
Q

What are things to think about in problem recognition?

A

What the problem is

How it can be solved using computational methods

63
Q

What other techniques can help problem recognition?

A

Visualisation

Abstraction

Decomposition

64
Q

What is decomposition?

A

Breaking a problem down into smaller sub-tasks which are easier to solve

65
Q

What is a divide conquer algorithm?

A

Reduces the size of the problem with each iteration

66
Q

What are examples of divide and conquer algorithms?

A

Binary search

Quick sort algorithm

67
Q

What is backtracking?

A

Incrementally building up towards a solution, abandoning partial success when the solution cannot be completed and then going back to a previous successful point

68
Q

What are the uses of backtracking?

A

Good for route finding problems

Finding an alternative route in a network if part broken

69
Q

What is big data?

A

The collection of large amount of data on a particular topic

Humans cannot search through all this data and make connections

70
Q

What is data mining?

A

Allows a computer to analyse big data

Spot patterns and trends, make connections and use those connections to enable businesses etc to make decisions

71
Q

What is heuristics?

A

Makes use of previous knowledge/experience to find a solution that is not always optimum but is good enough

72
Q

What are the uses of heuristic algorithms?

A

AI

Language recognition

Big data analysis

Shortest path algorithms

Machine learning

73
Q

When is performance modelling completed?

A

Before the application is released

74
Q

What is performance modelling?

A

Predicting how our computer system will perform as the level of usage increases using mathematical formulas

75
Q

What are the questions asked during performance modelling?

A

Will it be able to cope with the number of users?

Will it run at an acceptable speed?

Will it scale well as more people start to use it?

Where is the breaking point? (STRESS TESTING)

Will it crash when the user enters erroneous data?

76
Q

What is pipelining?

A

Splitting a task up into smaller tasks so the output of one task is the input of the next

Allows multiple tasks to be executed simultaneously and therefore speeds up performance

77
Q

What is software pipelining?

A

Same concept as instruction pipelining

Task must be able to be split up into a series of sub tasks

Each sub task must lead to the next

78
Q

What is visualisation?

A

The ability to picture a problem and its solution in a visual way, making it easier to spot patterns, make connections, solve the problem or analyse data

79
Q

What are data visualisation algorithms?

A

Used in most software (or video games) which are based on GUI

Provide more intuitive, user-friendly visual representation of data

Wide range of techniques and algorithms used to represent data in a visual way often using maths concepts (2D/3D coordination, trigonometry, proportionality)