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

Solve the follwing by using the spanning tree method. Answer the problem write o

ID: 3824109 • Letter: S

Question

Solve the follwing by using the spanning tree method. Answer the problem write out the answer on the provided blank. Take a screenshot, or picture or submit the Word document with the traced out spanning tree solution and the written solution on the paper. Make sure the spanning tree is legible and the answers are visible and not blurry. This is Java

What is returned by recurs(4)?

public int recurs(int n)

{

int result = 0;

if(n<=3)

result = 2;

else

result = recurs(n - 2) + (n - 2);

return result;

}

What is returned by try(1) ?

What is returned by try(6) ?

public int try(int n)

{

if(n==1 || n==2)

return 2*n;

else

return try(n - 1) + try(n - 2);

}

What is returned by wow(2) ?

What is returned by wow(-5) ?

public static int wow(int x)

{

if(x<10)

return x + wow(x+2);

else

return 1;

}

What is returned by roses(5)?

What is returned by roses(0)?

public static int roses(int x)

{

if ( x == 0)

return 1;

if( x % 2 != 0)

return roses(x – 1) + x;

return roses(x – 2) + x;

}

What is returned by the method call rec(“abcdef”)? _____

What is returned by the method call rec(“”)? ______

public static String rec(String s)

{

if(s == null || s.length() ==0)

return “”;

return (s.charAt(s.length( )-1 ) + rec(s.substring(0,s.length( )/2));

}

9! =

0! =

What is the 8th number in Fibonacci’s sequence?

Explanation / Answer

public int recurs(int n)

{

int result = 0;

if(n<=3)

result = 2;

else

result = recurs(n - 2) + (n - 2);

return result;

}

What is returned by recurs(4)? ANS) 4

public int try(int n)

{

if(n==1 || n==2)

return 2*n;

else

return try(n - 1) + try(n - 2);

}

What is returned by try(1) ? ANS) 2

What is returned by try(6) ? ANS) 26

public static int wow(int x)

{

if(x<10)

return x + wow(x+2);

else

return 1;

}

What is returned by wow(2) ? ANS) 21

What is returned by wow(-5) ? ANS) 17

public static int roses(int x)

{

if ( x == 0)

return 1;

if( x % 2 != 0)

return roses(x – 1) + x;

return roses(x – 2) + x;

}

What is returned by roses(5)? ANS)12

What is returned by roses(0)?ANS) 1

9! = 362880

0! =0

What is the 8th number in Fibonacci’s sequence? ANS) 21

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