Recursion - Standard Flashcards

1
Q

Linear recursion

A

amount of information stored is dependend linearly on n (size) - creates a chain of defered operations

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

Tree/branching recursion

A

Like fibonnaci
for very large values of n, large recursive stacks are stored in memory making this type of recursion slow and memory inefficient

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

Tail recursion

A

recursive call is the last thing that is done before returning
- last call evaluates function’s value
nothing from the higher call eed to be stored
optimised for memory use

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

tail recursive factiorial

A

facAux 0 r = r
facAu n r = facAux (n-1)(r*n)

facTail n = facAux n 1

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

tail recursive fibonnaci (remember that is Tree recursive)

A

fibAux n r e s u l t previous
| n == 0 = r e s u l t
| otherwise = fibAux (n − 1) ( r e s u l t + previous ) r e s u l t

f i b T a i l n
| n == 0 = 0
| otherwise = fibAux n 1 0

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