Page 1 - Home Assignment-Recursion
P. 1

Computer Science

                                                    Class – XII


                                                Topic: Recursion



               1.  A function is said to be ________________ if it calls itself.
               2.  The terminating condition used for solving a problem using recursion is termed as the
                   _____________________ for that problem.
               3.  What is a recursive function? Write one advantage of recursive function.
               4.  What are the two cases required in a recursive function?
               5.  What is base case?
               6.  What is recursive case?
               7.  Is it necessary to have a base case in a recursive function? Why/Why not?
               8.  When does infinite recursion occur?
               9.  Differentiate between iteration and recursion.
               10. State one advantage and one disadvantage of using recursion over iteration.
               11. Why are recursive functions considered slower than their iterative counterparts?
               12. Compare and contrast the use of iteration and recursion in terms of memory space and speed.
               13. Identify the base case in the following recursive function:
                   def function1(n):
                       if n==0:
                          return 5
                       elif n==8:
                          return 8
                       elif n>8:
                          return function1(n-1) + function1(n-2)
                       else:
                          return -1
               14. Write recursive code for printing a message infinite times.
               15. Write recursive code for sum of squares of first N (user input) natural numbers.
               16. Write recursive code for calculating factorial of a number.
                                                 n
               17. Write recursive code for finding X .
               18. Explain the working of recursive function by taking help of a stack.
               19. Write advantages and disadvantages of recursion.
               20. Write recursive code for printing Fibonacci Series.
               21. Write recursive code for Binary Search.
               22. Predict the output of the following code:
                   def express(x, n):
                       if n==0:
                          return 1
                       elif n%2 == 0:
                          return express(x*x, n/2)
                       else:
                          return x * express(x, n-1)
                   a=express(2,5)
                   print(a)
   1