2.2.1 Programming Techniques Flashcards

1
Q

What are the 3 conditions for Recursion

A
  1. Contains a stopping condition
  2. For any input value other than the stopping condition, the subroutine should call itself
  3. The stopping condition should be reachable within a finite number of time.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Compare iteration and recursion, which is more memory efficient?

A

Iteration.

In recursive approach, every time a recursive function calls itself, the processor needs to remember where it was before it jumps to the new copy.
The processor also needs to remember that values of all the previous variables using stacks, which takes up space in memory.

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

Define Sequence

A

A programming constructs that code is executed line by line.

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