Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Which one can be used to solve a problem? Iteration A formula Selection Which on

ID: 3850329 • Letter: W

Question

Which one can be used to solve a problem?

Iteration

A formula

Selection

Which one is a base case for a recursive computation of “n” factorial?

n!=n/n-1)!

2!=2

0!=1

For a recursive palidrome checker, which one is a base case?

If the first and last characters are not the same, the text is not a palindrome.

If the first and last characters are not the same, the text is a palidrome.

If the first and last characters are the same, the text is not a palindrome.

If there is an odd number of a character, the text is not a palindrome.

Which one is a characteristic of recursion?

Repetively calling an identical version of the same problem.

Repetively calling a simpler version of the same problem

Repetively calling a more complex version of the same problem.

Repetively calling a more complex version of a different problem.

Compared to iteration, which one is a benefit of recursion?

Compact elegant solution

More memory usage

Harder understand

Obvious how to write recursive code.

Which one is an invariant relationship that expresses a case in terms of simpler intermediate subcases of itself?

Composition

General case

Base case

Inheritance

Which one is the general case for a recursive computation of “n” factorial?

A. n!=(n-1)!

B. n!=n(n-1)!

c. n!=1

d. n!=n(n-1)(n-2)…(2)!

A recursive method calls itself repeatedly until which one occurs?

A call returns void

The call stack overflows

A bade case is reached

The general case is reached

For a recursion, which one has an obvious known solution?

A switch case

B default case

C iteration case

D base case

Which of these maintains the local variable values and next instruction address of method calls?

Program queue

Next instruction pointer

Call stack

Return value

Which one has the same return value from each recursive call?

                     A tail recursion

                      B head recursion

                    C invariant recursion

                      D constant recursion

Which of these calls itself?

Iterative code

Selection code

Method that returns void

Recursive method

Explanation / Answer

1. Which one can be used to solve a problem?
Iteration
A formula
Selection

Answer: Selection
Explanation: When we have a problem, we will have some conditions. To know whether conditions are getting satisfied or not, we need to go for selection.


2. Which one is a base case for a recursive computation of “n” factorial?
n!=n/n-1)!
2!=2
0!=1

Answer: 2! = 2
Explanation: 5! means 5*4*3*2*1
Factorial means multiplying given integer with all positive integers greater than 0. At the end, 2! will be there. Especially 0! is not 1.
n! = n*(n-1)! at the end it will be 2*1 always.


3. For a recursive palidrome checker, which one is a base case?
If the first and last characters are not the same, the text is not a palindrome.
If the first and last characters are not the same, the text is a palidrome.
If the first and last characters are the same, the text is not a palindrome.
If there is an odd number of a character, the text is not a palindrome.

Answer: If the first and last characters are not the same, the text is not a palindrome.
Explanation: Example is RACECAR. To know whether it is a palindrome or not, using recursion we need to compare the first and last letters. If they are same, we will go for second letter and last but one, and so on till we reach mid letter(s). So, in mean time if any of the letters didn't match, that means it is not a palindrome.


4. Which one is a characteristic of recursion?
Repetively calling an identical version of the same problem.
Repetively calling a simpler version of the same problem
Repetively calling a more complex version of the same problem.
Repetively calling a more complex version of a different problem.

Answer: Repetitively calling an identical version of the same problem.
Recursion means a function calling itself, when we have to do same process over and over till we make the decision / get the result, we use it. So, we call it identical.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote