Font size
WorksheetsClass 12 Recursion
Total questions: 10
Worksheet time: 8mins
What is the action of method mystery2?
a+B
ab
a!
a*b
ba
Which of the following is the best definition of a recursive method?
A method that iterates itself exactly 5 times.
A method that will never iterate infinitely.
A method that invokes itself by name within the method.
A method that cannot be called more than once.
Analyze the program in the picture. The method name is darkened. Could you write in a line what this method does?
Which answer is a correct skeleton for a recursive Java method?
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
}
}
int solution( int N )
{
if ( base case )
{
return something easily computed
}
else
{
return solution(N)
}
}
int solution( int N )
{
divide problem into pieces
return something calculated from the solution to each piece
}
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
}
}
Recursion is:
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.
is a computer programming technique involving the use of a procedure, subroutine, function, or algorithm that calls other function in a step.
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.
None of the above
Name the condition at which the recursive method will stop calling itself.
Base case
Worst Case
Best Case
None of the above
Which of the following condition is true?
Recursion is always better than iteration.
Recursion uses less memory as compared to iteration.
Recursion uses more memory as compared to iteration.
Iteration is always better and simpler than recursion.
Which of the following problems can be solved using recursion?
finding Nth number of the Fibonacci sequence
finding the length of a string
finding the factorial of a number
all of the above
Though this program is writtin in python, it is easy to understand...What is the returned value of recmethod(5)?
68
75
70
82
what will multiplyEvens(3) return?
4
2
48
8
