Deck 13: Recursion

ملء الشاشة (f)
exit full mode
سؤال
Consider the following recursive code snippet: Consider the following recursive code snippet:   A.1 B.11 C.5 D.6<div style=padding-top: 35px>
A.1
B.11
C.5
D.6
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Consider the getArea method from the textbook shown below. Consider the getArea method from the textbook shown below.   What will be the result? A.The method will return incorrect results for triangles with width equal to 0. B.The method will return incorrect results for triangles with width equal to 1. C.The method will return area to be one too high for all triangles. D.The method will still return correct results for all non-negative width triangles.<div style=padding-top: 35px> What will be the result?
A.The method will return incorrect results for triangles with width equal to 0.
B.The method will return incorrect results for triangles with width equal to 1.
C.The method will return area to be one too high for all triangles.
D.The method will still return correct results for all non-negative width triangles.
سؤال
What is required to make a recursive method successful?
I special cases that handle the simplest computations directly
II a recursive call to simplify the computation
III a mutual recursion
A.I, II, and III
B.II only
C.I only
D.I and II only
سؤال
Consider the recursive method myPrint shown in this code snippet: Consider the recursive method myPrint shown in this code snippet:   What does this method do? A.Prints a positive int value forward, digit by digit. B.Divides the int by 10 and prints out the result. C.Divides the int by 10 and prints out its last digit. D.Prints a positive int value backward, digit by digit.<div style=padding-top: 35px> What does this method do?
A.Prints a positive int value forward, digit by digit.
B.Divides the int by 10 and prints out the result.
C.Divides the int by 10 and prints out its last digit.
D.Prints a positive int value backward, digit by digit.
سؤال
Consider the following code snippet for recursive addition: Consider the following code snippet for recursive addition:   Identify the terminating condition in this recursive method. A.there is no terminating condition B.i == 0 C.return j D.return add(i - 1, j + 1)<div style=padding-top: 35px> Identify the terminating condition in this recursive method.
A.there is no terminating condition
B.i == 0
C.return j
D.return add(i - 1, j + 1)
سؤال
Consider the code for the recursive method riddle shown in this code snippet: Consider the code for the recursive method riddle shown in this code snippet:   To avoid infinite recursion, which of the following lines of code should replace the current terminating case? A.if (n <= 0) B.if (n == -1) C.if (n >= 0) D.The terminating case as shown will avoid infinite recursion.<div style=padding-top: 35px> To avoid infinite recursion, which of the following lines of code should replace the current terminating case?
A.if (n <= 0)
B.if (n == -1)
C.if (n >= 0)
D.The terminating case as shown will avoid infinite recursion.
سؤال
Insert the missing code in the following code fragment.This fragment is intended to recursively compute xn, where x and n are both non-negative integers: Insert the missing code in the following code fragment.This fragment is intended to recursively compute xn, where x and n are both non-negative integers:   A.return power(x, n - 1); B.return x; C.return 1; D.return x * power(x, n - 1);<div style=padding-top: 35px>
A.return power(x, n - 1);
B.return x;
C.return 1;
D.return x * power(x, n - 1);
سؤال
Consider the getArea method from the textbook shown below. Consider the getArea method from the textbook shown below.   Where is/are the recursive call(s)? A.lines #1 and #2 B.line #4 C.line #1 D.line #2<div style=padding-top: 35px> Where is/are the recursive call(s)?
A.lines #1 and #2
B.line #4
C.line #1
D.line #2
سؤال
Consider the getArea method from the book shown below. Consider the getArea method from the book shown below.   What will happen when this code is executed? A.Nothing - the method would still be correct. B.We would lose our only recursive case. C.A positive width would reduce the correct area by 1. D.A negative or zero width would cause problems.<div style=padding-top: 35px> What will happen when this code is executed?
A.Nothing - the method would still be correct.
B.We would lose our only recursive case.
C.A positive width would reduce the correct area by 1.
D.A negative or zero width would cause problems.
سؤال
Consider the following code snippet for calculating Fibonacci numbers recursively: Consider the following code snippet for calculating Fibonacci numbers recursively:   Identify the terminating condition in this recursive method. A.n < 1 B.n <= 1 C.fib(n - 1) D.fib(n - 1) + fib(n - 1)<div style=padding-top: 35px> Identify the terminating condition in this recursive method.
A.n < 1
B.n <= 1
C.fib(n - 1)
D.fib(n - 1) + fib(n - 1)
سؤال
A recursive method without a special terminating case would _________
A.be more efficient.
B.never terminate.
C.end immediately.
D.not be recursive.
سؤال
Consider the following recursive code snippet: Consider the following recursive code snippet:   } Identify the terminating condition(s) of method mystery? A.n <= 0 B.n > 0 C.n == 1 D.n <= 0 or n == 1<div style=padding-top: 35px> }
Identify the terminating condition(s) of method mystery?
A.n <= 0
B.n > 0
C.n == 1
D.n <= 0 or n == 1
سؤال
Complete the code for the recursive method printSum shown in this code snippet, which is intended to return the sum of digits from 1 to n: Complete the code for the recursive method printSum shown in this code snippet, which is intended to return the sum of digits from 1 to n:   A.return (n + printSum(n - 1)); B.return (n - printSum(n - 1)); C.return (n + printSum(n + 1)); D.return (printSum(n - 1));<div style=padding-top: 35px>
A.return (n + printSum(n - 1));
B.return (n - printSum(n - 1));
C.return (n + printSum(n + 1));
D.return (printSum(n - 1));
سؤال
If recursion does not have a special terminating case, what error will occur?
A.Illegal argument
B.Out of memory
C.Stack overflow
D.Index out of range
سؤال
Consider the getArea method from the textbook shown below: Consider the getArea method from the textbook shown below:   A.Those with width equal to 0. B.Triangles of any width. C.Those with width equal to 1. D.Those with width greater than or equal to 2.<div style=padding-top: 35px>
A.Those with width equal to 0.
B.Triangles of any width.
C.Those with width equal to 1.
D.Those with width greater than or equal to 2.
سؤال
Consider the recursive method myPrint: Consider the recursive method myPrint:   What is printed for the call myPrint(8)? A.4 B.21 C.10 D.8<div style=padding-top: 35px> What is printed for the call myPrint(8)?
A.4
B.21
C.10
D.8
سؤال
Consider the following recursive code snippet: Consider the following recursive code snippet:   What value is returned from a call to mystery(3,6)? A.18 B.3 C.6 D.729<div style=padding-top: 35px> What value is returned from a call to mystery(3,6)?
A.18
B.3
C.6
D.729
سؤال
Consider the code for the recursive method mystery shown in this code snippet: Consider the code for the recursive method mystery shown in this code snippet:   What will be printed by the statement System.out.println(mystery(-4));? A.Nothing - a StackoverflowError exception will occur B.0 C.-22 D.-10<div style=padding-top: 35px> What will be printed by the statement System.out.println(mystery(-4));?
A.Nothing - a StackoverflowError exception will occur
B.0
C.-22
D.-10
سؤال
Consider the getArea method from the textbook shown below. Consider the getArea method from the textbook shown below.   Where is/are the terminating condition(s)? A.line #2 B.line #4 C.line #1 D.lines #1 and #2<div style=padding-top: 35px> Where is/are the terminating condition(s)?
A.line #2
B.line #4
C.line #1
D.lines #1 and #2
سؤال
Consider the recursive method myPrint in this code snippet: Consider the recursive method myPrint in this code snippet:   What is printed for the call myPrint(821)? A.821 B.12 C.10 D.128<div style=padding-top: 35px> What is printed for the call myPrint(821)?
A.821
B.12
C.10
D.128
سؤال
Would switching the special case order affect the return value of the following method? Would switching the special case order affect the return value of the following method?   A.An exception will be thrown. B.Yes C.No D.It is impossible to tell.<div style=padding-top: 35px>
A.An exception will be thrown.
B.Yes
C.No
D.It is impossible to tell.
سؤال
Consider the problem of arranging matchsticks so as to form a row of squares, as shown below for three squares and ten matchsticks. Consider the problem of arranging matchsticks so as to form a row of squares, as shown below for three squares and ten matchsticks.   A.4 * squares; B.3 + matchsticks(squares - 1); C.4 + matchsticks(squares - 1); D.matchsticks(squares + 4);<div style=padding-top: 35px>
A.4 * squares;
B.3 + matchsticks(squares - 1);
C.4 + matchsticks(squares - 1);
D.matchsticks(squares + 4);
سؤال
Consider the method below, which implements the exponentiation operation recursively.Select the statement that should be used to complete the method so that it handles the special case correctly. Consider the method below, which implements the exponentiation operation recursively.Select the statement that should be used to complete the method so that it handles the special case correctly.   A.return 0; B.return 1 * power(base, exponent - 1); C.return base; D.return 1;<div style=padding-top: 35px>
A.return 0;
B.return 1 * power(base, exponent - 1);
C.return base;
D.return 1;
سؤال
Consider the method below, which displays the characters from a String in reverse order.Each character appears on a separate line.Select the statement that should be used to complete the method so that it performs a recursive method call correctly. Consider the method below, which displays the characters from a String in reverse order.Each character appears on a separate line.Select the statement that should be used to complete the method so that it performs a recursive method call correctly.   A.printReverse(word.length() - 1); B.printReverse(word.substring(1)); C.printReverse(word); D.printReverse(new String(word.charAt(1)));<div style=padding-top: 35px>
A.printReverse(word.length() - 1);
B.printReverse(word.substring(1));
C.printReverse(word);
D.printReverse(new String(word.charAt(1)));
سؤال
Consider the method powerOfTwo shown below: Consider the method powerOfTwo shown below:   What is the best interpretation of line #1? A.1 is an invalid choice for n B.Any multiple of one is a power of two C.One is not a power of two D.One is a power of two<div style=padding-top: 35px> What is the best interpretation of line #1?
A.1 is an invalid choice for n
B.Any multiple of one is a power of two
C.One is not a power of two
D.One is a power of two
سؤال
Which of the following options could be used as a terminating condition for a recursive method that finds the middle character of a String with any number of characters?
I the length of the String is 1
II first and last String characters match
III the String is not empty
A.I only
B.I and III only
C.I, II and III
D.II only
سؤال
If a recursive method does not simplify the computation within the method and the base case is not called, what will be the result?
A.The recursion calculation will occur correctly regardless.
B.Infinite recursion will occur.
C.This cannot be determined.
D.The terminating condition will be executed and recursion will end.
سؤال
Consider the method powerOfTwo shown below: Consider the method powerOfTwo shown below:   How many recursive calls are made from the original call powerOfTwo(63) (not including the original call)? A.1 B.6 C.0 D.4<div style=padding-top: 35px> How many recursive calls are made from the original call powerOfTwo(63) (not including the original call)?
A.1
B.6
C.0
D.4
سؤال
Complete the code for the recursive method shown below, which is intended to compute the sum of the first n positive integers: Complete the code for the recursive method shown below, which is intended to compute the sum of the first n positive integers:   A.return n + s(n - 1); B.return s(n) + n - 1; C.return n + (n - 1); D.return n + s(n + 1);<div style=padding-top: 35px>
A.return n + s(n - 1);
B.return s(n) + n - 1;
C.return n + (n - 1);
D.return n + s(n + 1);
سؤال
Consider the getArea method from the textbook shown below: Consider the getArea method from the textbook shown below:   This would cause infinite recursion for ____. A.triangles with width equal to 1 B.triangles with width equal to 0 C.triangles with width greater than or equal to 2 D.triangles of any width<div style=padding-top: 35px> This would cause infinite recursion for ____.
A.triangles with width equal to 1
B.triangles with width equal to 0
C.triangles with width greater than or equal to 2
D.triangles of any width
سؤال
Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method: Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method:   A.return (anInteger * (myFactorial(anInteger - 1))); B.return (anInteger * (myFactorial(anInteger))); C.return ((anInteger - 1) * (myFactorial(anInteger))); D.return ((anInteger - 1)*(myFactorial(anInteger - 1)));<div style=padding-top: 35px>
A.return (anInteger * (myFactorial(anInteger - 1)));
B.return (anInteger * (myFactorial(anInteger)));
C.return ((anInteger - 1) * (myFactorial(anInteger)));
D.return ((anInteger - 1)*(myFactorial(anInteger - 1)));
سؤال
____ recursion can occur when a recursive algorithm does not contain a special case to handle the simplest computations directly.
A.Non-mutual
B.Terminating condition
C.Mutual
D.Infinite
سؤال
Consider the following recursive code snippet: Consider the following recursive code snippet:   What parameter values for n would cause an infinite recursion problem in the following method? A.all n with n < 0 B.n == 0 C.all n with n >= 0 D.n == 1<div style=padding-top: 35px> What parameter values for n would cause an infinite recursion problem in the following method?
A.all n with n < 0
B.n == 0
C.all n with n >= 0
D.n == 1
سؤال
Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method: Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method:   A.return 0; B.return myFactorial(anInteger); C.return 1; D.return -anInteger;<div style=padding-top: 35px>
A.return 0;
B.return myFactorial(anInteger);
C.return 1;
D.return -anInteger;
سؤال
Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method: Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method:   A.if (anInteger * (anInteger - 1) == 1) B.if (anInteger == 1) C.if (myFactorial(anInteger) == 1) D.if ((anInteger - 1) == 1)<div style=padding-top: 35px>
A.if (anInteger * (anInteger - 1) == 1)
B.if (anInteger == 1)
C.if (myFactorial(anInteger) == 1)
D.if ((anInteger - 1) == 1)
سؤال
How many recursive calls to the fib method shown below would be made from an original call to fib(4)? (Do not count the original call) How many recursive calls to the fib method shown below would be made from an original call to fib(4)? (Do not count the original call)   A.8 B.4 C.1 D.2<div style=padding-top: 35px>
A.8
B.4
C.1
D.2
سؤال
Consider the method below, which prints the digits of an arbitrary positive integer in reverse order, one digit per line.The method should print the last digit first.Then, it should recursively print the integer obtained by removing the last digit.Select the statements that should be used to complete the method. Consider the method below, which prints the digits of an arbitrary positive integer in reverse order, one digit per line.The method should print the last digit first.Then, it should recursively print the integer obtained by removing the last digit.Select the statements that should be used to complete the method.  <div style=padding-top: 35px>
سؤال
Consider the method powerOfTwo shown below: Consider the method powerOfTwo shown below:   How many recursive calls are made from the original call of powerOfTwo(64) (not including the original call)? A.6 B.4 C.8 D.2<div style=padding-top: 35px> How many recursive calls are made from the original call of powerOfTwo(64) (not including the original call)?
A.6
B.4
C.8
D.2
سؤال
Consider the getArea method from the textbook shown below: Consider the getArea method from the textbook shown below:   If line #1 was eliminated from the method, what would be the result when calling getArea? A.A positive width would reduce the correct area by 1. B.We would lose our only recursive case. C.Nothing - the method would still work correctly. D.A negative or zero width would cause problems.<div style=padding-top: 35px> If line #1 was eliminated from the method, what would be the result when calling getArea?
A.A positive width would reduce the correct area by 1.
B.We would lose our only recursive case.
C.Nothing - the method would still work correctly.
D.A negative or zero width would cause problems.
سؤال
When a recursive method is called correctly, and it does not perform recursion, what must be true?
A.Both a terminating condition and a recursive case condition were true.
B.A terminating condition was true.
C.All recursive case conditions were true.
D.One recursive case condition was true.
سؤال
Given the following code snippet: Given the following code snippet:   What value will be returned when this code is executed with a call to newCalc(15)? A.2.5 B.5 C.5.5 D.2<div style=padding-top: 35px> What value will be returned when this code is executed with a call to newCalc(15)?
A.2.5
B.5
C.5.5
D.2
سؤال
Given the following class code: Given the following class code:   What values will be printed when this code is executed? A.3, 6, and 9 B.6 C.1, 3, 6, and 9 D.9<div style=padding-top: 35px> What values will be printed when this code is executed?
A.3, 6, and 9
B.6
C.1, 3, 6, and 9
D.9
سؤال
Given the following code snippet: Given the following code snippet:   What value will be returned when this code is executed with a call to newCalc(15)? A.2 B.6.5 C.2.5 D.6<div style=padding-top: 35px> What value will be returned when this code is executed with a call to newCalc(15)?
A.2
B.6.5
C.2.5
D.6
سؤال
Consider the code for the recursive method printSum shown in this code snippet, which is intended to return the sum of digits from 1 to n: Consider the code for the recursive method printSum shown in this code snippet, which is intended to return the sum of digits from 1 to n:   Which of the following statements is correct? A.line #3 is incorrect, and should be changed to return (n + printSum(n + 1)); B.line #1 is incorrect, and should be changed to if (n <= 1) C.line #3 is incorrect, and should be changed to return (n + printSum(n - 1)); D.line #3 is incorrect, and should be changed to return (printSum(n - 1));<div style=padding-top: 35px> Which of the following statements is correct?
A.line #3 is incorrect, and should be changed to return (n + printSum(n + 1));
B.line #1 is incorrect, and should be changed to if (n <= 1)
C.line #3 is incorrect, and should be changed to return (n + printSum(n - 1));
D.line #3 is incorrect, and should be changed to return (printSum(n - 1));
سؤال
Complete the following code snippet, which is intended to be a recursive method that will find the smallest value in an array of double values from index to the end of the array: Complete the following code snippet, which is intended to be a recursive method that will find the smallest value in an array of double values from index to the end of the array:   A.return elements[index]; B.return 0; C.return 1; D.return elements[0];<div style=padding-top: 35px>
A.return elements[index];
B.return 0;
C.return 1;
D.return elements[0];
سؤال
Given the following class code: Given the following class code:   What values will be printed when this code is executed? A.4 B.8 C.0, 4, and 8 D.4 and 8<div style=padding-top: 35px> What values will be printed when this code is executed?
A.4
B.8
C.0, 4, and 8
D.4 and 8
سؤال
Complete the following code snippet, which is intended to be a recursive method that will find the sum of all elements in an array of double values from the beginning of the array to index: Complete the following code snippet, which is intended to be a recursive method that will find the sum of all elements in an array of double values from the beginning of the array to index:   A.return (arr[index] + findSum(arr, index + 1)); B.return (findSum(arr, index - 1)); C.return (findSum(arr, index + 1)); D.return (arr[index] + findSum(arr, index - 1));<div style=padding-top: 35px>
A.return (arr[index] + findSum(arr, index + 1));
B.return (findSum(arr, index - 1));
C.return (findSum(arr, index + 1));
D.return (arr[index] + findSum(arr, index - 1));
سؤال
Given the following class code: Given the following class code:   What values will be printed? A.1, 3, and 6 B.3, 6, 9, and 12 C.1, 3, 6, and 9 D.3, 6, and 9<div style=padding-top: 35px> What values will be printed?
A.1, 3, and 6
B.3, 6, 9, and 12
C.1, 3, 6, and 9
D.3, 6, and 9
سؤال
Given the following code snippet: Given the following code snippet:   What value will be returned when this code is executed with a call to newCalc(5)? A.5 B.1.5 C.5.5 D.1<div style=padding-top: 35px> What value will be returned when this code is executed with a call to newCalc(5)?
A.5
B.1.5
C.5.5
D.1
سؤال
The method below generates all nonempty substrings of a word passed as argument.Assuming that the string contains no duplicate characters, select the statement to complete the method so that it prints all nonempty substrings correctly. The method below generates all nonempty substrings of a word passed as argument.Assuming that the string contains no duplicate characters, select the statement to complete the method so that it prints all nonempty substrings correctly.   A.printSubstrings(word.substring(0)); B.printSubstrings(word.substring(1)); C.printSubstrings(word.substring(word.length())); D.printSubstrings(word.substring(word.length() - 1));<div style=padding-top: 35px>
A.printSubstrings(word.substring(0));
B.printSubstrings(word.substring(1));
C.printSubstrings(word.substring(word.length()));
D.printSubstrings(word.substring(word.length() - 1));
سؤال
Given the following code snippet: Given the following code snippet:   What value will be returned when this code is executed with a call to newCalc(5)? A.2.5 B.5.5 C.5 D.2<div style=padding-top: 35px> What value will be returned when this code is executed with a call to newCalc(5)?
A.2.5
B.5.5
C.5
D.2
سؤال
Complete the following code snippet, which is intended to be a recursive method that reverses a String value: Complete the following code snippet, which is intended to be a recursive method that reverses a String value:   A.return reverseIt; B.return reverseIt; C.return reverseIt; D.return reverseIt;<div style=padding-top: 35px>
A.return reverseIt;
B.return reverseIt;
C.return reverseIt;
D.return reverseIt;
سؤال
Complete the code for the calcPower recursive method shown below, which is intended to raise the base number passed into the method to the exponent power passed into the method: Complete the code for the calcPower recursive method shown below, which is intended to raise the base number passed into the method to the exponent power passed into the method:   A.answer = 0; B.answer = 1; C.answer = calcPower(1); D.answer = -1;<div style=padding-top: 35px>
A.answer = 0;
B.answer = 1;
C.answer = calcPower(1);
D.answer = -1;
سؤال
Complete the following code snippet, which is intended to be a recursive method that will find the smallest value in an array of double values from index to the end of the array: Complete the following code snippet, which is intended to be a recursive method that will find the smallest value in an array of double values from index to the end of the array:   A.minVal(elements, index - 1) B.minVal(index - 1) C.minVal(elements, index + 1) D.minVal(index + 1)<div style=padding-top: 35px>
A.minVal(elements, index - 1)
B.minVal(index - 1)
C.minVal(elements, index + 1)
D.minVal(index + 1)
سؤال
Complete the following code snippet, which is intended to be a recursive method that reverses a String value: Complete the following code snippet, which is intended to be a recursive method that reverses a String value:   A.return s.charAt(0); B.return 0; C.return s.substring(1); D.return s;<div style=padding-top: 35px>
A.return s.charAt(0);
B.return 0;
C.return s.substring(1);
D.return s;
سؤال
Given the following class code: Given the following class code:   What values will be printed when this code is executed? A.8 B.4 C.4 and 8 D.0, 4, and 8<div style=padding-top: 35px> What values will be printed when this code is executed?
A.8
B.4
C.4 and 8
D.0, 4, and 8
سؤال
Which of the following is NOT true about debugging a recursive method by setting a breakpoint on the line containing a return statement?
A.You cannot debug a recursive method with the debugger.
B.The debugger's call stack will show all the calls to the recursive method that are pending.
C.You can select a pending call and then inspect the value of its variables.
D.The last call on the stack represents the first recursive call to reach the return statement.
سؤال
Complete the code for the calcPower recursive method shown below, which is intended to raise the base number passed into the method to the exponent power passed into the method: Complete the code for the calcPower recursive method shown below, which is intended to raise the base number passed into the method to the exponent power passed into the method:   A.answer = baseNum * calcPower (baseNum -1, exponent - 1); B.answer = baseNum * calcPower (baseNum, exponent); C.answer = baseNum * calcPower (baseNum -1, exponent); D.answer = baseNum * calcPower (baseNum, exponent - 1);<div style=padding-top: 35px>
A.answer = baseNum * calcPower (baseNum -1, exponent - 1);
B.answer = baseNum * calcPower (baseNum, exponent);
C.answer = baseNum * calcPower (baseNum -1, exponent);
D.answer = baseNum * calcPower (baseNum, exponent - 1);
سؤال
Complete the following code snippet, which is intended to be a recursive method that will find the sum of all elements in an array of double values from the beginning of the array to index: Complete the following code snippet, which is intended to be a recursive method that will find the sum of all elements in an array of double values from the beginning of the array to index:   A.return arr[index + 1]; B.return arr[1]; C.return arr[index - 1]; D.return arr[index];<div style=padding-top: 35px>
A.return arr[index + 1];
B.return arr[1];
C.return arr[index - 1];
D.return arr[index];
سؤال
Complete the code for the calcPower recursive method shown below, which is intended to raise the base number passed into the method to the exponent power passed into the method: Complete the code for the calcPower recursive method shown below, which is intended to raise the base number passed into the method to the exponent power passed into the method:   A.if (exponent == -1) B.if (exponent == 1) C.if (exponent != 1) D.if (exponent == 0)<div style=padding-top: 35px>
A.if (exponent == -1)
B.if (exponent == 1)
C.if (exponent != 1)
D.if (exponent == 0)
سؤال
Consider the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method: Consider the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method:   If you set a breakpoint on line #2 and then call myFactorial(4), how many calls to myFactorial will be visible on the debugger's call stack when the program suspends for the breakpoint? A.0 because the answer was returned B.3 C.4 D.1<div style=padding-top: 35px> If you set a breakpoint on line #2 and then call myFactorial(4), how many calls to myFactorial will be visible on the debugger's call stack when the program suspends for the breakpoint?
A.0 because the answer was returned
B.3
C.4
D.1
سؤال
Consider the fib method from the textbook shown below: Consider the fib method from the textbook shown below:   Computing the 7th fibonacci number, fib(7), recursively computes fib(6), fib(5), and fib(4) ___ times respectively. A.6, 5, and 4 B.3, 2, and 1 C.1, 2, and 3 D.4, 5, and 6<div style=padding-top: 35px> Computing the 7th fibonacci number, fib(7), recursively computes fib(6), fib(5), and fib(4) ___ times respectively.
A.6, 5, and 4
B.3, 2, and 1
C.1, 2, and 3
D.4, 5, and 6
سؤال
A palindrome is a word or phrase that reads the same forward or backward.Consider the following code snippet: A palindrome is a word or phrase that reads the same forward or backward.Consider the following code snippet:   What is the purpose of the palindrome method? A.Recursively call itself. B.Provide the string, along with its first and last indexes to the recursive isPal method. C.Send the recursive isPal method its terminating condition. D.Return the palindrome to the calling method.<div style=padding-top: 35px> What is the purpose of the palindrome method?
A.Recursively call itself.
B.Provide the string, along with its first and last indexes to the recursive isPal method.
C.Send the recursive isPal method its terminating condition.
D.Return the palindrome to the calling method.
سؤال
Consider the square method shown below that takes a non-negative int argument.Complete the code for the square method so that it correctly calls the squareHelper method to produce the square of n. Consider the square method shown below that takes a non-negative int argument.Complete the code for the square method so that it correctly calls the squareHelper method to produce the square of n.   A.return squareHelper(n - 1, n) B.return squareHelper(n, n - 1) C.return square(n) D.return squareHelper(n, n)<div style=padding-top: 35px>
A.return squareHelper(n - 1, n)
B.return squareHelper(n, n - 1)
C.return square(n)
D.return squareHelper(n, n)
سؤال
Consider the recursive version of the fib method from the textbook shown below: Consider the recursive version of the fib method from the textbook shown below:   How many recursive calls to fib(2) will be made from the original call of fib(6)? A.4 B.3 C.5 D.2<div style=padding-top: 35px> How many recursive calls to fib(2) will be made from the original call of fib(6)?
A.4
B.3
C.5
D.2
سؤال
Consider the recursive version of the fib method from the textbook shown below: Consider the recursive version of the fib method from the textbook shown below:   How many total recursive calls (not counting the original call) to fib will be made from the original call of fib(7)? A.12 B.32 C.24 D.30<div style=padding-top: 35px> How many total recursive calls (not counting the original call) to fib will be made from the original call of fib(7)?
A.12
B.32
C.24
D.30
سؤال
Consider the square method shown below that takes a non-negative int argument: Consider the square method shown below that takes a non-negative int argument:   What would a call to square(7) return? A.7 B.14 C.13 D.49<div style=padding-top: 35px> What would a call to square(7) return?
A.7
B.14
C.13
D.49
سؤال
Consider the square method shown below that takes a non-negative int argument. Consider the square method shown below that takes a non-negative int argument.   What would a call to square(4) return? A.256 B.4 C.16 D.64<div style=padding-top: 35px> What would a call to square(4) return?
A.256
B.4
C.16
D.64
سؤال
A palindrome is a word or phrase that reads the same forward or backward.Consider the following code snippet: A palindrome is a word or phrase that reads the same forward or backward.Consider the following code snippet:   A.You have reached the middle of the string. B.It cannot be determined if the string is a palindrome. C.An empty or one-character string is considered a palindrome. D.The string is not a palindrome.<div style=padding-top: 35px>
A.You have reached the middle of the string.
B.It cannot be determined if the string is a palindrome.
C.An empty or one-character string is considered a palindrome.
D.The string is not a palindrome.
سؤال
Assume that recursive method search returns true if argument value is one of the elements in the section of the array limited by the firstIndex and lastIndex arguments.What statement can be used in main to determine if the value 7 is one of the elements in array values? Assume that recursive method search returns true if argument value is one of the elements in the section of the array limited by the firstIndex and lastIndex arguments.What statement can be used in main to determine if the value 7 is one of the elements in array values?   A.search(7, values, 1, values.length) B.search(7, values, 1, values.length - 1) C.search(7, values, 0, values.length) D.search(7, values, 0, values.length - 1)<div style=padding-top: 35px>
A.search(7, values, 1, values.length)
B.search(7, values, 1, values.length - 1)
C.search(7, values, 0, values.length)
D.search(7, values, 0, values.length - 1)
سؤال
A palindrome is a word or phrase that reads the same forward or backward.Consider the methods palindrome and isPal shown below: A palindrome is a word or phrase that reads the same forward or backward.Consider the methods palindrome and isPal shown below:   The method isPal as shown here would be considered to be a ____ method. A.terminating B.static C.recursive helper D.public<div style=padding-top: 35px> The method isPal as shown here would be considered to be a ____ method.
A.terminating
B.static
C.recursive helper
D.public
سؤال
Consider the iterative version of the fib method from the textbook shown below: Consider the iterative version of the fib method from the textbook shown below:   How many iterations of the for loop will there be for the call fib(6)? A.3 B.5 C.6 D.4<div style=padding-top: 35px> How many iterations of the for loop will there be for the call fib(6)?
A.3
B.5
C.6
D.4
سؤال
Consider the recursive version of the fib method from the textbook shown below: Consider the recursive version of the fib method from the textbook shown below:   How many total recursive calls (not counting the original call) to fib will be made from the original call of fib(6)? A.14 B.12 C.6 D.20<div style=padding-top: 35px> How many total recursive calls (not counting the original call) to fib will be made from the original call of fib(6)?
A.14
B.12
C.6
D.20
سؤال
Why does the best recursive method usually run slightly slower than its iterative counterpart?
A.Each recursive method call takes processor time.
B.Multiple recursive cases must be considered.
C.Checking multiple terminating conditions take more processor time.
D.Testing the terminating condition takes longer.
سؤال
Consider the problem of displaying a pattern of asterisks that form a triangle of height h, as shown below for h = 4: Consider the problem of displaying a pattern of asterisks that form a triangle of height h, as shown below for h = 4:   A.shape(0, height - 1); B.shape(0, height - 1); C.shape(1, height); D.shape(0, height);<div style=padding-top: 35px>
A.shape(0, height - 1);
B.shape(0, height - 1);
C.shape(1, height);
D.shape(0, height);
سؤال
Consider the helper method reversePrint, which uses recursion to display in reverse the elements in a section of an array limited by the firstIndex and lastIndex arguments.What statement should be used to complete the recursive method? Consider the helper method reversePrint, which uses recursion to display in reverse the elements in a section of an array limited by the firstIndex and lastIndex arguments.What statement should be used to complete the recursive method?   A.reversePrint(array, firstIndex, lastIndex - 1); B.reversePrint(array, firstIndex + 1, lastIndex); C.reversePrint(array, firstIndex + 1, lastIndex - 1); D.reversePrint(array, firstIndex, lastIndex + 1);<div style=padding-top: 35px>
A.reversePrint(array, firstIndex, lastIndex - 1);
B.reversePrint(array, firstIndex + 1, lastIndex);
C.reversePrint(array, firstIndex + 1, lastIndex - 1);
D.reversePrint(array, firstIndex, lastIndex + 1);
سؤال
Consider the recursive version of the fib method from the textbook shown below: Consider the recursive version of the fib method from the textbook shown below:   How many more recursive calls to fib will be made from the original call of fib(7) than from the original call of fib(6) (not counting the original calls)? A.2 B.10 C.5 D.1<div style=padding-top: 35px> How many more recursive calls to fib will be made from the original call of fib(7) than from the original call of fib(6) (not counting the original calls)?
A.2
B.10
C.5
D.1
سؤال
Consider the helper method reversePrint, which uses recursion to display in reverse the elements in a section of an array limited by the firstIndex and lastIndex arguments.What statement should be used to complete the recursive method? Consider the helper method reversePrint, which uses recursion to display in reverse the elements in a section of an array limited by the firstIndex and lastIndex arguments.What statement should be used to complete the recursive method?   A.array[firstIndex] B.array[firstIndex+1] C.array[lastIndex-1] D.array[lastIndex]<div style=padding-top: 35px>
A.array[firstIndex]
B.array[firstIndex+1]
C.array[lastIndex-1]
D.array[lastIndex]
سؤال
A palindrome is a word or phrase spelled which reads the same forward or backward.Consider the following code snippet: A palindrome is a word or phrase spelled which reads the same forward or backward.Consider the following code snippet:   What does the method palindrome return? A.false B.a palindrome not found exception C.the Boolean value returned from the isPal method D.true<div style=padding-top: 35px> What does the method palindrome return?
A.false
B.a palindrome not found exception
C.the Boolean value returned from the isPal method
D.true
سؤال
Consider the fib method from the textbook shown below. Consider the fib method from the textbook shown below.   Calling fib(3) will trigger ___ recursive call(s) and execute the terminating condition ___ time(s), respectively. A.1, 1 B.1, 2 C.2, 2 D.2, 1<div style=padding-top: 35px> Calling fib(3) will trigger ___ recursive call(s) and execute the terminating condition ___ time(s), respectively.
A.1, 1
B.1, 2
C.2, 2
D.2, 1
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/99
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 13: Recursion
1
Consider the following recursive code snippet: Consider the following recursive code snippet:   A.1 B.11 C.5 D.6
A.1
B.11
C.5
D.6
5
2
Consider the getArea method from the textbook shown below. Consider the getArea method from the textbook shown below.   What will be the result? A.The method will return incorrect results for triangles with width equal to 0. B.The method will return incorrect results for triangles with width equal to 1. C.The method will return area to be one too high for all triangles. D.The method will still return correct results for all non-negative width triangles. What will be the result?
A.The method will return incorrect results for triangles with width equal to 0.
B.The method will return incorrect results for triangles with width equal to 1.
C.The method will return area to be one too high for all triangles.
D.The method will still return correct results for all non-negative width triangles.
The method will still return correct results for all non-negative width triangles.
3
What is required to make a recursive method successful?
I special cases that handle the simplest computations directly
II a recursive call to simplify the computation
III a mutual recursion
A.I, II, and III
B.II only
C.I only
D.I and II only
I and II only
4
Consider the recursive method myPrint shown in this code snippet: Consider the recursive method myPrint shown in this code snippet:   What does this method do? A.Prints a positive int value forward, digit by digit. B.Divides the int by 10 and prints out the result. C.Divides the int by 10 and prints out its last digit. D.Prints a positive int value backward, digit by digit. What does this method do?
A.Prints a positive int value forward, digit by digit.
B.Divides the int by 10 and prints out the result.
C.Divides the int by 10 and prints out its last digit.
D.Prints a positive int value backward, digit by digit.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
5
Consider the following code snippet for recursive addition: Consider the following code snippet for recursive addition:   Identify the terminating condition in this recursive method. A.there is no terminating condition B.i == 0 C.return j D.return add(i - 1, j + 1) Identify the terminating condition in this recursive method.
A.there is no terminating condition
B.i == 0
C.return j
D.return add(i - 1, j + 1)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
6
Consider the code for the recursive method riddle shown in this code snippet: Consider the code for the recursive method riddle shown in this code snippet:   To avoid infinite recursion, which of the following lines of code should replace the current terminating case? A.if (n <= 0) B.if (n == -1) C.if (n >= 0) D.The terminating case as shown will avoid infinite recursion. To avoid infinite recursion, which of the following lines of code should replace the current terminating case?
A.if (n <= 0)
B.if (n == -1)
C.if (n >= 0)
D.The terminating case as shown will avoid infinite recursion.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
7
Insert the missing code in the following code fragment.This fragment is intended to recursively compute xn, where x and n are both non-negative integers: Insert the missing code in the following code fragment.This fragment is intended to recursively compute xn, where x and n are both non-negative integers:   A.return power(x, n - 1); B.return x; C.return 1; D.return x * power(x, n - 1);
A.return power(x, n - 1);
B.return x;
C.return 1;
D.return x * power(x, n - 1);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
8
Consider the getArea method from the textbook shown below. Consider the getArea method from the textbook shown below.   Where is/are the recursive call(s)? A.lines #1 and #2 B.line #4 C.line #1 D.line #2 Where is/are the recursive call(s)?
A.lines #1 and #2
B.line #4
C.line #1
D.line #2
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
9
Consider the getArea method from the book shown below. Consider the getArea method from the book shown below.   What will happen when this code is executed? A.Nothing - the method would still be correct. B.We would lose our only recursive case. C.A positive width would reduce the correct area by 1. D.A negative or zero width would cause problems. What will happen when this code is executed?
A.Nothing - the method would still be correct.
B.We would lose our only recursive case.
C.A positive width would reduce the correct area by 1.
D.A negative or zero width would cause problems.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
10
Consider the following code snippet for calculating Fibonacci numbers recursively: Consider the following code snippet for calculating Fibonacci numbers recursively:   Identify the terminating condition in this recursive method. A.n < 1 B.n <= 1 C.fib(n - 1) D.fib(n - 1) + fib(n - 1) Identify the terminating condition in this recursive method.
A.n < 1
B.n <= 1
C.fib(n - 1)
D.fib(n - 1) + fib(n - 1)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
11
A recursive method without a special terminating case would _________
A.be more efficient.
B.never terminate.
C.end immediately.
D.not be recursive.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
12
Consider the following recursive code snippet: Consider the following recursive code snippet:   } Identify the terminating condition(s) of method mystery? A.n <= 0 B.n > 0 C.n == 1 D.n <= 0 or n == 1 }
Identify the terminating condition(s) of method mystery?
A.n <= 0
B.n > 0
C.n == 1
D.n <= 0 or n == 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
13
Complete the code for the recursive method printSum shown in this code snippet, which is intended to return the sum of digits from 1 to n: Complete the code for the recursive method printSum shown in this code snippet, which is intended to return the sum of digits from 1 to n:   A.return (n + printSum(n - 1)); B.return (n - printSum(n - 1)); C.return (n + printSum(n + 1)); D.return (printSum(n - 1));
A.return (n + printSum(n - 1));
B.return (n - printSum(n - 1));
C.return (n + printSum(n + 1));
D.return (printSum(n - 1));
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
14
If recursion does not have a special terminating case, what error will occur?
A.Illegal argument
B.Out of memory
C.Stack overflow
D.Index out of range
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
15
Consider the getArea method from the textbook shown below: Consider the getArea method from the textbook shown below:   A.Those with width equal to 0. B.Triangles of any width. C.Those with width equal to 1. D.Those with width greater than or equal to 2.
A.Those with width equal to 0.
B.Triangles of any width.
C.Those with width equal to 1.
D.Those with width greater than or equal to 2.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
16
Consider the recursive method myPrint: Consider the recursive method myPrint:   What is printed for the call myPrint(8)? A.4 B.21 C.10 D.8 What is printed for the call myPrint(8)?
A.4
B.21
C.10
D.8
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
17
Consider the following recursive code snippet: Consider the following recursive code snippet:   What value is returned from a call to mystery(3,6)? A.18 B.3 C.6 D.729 What value is returned from a call to mystery(3,6)?
A.18
B.3
C.6
D.729
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
18
Consider the code for the recursive method mystery shown in this code snippet: Consider the code for the recursive method mystery shown in this code snippet:   What will be printed by the statement System.out.println(mystery(-4));? A.Nothing - a StackoverflowError exception will occur B.0 C.-22 D.-10 What will be printed by the statement System.out.println(mystery(-4));?
A.Nothing - a StackoverflowError exception will occur
B.0
C.-22
D.-10
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
19
Consider the getArea method from the textbook shown below. Consider the getArea method from the textbook shown below.   Where is/are the terminating condition(s)? A.line #2 B.line #4 C.line #1 D.lines #1 and #2 Where is/are the terminating condition(s)?
A.line #2
B.line #4
C.line #1
D.lines #1 and #2
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
20
Consider the recursive method myPrint in this code snippet: Consider the recursive method myPrint in this code snippet:   What is printed for the call myPrint(821)? A.821 B.12 C.10 D.128 What is printed for the call myPrint(821)?
A.821
B.12
C.10
D.128
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
21
Would switching the special case order affect the return value of the following method? Would switching the special case order affect the return value of the following method?   A.An exception will be thrown. B.Yes C.No D.It is impossible to tell.
A.An exception will be thrown.
B.Yes
C.No
D.It is impossible to tell.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
22
Consider the problem of arranging matchsticks so as to form a row of squares, as shown below for three squares and ten matchsticks. Consider the problem of arranging matchsticks so as to form a row of squares, as shown below for three squares and ten matchsticks.   A.4 * squares; B.3 + matchsticks(squares - 1); C.4 + matchsticks(squares - 1); D.matchsticks(squares + 4);
A.4 * squares;
B.3 + matchsticks(squares - 1);
C.4 + matchsticks(squares - 1);
D.matchsticks(squares + 4);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
23
Consider the method below, which implements the exponentiation operation recursively.Select the statement that should be used to complete the method so that it handles the special case correctly. Consider the method below, which implements the exponentiation operation recursively.Select the statement that should be used to complete the method so that it handles the special case correctly.   A.return 0; B.return 1 * power(base, exponent - 1); C.return base; D.return 1;
A.return 0;
B.return 1 * power(base, exponent - 1);
C.return base;
D.return 1;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
24
Consider the method below, which displays the characters from a String in reverse order.Each character appears on a separate line.Select the statement that should be used to complete the method so that it performs a recursive method call correctly. Consider the method below, which displays the characters from a String in reverse order.Each character appears on a separate line.Select the statement that should be used to complete the method so that it performs a recursive method call correctly.   A.printReverse(word.length() - 1); B.printReverse(word.substring(1)); C.printReverse(word); D.printReverse(new String(word.charAt(1)));
A.printReverse(word.length() - 1);
B.printReverse(word.substring(1));
C.printReverse(word);
D.printReverse(new String(word.charAt(1)));
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
25
Consider the method powerOfTwo shown below: Consider the method powerOfTwo shown below:   What is the best interpretation of line #1? A.1 is an invalid choice for n B.Any multiple of one is a power of two C.One is not a power of two D.One is a power of two What is the best interpretation of line #1?
A.1 is an invalid choice for n
B.Any multiple of one is a power of two
C.One is not a power of two
D.One is a power of two
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
26
Which of the following options could be used as a terminating condition for a recursive method that finds the middle character of a String with any number of characters?
I the length of the String is 1
II first and last String characters match
III the String is not empty
A.I only
B.I and III only
C.I, II and III
D.II only
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
27
If a recursive method does not simplify the computation within the method and the base case is not called, what will be the result?
A.The recursion calculation will occur correctly regardless.
B.Infinite recursion will occur.
C.This cannot be determined.
D.The terminating condition will be executed and recursion will end.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
28
Consider the method powerOfTwo shown below: Consider the method powerOfTwo shown below:   How many recursive calls are made from the original call powerOfTwo(63) (not including the original call)? A.1 B.6 C.0 D.4 How many recursive calls are made from the original call powerOfTwo(63) (not including the original call)?
A.1
B.6
C.0
D.4
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
29
Complete the code for the recursive method shown below, which is intended to compute the sum of the first n positive integers: Complete the code for the recursive method shown below, which is intended to compute the sum of the first n positive integers:   A.return n + s(n - 1); B.return s(n) + n - 1; C.return n + (n - 1); D.return n + s(n + 1);
A.return n + s(n - 1);
B.return s(n) + n - 1;
C.return n + (n - 1);
D.return n + s(n + 1);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
30
Consider the getArea method from the textbook shown below: Consider the getArea method from the textbook shown below:   This would cause infinite recursion for ____. A.triangles with width equal to 1 B.triangles with width equal to 0 C.triangles with width greater than or equal to 2 D.triangles of any width This would cause infinite recursion for ____.
A.triangles with width equal to 1
B.triangles with width equal to 0
C.triangles with width greater than or equal to 2
D.triangles of any width
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
31
Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method: Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method:   A.return (anInteger * (myFactorial(anInteger - 1))); B.return (anInteger * (myFactorial(anInteger))); C.return ((anInteger - 1) * (myFactorial(anInteger))); D.return ((anInteger - 1)*(myFactorial(anInteger - 1)));
A.return (anInteger * (myFactorial(anInteger - 1)));
B.return (anInteger * (myFactorial(anInteger)));
C.return ((anInteger - 1) * (myFactorial(anInteger)));
D.return ((anInteger - 1)*(myFactorial(anInteger - 1)));
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
32
____ recursion can occur when a recursive algorithm does not contain a special case to handle the simplest computations directly.
A.Non-mutual
B.Terminating condition
C.Mutual
D.Infinite
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
33
Consider the following recursive code snippet: Consider the following recursive code snippet:   What parameter values for n would cause an infinite recursion problem in the following method? A.all n with n < 0 B.n == 0 C.all n with n >= 0 D.n == 1 What parameter values for n would cause an infinite recursion problem in the following method?
A.all n with n < 0
B.n == 0
C.all n with n >= 0
D.n == 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
34
Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method: Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method:   A.return 0; B.return myFactorial(anInteger); C.return 1; D.return -anInteger;
A.return 0;
B.return myFactorial(anInteger);
C.return 1;
D.return -anInteger;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
35
Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method: Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method:   A.if (anInteger * (anInteger - 1) == 1) B.if (anInteger == 1) C.if (myFactorial(anInteger) == 1) D.if ((anInteger - 1) == 1)
A.if (anInteger * (anInteger - 1) == 1)
B.if (anInteger == 1)
C.if (myFactorial(anInteger) == 1)
D.if ((anInteger - 1) == 1)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
36
How many recursive calls to the fib method shown below would be made from an original call to fib(4)? (Do not count the original call) How many recursive calls to the fib method shown below would be made from an original call to fib(4)? (Do not count the original call)   A.8 B.4 C.1 D.2
A.8
B.4
C.1
D.2
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
37
Consider the method below, which prints the digits of an arbitrary positive integer in reverse order, one digit per line.The method should print the last digit first.Then, it should recursively print the integer obtained by removing the last digit.Select the statements that should be used to complete the method. Consider the method below, which prints the digits of an arbitrary positive integer in reverse order, one digit per line.The method should print the last digit first.Then, it should recursively print the integer obtained by removing the last digit.Select the statements that should be used to complete the method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
38
Consider the method powerOfTwo shown below: Consider the method powerOfTwo shown below:   How many recursive calls are made from the original call of powerOfTwo(64) (not including the original call)? A.6 B.4 C.8 D.2 How many recursive calls are made from the original call of powerOfTwo(64) (not including the original call)?
A.6
B.4
C.8
D.2
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
39
Consider the getArea method from the textbook shown below: Consider the getArea method from the textbook shown below:   If line #1 was eliminated from the method, what would be the result when calling getArea? A.A positive width would reduce the correct area by 1. B.We would lose our only recursive case. C.Nothing - the method would still work correctly. D.A negative or zero width would cause problems. If line #1 was eliminated from the method, what would be the result when calling getArea?
A.A positive width would reduce the correct area by 1.
B.We would lose our only recursive case.
C.Nothing - the method would still work correctly.
D.A negative or zero width would cause problems.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
40
When a recursive method is called correctly, and it does not perform recursion, what must be true?
A.Both a terminating condition and a recursive case condition were true.
B.A terminating condition was true.
C.All recursive case conditions were true.
D.One recursive case condition was true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
41
Given the following code snippet: Given the following code snippet:   What value will be returned when this code is executed with a call to newCalc(15)? A.2.5 B.5 C.5.5 D.2 What value will be returned when this code is executed with a call to newCalc(15)?
A.2.5
B.5
C.5.5
D.2
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
42
Given the following class code: Given the following class code:   What values will be printed when this code is executed? A.3, 6, and 9 B.6 C.1, 3, 6, and 9 D.9 What values will be printed when this code is executed?
A.3, 6, and 9
B.6
C.1, 3, 6, and 9
D.9
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
43
Given the following code snippet: Given the following code snippet:   What value will be returned when this code is executed with a call to newCalc(15)? A.2 B.6.5 C.2.5 D.6 What value will be returned when this code is executed with a call to newCalc(15)?
A.2
B.6.5
C.2.5
D.6
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
44
Consider the code for the recursive method printSum shown in this code snippet, which is intended to return the sum of digits from 1 to n: Consider the code for the recursive method printSum shown in this code snippet, which is intended to return the sum of digits from 1 to n:   Which of the following statements is correct? A.line #3 is incorrect, and should be changed to return (n + printSum(n + 1)); B.line #1 is incorrect, and should be changed to if (n <= 1) C.line #3 is incorrect, and should be changed to return (n + printSum(n - 1)); D.line #3 is incorrect, and should be changed to return (printSum(n - 1)); Which of the following statements is correct?
A.line #3 is incorrect, and should be changed to return (n + printSum(n + 1));
B.line #1 is incorrect, and should be changed to if (n <= 1)
C.line #3 is incorrect, and should be changed to return (n + printSum(n - 1));
D.line #3 is incorrect, and should be changed to return (printSum(n - 1));
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
45
Complete the following code snippet, which is intended to be a recursive method that will find the smallest value in an array of double values from index to the end of the array: Complete the following code snippet, which is intended to be a recursive method that will find the smallest value in an array of double values from index to the end of the array:   A.return elements[index]; B.return 0; C.return 1; D.return elements[0];
A.return elements[index];
B.return 0;
C.return 1;
D.return elements[0];
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
46
Given the following class code: Given the following class code:   What values will be printed when this code is executed? A.4 B.8 C.0, 4, and 8 D.4 and 8 What values will be printed when this code is executed?
A.4
B.8
C.0, 4, and 8
D.4 and 8
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
47
Complete the following code snippet, which is intended to be a recursive method that will find the sum of all elements in an array of double values from the beginning of the array to index: Complete the following code snippet, which is intended to be a recursive method that will find the sum of all elements in an array of double values from the beginning of the array to index:   A.return (arr[index] + findSum(arr, index + 1)); B.return (findSum(arr, index - 1)); C.return (findSum(arr, index + 1)); D.return (arr[index] + findSum(arr, index - 1));
A.return (arr[index] + findSum(arr, index + 1));
B.return (findSum(arr, index - 1));
C.return (findSum(arr, index + 1));
D.return (arr[index] + findSum(arr, index - 1));
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
48
Given the following class code: Given the following class code:   What values will be printed? A.1, 3, and 6 B.3, 6, 9, and 12 C.1, 3, 6, and 9 D.3, 6, and 9 What values will be printed?
A.1, 3, and 6
B.3, 6, 9, and 12
C.1, 3, 6, and 9
D.3, 6, and 9
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
49
Given the following code snippet: Given the following code snippet:   What value will be returned when this code is executed with a call to newCalc(5)? A.5 B.1.5 C.5.5 D.1 What value will be returned when this code is executed with a call to newCalc(5)?
A.5
B.1.5
C.5.5
D.1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
50
The method below generates all nonempty substrings of a word passed as argument.Assuming that the string contains no duplicate characters, select the statement to complete the method so that it prints all nonempty substrings correctly. The method below generates all nonempty substrings of a word passed as argument.Assuming that the string contains no duplicate characters, select the statement to complete the method so that it prints all nonempty substrings correctly.   A.printSubstrings(word.substring(0)); B.printSubstrings(word.substring(1)); C.printSubstrings(word.substring(word.length())); D.printSubstrings(word.substring(word.length() - 1));
A.printSubstrings(word.substring(0));
B.printSubstrings(word.substring(1));
C.printSubstrings(word.substring(word.length()));
D.printSubstrings(word.substring(word.length() - 1));
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
51
Given the following code snippet: Given the following code snippet:   What value will be returned when this code is executed with a call to newCalc(5)? A.2.5 B.5.5 C.5 D.2 What value will be returned when this code is executed with a call to newCalc(5)?
A.2.5
B.5.5
C.5
D.2
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
52
Complete the following code snippet, which is intended to be a recursive method that reverses a String value: Complete the following code snippet, which is intended to be a recursive method that reverses a String value:   A.return reverseIt; B.return reverseIt; C.return reverseIt; D.return reverseIt;
A.return reverseIt;
B.return reverseIt;
C.return reverseIt;
D.return reverseIt;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
53
Complete the code for the calcPower recursive method shown below, which is intended to raise the base number passed into the method to the exponent power passed into the method: Complete the code for the calcPower recursive method shown below, which is intended to raise the base number passed into the method to the exponent power passed into the method:   A.answer = 0; B.answer = 1; C.answer = calcPower(1); D.answer = -1;
A.answer = 0;
B.answer = 1;
C.answer = calcPower(1);
D.answer = -1;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
54
Complete the following code snippet, which is intended to be a recursive method that will find the smallest value in an array of double values from index to the end of the array: Complete the following code snippet, which is intended to be a recursive method that will find the smallest value in an array of double values from index to the end of the array:   A.minVal(elements, index - 1) B.minVal(index - 1) C.minVal(elements, index + 1) D.minVal(index + 1)
A.minVal(elements, index - 1)
B.minVal(index - 1)
C.minVal(elements, index + 1)
D.minVal(index + 1)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
55
Complete the following code snippet, which is intended to be a recursive method that reverses a String value: Complete the following code snippet, which is intended to be a recursive method that reverses a String value:   A.return s.charAt(0); B.return 0; C.return s.substring(1); D.return s;
A.return s.charAt(0);
B.return 0;
C.return s.substring(1);
D.return s;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
56
Given the following class code: Given the following class code:   What values will be printed when this code is executed? A.8 B.4 C.4 and 8 D.0, 4, and 8 What values will be printed when this code is executed?
A.8
B.4
C.4 and 8
D.0, 4, and 8
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
57
Which of the following is NOT true about debugging a recursive method by setting a breakpoint on the line containing a return statement?
A.You cannot debug a recursive method with the debugger.
B.The debugger's call stack will show all the calls to the recursive method that are pending.
C.You can select a pending call and then inspect the value of its variables.
D.The last call on the stack represents the first recursive call to reach the return statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
58
Complete the code for the calcPower recursive method shown below, which is intended to raise the base number passed into the method to the exponent power passed into the method: Complete the code for the calcPower recursive method shown below, which is intended to raise the base number passed into the method to the exponent power passed into the method:   A.answer = baseNum * calcPower (baseNum -1, exponent - 1); B.answer = baseNum * calcPower (baseNum, exponent); C.answer = baseNum * calcPower (baseNum -1, exponent); D.answer = baseNum * calcPower (baseNum, exponent - 1);
A.answer = baseNum * calcPower (baseNum -1, exponent - 1);
B.answer = baseNum * calcPower (baseNum, exponent);
C.answer = baseNum * calcPower (baseNum -1, exponent);
D.answer = baseNum * calcPower (baseNum, exponent - 1);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
59
Complete the following code snippet, which is intended to be a recursive method that will find the sum of all elements in an array of double values from the beginning of the array to index: Complete the following code snippet, which is intended to be a recursive method that will find the sum of all elements in an array of double values from the beginning of the array to index:   A.return arr[index + 1]; B.return arr[1]; C.return arr[index - 1]; D.return arr[index];
A.return arr[index + 1];
B.return arr[1];
C.return arr[index - 1];
D.return arr[index];
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
60
Complete the code for the calcPower recursive method shown below, which is intended to raise the base number passed into the method to the exponent power passed into the method: Complete the code for the calcPower recursive method shown below, which is intended to raise the base number passed into the method to the exponent power passed into the method:   A.if (exponent == -1) B.if (exponent == 1) C.if (exponent != 1) D.if (exponent == 0)
A.if (exponent == -1)
B.if (exponent == 1)
C.if (exponent != 1)
D.if (exponent == 0)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
61
Consider the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method: Consider the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method:   If you set a breakpoint on line #2 and then call myFactorial(4), how many calls to myFactorial will be visible on the debugger's call stack when the program suspends for the breakpoint? A.0 because the answer was returned B.3 C.4 D.1 If you set a breakpoint on line #2 and then call myFactorial(4), how many calls to myFactorial will be visible on the debugger's call stack when the program suspends for the breakpoint?
A.0 because the answer was returned
B.3
C.4
D.1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
62
Consider the fib method from the textbook shown below: Consider the fib method from the textbook shown below:   Computing the 7th fibonacci number, fib(7), recursively computes fib(6), fib(5), and fib(4) ___ times respectively. A.6, 5, and 4 B.3, 2, and 1 C.1, 2, and 3 D.4, 5, and 6 Computing the 7th fibonacci number, fib(7), recursively computes fib(6), fib(5), and fib(4) ___ times respectively.
A.6, 5, and 4
B.3, 2, and 1
C.1, 2, and 3
D.4, 5, and 6
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
63
A palindrome is a word or phrase that reads the same forward or backward.Consider the following code snippet: A palindrome is a word or phrase that reads the same forward or backward.Consider the following code snippet:   What is the purpose of the palindrome method? A.Recursively call itself. B.Provide the string, along with its first and last indexes to the recursive isPal method. C.Send the recursive isPal method its terminating condition. D.Return the palindrome to the calling method. What is the purpose of the palindrome method?
A.Recursively call itself.
B.Provide the string, along with its first and last indexes to the recursive isPal method.
C.Send the recursive isPal method its terminating condition.
D.Return the palindrome to the calling method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
64
Consider the square method shown below that takes a non-negative int argument.Complete the code for the square method so that it correctly calls the squareHelper method to produce the square of n. Consider the square method shown below that takes a non-negative int argument.Complete the code for the square method so that it correctly calls the squareHelper method to produce the square of n.   A.return squareHelper(n - 1, n) B.return squareHelper(n, n - 1) C.return square(n) D.return squareHelper(n, n)
A.return squareHelper(n - 1, n)
B.return squareHelper(n, n - 1)
C.return square(n)
D.return squareHelper(n, n)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
65
Consider the recursive version of the fib method from the textbook shown below: Consider the recursive version of the fib method from the textbook shown below:   How many recursive calls to fib(2) will be made from the original call of fib(6)? A.4 B.3 C.5 D.2 How many recursive calls to fib(2) will be made from the original call of fib(6)?
A.4
B.3
C.5
D.2
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
66
Consider the recursive version of the fib method from the textbook shown below: Consider the recursive version of the fib method from the textbook shown below:   How many total recursive calls (not counting the original call) to fib will be made from the original call of fib(7)? A.12 B.32 C.24 D.30 How many total recursive calls (not counting the original call) to fib will be made from the original call of fib(7)?
A.12
B.32
C.24
D.30
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
67
Consider the square method shown below that takes a non-negative int argument: Consider the square method shown below that takes a non-negative int argument:   What would a call to square(7) return? A.7 B.14 C.13 D.49 What would a call to square(7) return?
A.7
B.14
C.13
D.49
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
68
Consider the square method shown below that takes a non-negative int argument. Consider the square method shown below that takes a non-negative int argument.   What would a call to square(4) return? A.256 B.4 C.16 D.64 What would a call to square(4) return?
A.256
B.4
C.16
D.64
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
69
A palindrome is a word or phrase that reads the same forward or backward.Consider the following code snippet: A palindrome is a word or phrase that reads the same forward or backward.Consider the following code snippet:   A.You have reached the middle of the string. B.It cannot be determined if the string is a palindrome. C.An empty or one-character string is considered a palindrome. D.The string is not a palindrome.
A.You have reached the middle of the string.
B.It cannot be determined if the string is a palindrome.
C.An empty or one-character string is considered a palindrome.
D.The string is not a palindrome.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
70
Assume that recursive method search returns true if argument value is one of the elements in the section of the array limited by the firstIndex and lastIndex arguments.What statement can be used in main to determine if the value 7 is one of the elements in array values? Assume that recursive method search returns true if argument value is one of the elements in the section of the array limited by the firstIndex and lastIndex arguments.What statement can be used in main to determine if the value 7 is one of the elements in array values?   A.search(7, values, 1, values.length) B.search(7, values, 1, values.length - 1) C.search(7, values, 0, values.length) D.search(7, values, 0, values.length - 1)
A.search(7, values, 1, values.length)
B.search(7, values, 1, values.length - 1)
C.search(7, values, 0, values.length)
D.search(7, values, 0, values.length - 1)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
71
A palindrome is a word or phrase that reads the same forward or backward.Consider the methods palindrome and isPal shown below: A palindrome is a word or phrase that reads the same forward or backward.Consider the methods palindrome and isPal shown below:   The method isPal as shown here would be considered to be a ____ method. A.terminating B.static C.recursive helper D.public The method isPal as shown here would be considered to be a ____ method.
A.terminating
B.static
C.recursive helper
D.public
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
72
Consider the iterative version of the fib method from the textbook shown below: Consider the iterative version of the fib method from the textbook shown below:   How many iterations of the for loop will there be for the call fib(6)? A.3 B.5 C.6 D.4 How many iterations of the for loop will there be for the call fib(6)?
A.3
B.5
C.6
D.4
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
73
Consider the recursive version of the fib method from the textbook shown below: Consider the recursive version of the fib method from the textbook shown below:   How many total recursive calls (not counting the original call) to fib will be made from the original call of fib(6)? A.14 B.12 C.6 D.20 How many total recursive calls (not counting the original call) to fib will be made from the original call of fib(6)?
A.14
B.12
C.6
D.20
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
74
Why does the best recursive method usually run slightly slower than its iterative counterpart?
A.Each recursive method call takes processor time.
B.Multiple recursive cases must be considered.
C.Checking multiple terminating conditions take more processor time.
D.Testing the terminating condition takes longer.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
75
Consider the problem of displaying a pattern of asterisks that form a triangle of height h, as shown below for h = 4: Consider the problem of displaying a pattern of asterisks that form a triangle of height h, as shown below for h = 4:   A.shape(0, height - 1); B.shape(0, height - 1); C.shape(1, height); D.shape(0, height);
A.shape(0, height - 1);
B.shape(0, height - 1);
C.shape(1, height);
D.shape(0, height);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
76
Consider the helper method reversePrint, which uses recursion to display in reverse the elements in a section of an array limited by the firstIndex and lastIndex arguments.What statement should be used to complete the recursive method? Consider the helper method reversePrint, which uses recursion to display in reverse the elements in a section of an array limited by the firstIndex and lastIndex arguments.What statement should be used to complete the recursive method?   A.reversePrint(array, firstIndex, lastIndex - 1); B.reversePrint(array, firstIndex + 1, lastIndex); C.reversePrint(array, firstIndex + 1, lastIndex - 1); D.reversePrint(array, firstIndex, lastIndex + 1);
A.reversePrint(array, firstIndex, lastIndex - 1);
B.reversePrint(array, firstIndex + 1, lastIndex);
C.reversePrint(array, firstIndex + 1, lastIndex - 1);
D.reversePrint(array, firstIndex, lastIndex + 1);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
77
Consider the recursive version of the fib method from the textbook shown below: Consider the recursive version of the fib method from the textbook shown below:   How many more recursive calls to fib will be made from the original call of fib(7) than from the original call of fib(6) (not counting the original calls)? A.2 B.10 C.5 D.1 How many more recursive calls to fib will be made from the original call of fib(7) than from the original call of fib(6) (not counting the original calls)?
A.2
B.10
C.5
D.1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
78
Consider the helper method reversePrint, which uses recursion to display in reverse the elements in a section of an array limited by the firstIndex and lastIndex arguments.What statement should be used to complete the recursive method? Consider the helper method reversePrint, which uses recursion to display in reverse the elements in a section of an array limited by the firstIndex and lastIndex arguments.What statement should be used to complete the recursive method?   A.array[firstIndex] B.array[firstIndex+1] C.array[lastIndex-1] D.array[lastIndex]
A.array[firstIndex]
B.array[firstIndex+1]
C.array[lastIndex-1]
D.array[lastIndex]
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
79
A palindrome is a word or phrase spelled which reads the same forward or backward.Consider the following code snippet: A palindrome is a word or phrase spelled which reads the same forward or backward.Consider the following code snippet:   What does the method palindrome return? A.false B.a palindrome not found exception C.the Boolean value returned from the isPal method D.true What does the method palindrome return?
A.false
B.a palindrome not found exception
C.the Boolean value returned from the isPal method
D.true
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
80
Consider the fib method from the textbook shown below. Consider the fib method from the textbook shown below.   Calling fib(3) will trigger ___ recursive call(s) and execute the terminating condition ___ time(s), respectively. A.1, 1 B.1, 2 C.2, 2 D.2, 1 Calling fib(3) will trigger ___ recursive call(s) and execute the terminating condition ___ time(s), respectively.
A.1, 1
B.1, 2
C.2, 2
D.2, 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.