Recursion Flashcards

(8 cards)

1
Q

What is recursion?

A

When a subroutine calls itself during its execution.

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

When does recursion stop calling itself

A

Until a certain condition is met, called the stopping condition.

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

Advantage of recursion?

A

For cerain problems, they can be represented in less lines of code.

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

What happens each time the function calls itself?

A

A stack frame is created within the call stack.

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

What is stored in the stack frame?

A

Parameters, local variables and return addresses

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

Whats the point of the stack frame?

A

It allows the subroutine to return to that specific point during its execution.

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

What is the meaning of the subroutine ‘unwinding’?

A

The process of information from the call stack being popped off the stack.

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

Disadvantages to recursion?

A

Inefficient use of memory.

Danger of stack overflow if the subroutine calls itself too many times.

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