Question
QUESTION 6 Look at the following method. public static int Test2(int x, int y) { if ( x < y) { return -5; } else
QUESTION 6
Look at the following method.
public static int Test2(int x, int y)
{
if ( x < y)
{
return -5;
}
else
{
return (Test2(x - y, y + 5) + 6);
}
}
What is the base case for the method?
x < y | ||
-5 | ||
Test2(x - y, y + 5) + 6 | ||
+6 |
QUESTION 7
Look at the following method.
public static int test2(int x, int y)
{
if ( x < y)
{
return -5;
}
else
{
return (test2(x - y, y + 5) + 6);
}
}
What is returned for test2(18,5)?
6 | ||
-5 | ||
7 | ||
1 |
QUESTION 8
Look at the following pseudocode algorithm.v
Algorithm gcd(x, y)
if (x < y)
gcd (y, x)
else
if (y = 0)
return x
else
return gcd(y, x mod y)
end gcd
What is returned from gcd(60, 24)?
60 | ||
24 | ||
66 | ||
12 |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started