wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Class 12 Recursion

Total questions: 10

Worksheet time: 8mins

Name
Class
Date
1.

What is the action of method mystery2?

a)

a+B

b)

aba^b  

c)

a!

d)

a*b

e)

bab^a  

2.

 

Which of the following is the best definition of a recursive method?

a)

A method that iterates itself exactly 5 times.

b)

A method that will never iterate infinitely.

c)

A method that invokes itself by name within the method.

d)

A method that cannot be called more than once.

3.

Analyze the program in the picture. The method name is darkened. Could you write in a line what this method does?

4 lines
4.

Which answer is a correct skeleton for a recursive Java method?

a)

int solution( int N )

{

if ( base case )

{

return something easily computed

}

else

{

divide problem into pieces

return something calculated from the solution to each piece

}

}

b)

int solution( int N )

{

if ( base case )

{

return something easily computed

}

else

{

return solution(N)

}

}

c)

int solution( int N )

{

divide problem into pieces

return something calculated from the solution to each piece

}

d)

int solution( int N )

{

divide problem into pieces

if ( base case )

{

return something easily computed

}

else

{

return something calculated from the solution to each piece

}

}

5.

Recursion is:

a)

is a computer programming technique involving the use of a procedure, subroutine, function, or algorithm that calls itself in a step having a termination condition.

b)

is a computer programming technique involving the use of a procedure, subroutine, function, or algorithm that calls other function in a step.

c)

is a computer programming technique involving the use of a procedure, subroutine, function, or algorithm that calls itself in a step having no termination condition.

d)

None of the above

6.

Name the condition at which the recursive method will stop calling itself.

a)

Base case

b)

Worst Case

c)

Best Case

d)

None of the above

7.

Which of the following condition is true?

a)

Recursion is always better than iteration.

b)

Recursion uses less memory as compared to iteration.

c)

Recursion uses more memory as compared to iteration.

d)

Iteration is always better and simpler than recursion.

8.

Which of the following problems can be solved using recursion?

a)

finding Nth number of the Fibonacci sequence

b)

finding the length of a string

c)

finding the factorial of a number

d)

all of the above

9.

Though this program is writtin in python, it is easy to understand...What is the returned value of recmethod(5)?

a)

68

b)

75

c)

70

d)

82

10.

what will multiplyEvens(3) return?

a)

4

b)

2

c)

48

d)

8