Problem solving and programming Flashcards

(46 cards)

1
Q

What is a data type?

A
  • A classification of data into groups depending on the type of data they represent
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is casting?

A
  • The process of converting a piece of data from one data type to another
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are arithmetic operators?

A
  • Symbols or keywords used to perform mathematical calculations and operations on numerical values
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the modulus operator and what does it do?

A
  • MOD
  • Returns the remainder when one number is divided by another
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are logical operators?

A
  • Symbols or keywords used to compare values and return a boolean result
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are boolean operators?

A
  • Symbols or keywords used to combine and manipulate boolean values
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a programming construct?

A
  • A programming construct determines the order in which lines of code are executed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is branching?

A
  • Also known as selection
  • The flow of the program is interrupted and a condition is tested
  • The outcome of this condition will determine which lines of code are run next
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a switch/case statement?

A
  • A type of conditional statement that provides an alternative way to perform multiple comparisons based on the value of an expression
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

An example of a switch/case statement

A

grade = ‘b’
match(grade)
case ‘a’:
print (“perfect”)
case ‘b’:
print (“good”)
case_:
print (“bad)

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

What is iteration?

A
  • The process of doing something more than once
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the different types of iteration?

A
  • A loop can be count controlled (for loop) or condition controlled (while loop)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the difference between a while loop and a do while loop?

A
  • They are both condition controlled
  • The code within a do while loop will always run atleast once while the code within a while loop may not run at all
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How to code a do while loop

A

variable = x
do
print (x)
until condition

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

What is modularity?

A
  • A concept where problems are broken down into more manageable pieces
  • Each piece of the problem should be carried out by a single subroutine
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the difference between a function and a procedure?

A
  • A function will return a value
  • A procedure will NOT return a value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is a parameter?

A
  • A piece of data that is input into a code block such as a procedure or function so that it can complete its task
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the difference between byValue and byReference parameter passing?

A
  • byValue: any changes to the parameter within the function do not affect the original value outside of the function
  • byReference: changes to the parameter within the function directly affect the original value outside of the function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is recursion?

A
  • A function calls itself to solve a problem or complete a task
  • Uses self-reference to break down a task into more manageable sub-problems
20
Q

What are the features of a recursive algorithm?

A
  • The function must call itself
  • A base case: it can return a value without further recursive calls
  • A stopping base: must be reachable after a finite number of calls
21
Q

How does recursion work?

A
  • The function calls itself with a modified input parameter until it reaches a base case - a condition that stops the recursion and provides the final result
22
Q

Why does recursion need a proper stopping condition?

A
  • To avoid stack overflow
  • This is when a stack will run out of space and will be unable to store any more data, causing the program to crash
23
Q

Pros and cons of recursion

A
  • Pros: concise and simple
  • Cons: performance issues after many calls, debugging difficulty, limited application
24
Q

What is a global variable?

A
  • A variable declared at the outermost level of the program
  • They are declared outside any modules or functions
  • They can be accessed and modified from any part of the program
25
Pros and cons of global variables
- Pros: only needs to be declared once, don't need to keep passing parameters between modules - Cons: always stored in memory (takes up space), makes the program difficult to maintain, makes it difficult to test singular blocks as the programmer will need to run the whole program
26
What is a local variable?
- A variable declared within a specific scope, such as a function or procedure - Only accessible within the block they are defined in - Once the execution of the block of code ends, the variable is destroyed and the memory is released
27
Pros and cons of local variables
- Pros: encapsulate data (provide data hiding), allow you to use the same variable name in different functions to represent different variables, limited lifetime and memory is freed immediately - Cons: repeated creation and destruction of variables leads to memory overhead, excessive use within nested blocks can lead to code clutter
28
What is an IDE?
- An Integrated Development Environment - A software tool that provides developers with a comprehensive and integrated platform to write, edit and compile their code
29
What are the features of an IDE?
- Syntax highlighting: visually distinguish different elements of code - Auto-complete: suggest code completion as the developer types - Auto-indent: automatically indent the code on a new line - Code comments: used to document code - Syntax error highlighting: essential for debugging - Variable watch window: allows developers to watch the values of different variables as the program runs - Error message list: displays a collection of errors for debugging - Crash dump: error report at the end of execution
30
What are computational methods?
- A set of problem-solving techniques that use algorithms and mathematical models to analyse, simulate and solve complex problems efficiently using a computer
31
What is problem recognition?
- Determining if there is a problem that needs to be solved - Determining whether it can be solved using software
32
What are the steps of divide and conquer?
- Divide: problem is broken down into sub-problems - Conquer: sub-problems are solved independently - Combine: solutions of the sub-problems are combined to form the overall solution to the problem
33
Pros and cons of divide and conquer
- Pros: can make programs more time efficient, can make effective use of cache memory (problems are broken down) - Cons: not all problems can be broken down and solved independently, cause stack overflow
34
What is backtracking?
- A technique that is used when you don't have enough information to solve a problem, or if you have many ways to solve a problem - It will explore all possible paths in the search space to determine if these come to a dead end - It will build up partial solutions to a large problem incrementally and then if the solution fails, the partial solutions are abandoned, and the search begins at the last potentially successful point
35
Pros and cons of backtracking
- Pros: it is guaranteed to find a solution if one exists, it is easy to implement and use, it can be applied to a variety of problems - Cons: it is not ideal for solving strategic problems, it can have high time complexity, it can consume a lot of memory
36
What is data mining?
- When large quantities of data are turned into useful information so that patterns can be found - It can be used to search for relationships and facts that are not immediately obvious
37
Pros and cons of data mining
- Pros: can be used to identify trends and patterns, can help organisations make better future predictions - Cons: it requires very powerful computers, inaccurate data can provide inaccurate results, it may not explain the reasoning behind trends and patterns
38
What are heuristics?
- Makes use of experience to find a solution to a problem quickly - Prioritises speed over accuracy - It aims to find a solution that is "good enough"
39
Pros and cons of heuristics
- Pros: can find a solution close to the best solution available, save a lot of time, very practical and can be implemented easily - Cons: it will not guarantee that you will find the best solution, needs careful consideration between speed and accuracy, heuristic value may be incorrect
40
What is performance modelling?
- When the behaviour of something is tested or simulated before it is used in the real world - This can be used for evaluating and predicting the performance characteristics of a software system
41
What is the aim of performance modelling?
- To help understand how the software will behave under different load conditions and configurations
42
Pros and cons of performance modelling
- Pros: stress testing ensures a system can cope with a large set of data, you will be able to predict problems and act on them quickly - Cons: outcome is only as useful as the accuracy of the data, if the rules of the simulation are wrong then the results will be inaccurate
43
What is pipelining as a computational method?
- The process of carrying out multiple instructions concurrently - Improves the overall efficiency and performance of a task
44
What are the steps of pipelining?
- Break down the problem - Arrange the sub-problems in sequential order - Allow multiple tasks to operate at the same time
45
What is visualisation?
- When data or concepts are presented in a simpler form for humans to understand - Often create a visual or graphical representation of something to understand complex data
46
Pros and cons of visualisation
- Pros: can simplify concepts that are easier for humans to understand, can make it easier to spot new trends and patterns - Cons: cannot explain why data is the way it is, different people may interpret the visualisations in different ways