Professional Documents
Culture Documents
Recursion
Assignments with Answers
(d) No, it is not a recursive function, as they are two different function.
Q.4 Recursion and Iteration are both similar things i.e. anything that we can do with a loop
can be done by recursion. If you, are a programmer which one will be used by you while
making a program.
Ans. As a programmer we will prefer to use both recursion and iteration depending
upon the need. As, Recursion is used by a programmer as :
a) Recursion is a technique to define anything in terms of itself
b) Iteration does not involves the use of additional cost of RAM as compared
to using recursion
c) Recursion is important as it makes the program shorter, and more
simplified.
def fact(n):
if n==1:
return 1
else:
return ---------------
Ans. n * fact(n-1)
Q.8 Write a Python program to print the Fibonacci series using recursion:
if n<=1:
return n
else:
return(fibonacci(n-1)+fibonacci(n-2))
for i in range(num):
Q.9 Python program to find an element in an array using Binary search recursively.