Week 10 - Algorithms & Recursions Flashcards
1
Q
What are the 5 parts which define an algorithm?
F D EP PO TI
A
- Finite - it ends
- Definite - it isn’t subjective and is precise
- Effective Procedure - can be carried out effectively
- Produces Output - has a result or effect
- Takes Input - obtains values to use
2
Q
What’s an example of an algorithm?
A
Rounding pi to 5 decimal places.q
3
Q
What does computational complexity measure?
A
How efficient programs are and the relationship between performance and data sets.
These two things are can be related quadratically, linearly, exponentially, logarithmically or by a constant value.
4
Q
What does n represent?
A
Can be either time or memory.
5
Q
Recursion
A
A process of looping where the program will call itself.
It’s also related to the mathematical topic called proof by induction where similar methods are used to show something is true for n and for n+1.
6
Q
What are the 3 parts of recursion?
I
R
T
A
- Initialisation: declaring a counter
- Repetition: incrementing the counter
- Terminations: ending the counter using conditional statements or end keywords.