Anda di halaman 1dari 2

Name:

Iteration OR Recursion??

Iteration Recursion
How does it repeat Iteration is Calls upon itself with a
instructions? implemented in recursive call.
programming using FOR
and WHILE statements.
How many function calls If there is no iteration The number of calls is
are there? variable, the loop will dependent on the
repeat forever. condition of variable n
So, number of variables and its relationship to a
*number of operations number.
involved= number of
calls
Is there are stopping The programmer can A recursion needs to
condition? set conditions for the meet its base condition
code to stop using many to stop. If the base
statements within condition is met then
Python such as the the program do
break statement. something meaningful
and exits.
How does the program The program move It must make some
move towards the towards the stopping change in the
stopping condition? condition with break, arguments of the
continue, pass function which will
statements. eventually mean that
the base case is
executed.
(If this does not happen,
you will have an infinite
loop!)
How many sets of The set of variables is The set of variables is
variables are there and proportional to the proportional to the
why? number of iterations. number of functions
involving individual
ones.
How much memory is The limit is 1000. The limit is 1000.
needed?
Name:

How easy is the code to Because iteration is so Recursion is one of the


understand? common, Python most important ideas in
provides several computer science, but
language features to it's usually viewed as
make it easier. One one of the harder parts
form of iteration in of programming to
Python is the while grasp
statement