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

Which of the following statements are true? In some cases, however, using recurs

ID: 3582896 • Letter: W

Question

Which of the following statements are true? In some cases, however, using recursion enables you to give a natural, straightforward, simple solution to a program that would otherwise be difficult to solve. A recursive method can always be replaced by a non-recursive method. Recursive methods run faster than non-recursive methods. Recursive methods usually take more memory space than non-recursive methods. Fill in the code to complete the following method for checking whether a string is a palindrome. public static Boolean is Palindrome (String s) {return isPalindrome(s, 0, s.length() - 1);} public static Boolean is Palindrome(String s, int low, int high) (if (high - 1) return 1; else return n + x function(n - 2);} 4 2 1 3

Explanation / Answer

Question no-38

Answer is (A) and (D).

Explanation:

Program length small. You can see it applying MERGESORT()

Function is called extra memory space/stack is created to store the context of the function called.

So more memory space is needed.

------------------------------------------------------------------------

Question no-39

Solution statement is bold and underlined.

public static boolean isPalindrome(String s,int low,int high)

                {

                                if(high<low)

                                                                return true;

                                else if(s.charAt(low) != s.charAt(high))

                                                return false;

                                return   isPalindrome(s,low+1,high-1);

                }

-----------------------------------------------------------------------------------------------------

Question no-40

Answer is (C ) 1

Explanation:

The argument to the function is n= 6. So the test in if(n>=1) is true so returns 1

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