Lecture 17 Flashcards

1
Q

What is recursion

A

Recursion is the idea of solving a problem in terms of itself.

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

The two main elements to recursive solutions are?

A

–The base case: the form (or forms) of the problem for which an exact solution is provided.
–The recursive step: the reduction of one version the problem to a simpler form.

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

N factorial Code

A
int factorial(int n)
{
if(n == 0 || n == 1)
return 1;
else return n * factorial(n-1);
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

how can the program keep track of its state?

A

Stacks

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

Each individual method call within a recursive process can be called a

A

Frame

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

Proof by induction involves three main parts:

A

A base case with a known solution.
A proposed, closed-form solution for any value , which the base case matches.
A proof that shows that if the proposed solution works for time step k, it works for time step k+1.

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