0% found this document useful (0 votes)
100 views

Iteration OR Recursion?? Iteration Recursion: Name

Iteration repeats instructions using loops like for and while statements, with a fixed number of calls set by the programmer. Recursion repeats instructions by calling the function itself, with the number of calls dependent on a variable meeting a base condition. Recursion is more complex than iteration as the program must change arguments at each call to eventually reach the base condition, but it provides an elegant solution to some problems.

Uploaded by

anonimyboss
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views

Iteration OR Recursion?? Iteration Recursion: Name

Iteration repeats instructions using loops like for and while statements, with a fixed number of calls set by the programmer. Recursion repeats instructions by calling the function itself, with the number of calls dependent on a variable meeting a base condition. Recursion is more complex than iteration as the program must change arguments at each call to eventually reach the base condition, but it provides an elegant solution to some problems.

Uploaded by

anonimyboss
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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

You might also like