Recursion || Type A || Sumita Arora || Class 12 || Computer science || Information practices || Solution ||
Q 1 = What is a recursive function? Write one advantage of recursive functions.
Q 2 = What is direct recursion and indirect recursion?
Q 3 = What are the two cases required in a recursive function?
Q 4 = What is base case?
Q 5 = What is recursive case?
Q 6 = Is it necessary to have a base case in a recursive function? Why/Why not?
Q 7 = What is infinite recursion? Why does it occur?
Q 8 = How can you stop/resolve an infinite recursion?
Q 9 = Give some examples that can be represented recursively.
Q 10 = Can each recursive function be represented through iteration? Give examples.
Q 11 = Which of the function given in previous question will result into infinite recursion?
Q 12 = Identify the base case(s) in the following recursive function:
def function(n) :
if n == 0 :
return 5
elif n == 1 :
return 8
elif n > 0 :
return function1(n-1) + function1(n-2)
else:
return -1
Q 13 = Why are recursive functions considered slower than their iterative counterparts?
Q 14 = If any recursive function can be easily written using iterative code, then what is the need for recursion? When would you prefer recursion over iteration and vice versa?
Q 15 = Compare and contrast the use of iteration and recursion in terms of memory space and speed.
Q 2 = What is direct recursion and indirect recursion?
Q 3 = What are the two cases required in a recursive function?
Q 4 = What is base case?
Q 5 = What is recursive case?
Q 6 = Is it necessary to have a base case in a recursive function? Why/Why not?
Q 7 = What is infinite recursion? Why does it occur?
Q 8 = How can you stop/resolve an infinite recursion?
Q 9 = Give some examples that can be represented recursively.
Q 10 = Can each recursive function be represented through iteration? Give examples.
Q 11 = Which of the function given in previous question will result into infinite recursion?
Q 12 = Identify the base case(s) in the following recursive function:
def function(n) :
if n == 0 :
return 5
elif n == 1 :
return 8
elif n > 0 :
return function1(n-1) + function1(n-2)
else:
return -1
Q 13 = Why are recursive functions considered slower than their iterative counterparts?
Q 14 = If any recursive function can be easily written using iterative code, then what is the need for recursion? When would you prefer recursion over iteration and vice versa?
Q 15 = Compare and contrast the use of iteration and recursion in terms of memory space and speed.
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )