1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ololo11 [35]
3 years ago
8

For the recursive method below, list the base case and the recursive statement, then show your work for solving a call to the re

cur() method using any parameter value 10 or greater.
public static int recur(int n)
{
if(n < 1)
{
return 3;
}
else
{
return recur(n / 5) + 2;
}
}

Computers and Technology
1 answer:
Paul [167]3 years ago
3 0

Answer:

(a): The base case: if(n<1)

(b): The recursive statement: recur(n / 5)

(c): Parameter 10 returns 7

Explanation:

Given

The above code segment

Solving (a): The base case:

The base case is that, which is used to stop the recursion. i.e. when the condition of the base case is true, the function is stopped.

In the given code, the base case is:

<em>if(n<1)</em>

Solving (b): The recursive statement:

The recursive statement is the statement within the function which calls the function.

In the given code, the recursive statement is:

<em> recur(n / 5)</em>

<em />

Solving (c): A call to recur() using 10

The base case is first tested

if (n < 1); This is false because 10 > 1

So, the recursive statement is executed

<em>recur(n/5) +2=> recur(10/5)+2 => recur(2)+2</em>

2 is passed to the function, and it returns 2

if (n < 1); This is false because 2 > 1

So, the recursive statement is executed

<em>recur(n/5) +2=> recur(2/5)+2 => recur(0)+2</em>

2 is passed to the function, and it returns 2

<em />

if (n < 1); This is true because 0 < 1

This returns 3

So, the following sum is returned

Returned values = 2 + 2 + 3

Returned values = 7

You might be interested in
A ____ is a program that lets computer users create and access a collection of organized data.
ruslelena [56]
Database management system
5 0
3 years ago
Linda is searching for a new job. Which information would her potential employers likely review in her social profile?
nasty-shy [4]
The answer will be A they would wanna know about her work history
3 0
3 years ago
Read 2 more answers
In the belt drive mechanism, what happens when the belt is crossed instead of open?
KengaRu [80]
They will spin in the opposite direction because the belts are twisted.
8 0
3 years ago
java class What is the output of the following JAVA program (Java assumes public if no access modifier is given)? class Test { p
Natasha2012 [34]

Answer:

The answer to the given question is it will produce an "error"  

Explanation:

In the given java program it will produce an error because in java we do not use double quote("""") for message printing. We use a single quote("") for message printing. In the given program if we use a single quote(""). so it will give output that is "dogood:dogood".

The correct program to this question is can be given as:

Program:

public class Test  //define a class test.

{

   public static void main(String[] args)  //define main method

   {

       Test obj = new Test();   //create class object  

       obj.start(); //calling function

   }  

   void start()  //define function start.  

   {

       String stra = "do";   //define variable and assign value.

       String strb = method(stra);  //define variable and pass stra variable in method() function as a parameter.

       System.out.print(":"+stra + strb); //print value.  

   }

   String method(String stra)  //define function method  

   {  

       stra = stra + "good";   //add value

       System.out.print(stra);  //print value of stra

       return"good";  //return value

   }

}

Output:

dogood:dogood

6 0
3 years ago
What laws are broken when you hack someone?
postnew [5]

Answer:

it depends

Explanation:

if you are hacking for a purpose that is benefiting the person being hacked, that is ethical hacking. ethical hacking is not illegal, as long as you get permission from the person being hacked.

if you hack someone without their knowledge, that is unethical hacking, and that is in many cases, a crime, and if it has enough of a detrimental effect on a companys process, it could land you into prison and earn you a hefty fine.

ethical hacking is good for testing a networks security, and if all is well, the ethical hacker shouldnt be able to get into a network if it is secured properly.

6 0
3 years ago
Other questions:
  • Libby wrote an email to her friend. She pressed Shift and the number key 2 together to enter the email address. Which symbol did
    7·2 answers
  • The ________ is an area where you can position fields to use for filtering the PivotTable and thereby enabling you to display a
    11·1 answer
  • What is the name of the option in most presentation applications with which you can modify slide elements? The ( answer here )op
    9·1 answer
  • What are the possible consequences of intentional virus setting?
    14·1 answer
  • My serious question that needs answering pronto!!!
    11·1 answer
  • Complete the steps for saving a presentation as a poi file,
    14·1 answer
  • How would you describe binary to someone ??<br> PLEASE ANSWER I WILL GIVE U BRAINLY!!
    15·2 answers
  • What can i say back to my IT school lady?
    8·1 answer
  • Tasha grew up helping her uncle work on cars in his auto repair shop and developed into an excellent auto technician. Because of
    14·1 answer
  • Once you select a theme, you__________ change the theme’s individual elements independently of each other.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!