2.2 Problem Solving and Programming 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
What happens to a local variable when the subroutine has finished executing?
Value remains in the variable - stored in memory throughout the entire program
26
When do global variables require memory?
Memory allocated at the beginning of the program and throughout the program
27
What is a problem with using global variables?
Makes integrating modules tricking as the other module may have a global variable of the same name
28
If there are two variables with the same name (one local and one global), which one will data be written to unless specified?
Local
29
What are the different ways that data can be passed into a subroutine?
Passing by value Passing by reference
30
What is passing by value?
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
31
What is passing by reference?
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
32
What are subroutines?
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
33
What are the types of subroutine?
Procedure Function
34
What is a procedure?
Set of instructions that will be executed when the procedure is called DOESN'T return a value when called
35
What is a function?
Set of instructions that will be executed when the function is called DOES return a value when called
36
What is modularity?
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
What does IDE stand for?
Integrated Development Environment
38
What is an IDE?
Specialist piece of software that can help you code, interpret your code and show you how it would run
39
What are the IDE tools?
Editor Error diagnostics Run-time environment Translators
40
What is an editor?
Lets you write and edit code
41
When is an editor used?
When writing code
42
What are the functions of an editor?
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
What does error diagnostics do?
Enables you to DEBUG code
44
When is error diagnostics used?
When writing code
45
What are the features of error diagnostics?
Error description What line error is on Breakpoint
46
What is a breakpoint?
Added to code to pause the execution of code at a certain point
47
What does a breakpoint enable the developer to do?
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
What does step into mean?
Steps into execution of a subroutine when called - allows developed to trace the variables and identify the exact actions within the subroutine call
49
What does step out mean?
Steps out of a subroutine execution and back to the main code
50
What does step over mean?
Steps to the next line of code
51
What is tracing?
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
When is a run-time environment used?
When testing code
53
What is a run time environment?
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
What is a translator in an IDE?
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
What are other features of an IDE?
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
What are the characteristics of a problem solvable by computational methods?
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
What does it mean a computer can be solved by computational methods?
If an algorithm can be developed that SOLVES ALL INSTANCES of the problem in a FINITE number of steps/REASONABLE amount of time
56
What is an intractable problem?
A problem that can't be solved by a computer in a reasonable amount of time
57
What are the different ways we can solve problems?
Enumeration Simulation Theoretical approach
58
What is enumeration?
Where problems are solved using brute force and exhaustive search Checking through all possibilities until you find the correct one
59
How can a simulation be used to solve a problem?
A computer could be used to create a simulation Used to model a system, predict behaviour and outputs
60
How can a theoretical approach be used to solve a problem?
If a problem can be solved by a mathematical formula or theory then it will be solved by computational methods
61
What is problem recognition?
Identifying what the problem is that we need to solve
62
What are things to think about in problem recognition?
What the problem is How it can be solved using computational methods
63
What other techniques can help problem recognition?
Visualisation Abstraction Decomposition
64
What is decomposition?
Breaking a problem down into smaller sub-tasks which are easier to solve
65
What is a divide conquer algorithm?
Reduces the size of the problem with each iteration
66
What are examples of divide and conquer algorithms?
Binary search Quick sort algorithm
67
What is backtracking?
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
What are the uses of backtracking?
Good for route finding problems Finding an alternative route in a network if part broken
69
What is big data?
The collection of large amount of data on a particular topic Humans cannot search through all this data and make connections
70
What is data mining?
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
What is heuristics?
Makes use of previous knowledge/experience to find a solution that is not always optimum but is good enough
72
What are the uses of heuristic algorithms?
AI Language recognition Big data analysis Shortest path algorithms Machine learning
73
When is performance modelling completed?
Before the application is released
74
What is performance modelling?
Predicting how our computer system will perform as the level of usage increases using mathematical formulas
75
What are the questions asked during performance modelling?
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
What is pipelining?
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
What is software pipelining?
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
What is visualisation?
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
What are data visualisation algorithms?
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)