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]
2 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]2 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
The while loop has two important parts: a condition that is tested and a statement or block of statements that is repeated as lo
natima [27]

Answer:

TRUE

Explanation:

The while loop is used to run the block of statement again and again until condition is TRUE. if condition false program terminate the loop and execute the next of while statement.

syntax:

initialize;

while(condition)

{

 statement;

  increment/decrement;

)

when condition is TRUE, the block of statement execute again and again.

8 0
3 years ago
A ______ connection provides fast internet service and the ability to exchange large files. ​
Degger [83]

Answer:

broadband

Explanation:

A<u> broadband</u> connection  provides fast internet service and the ability to exchange large files. ​

3 0
3 years ago
An open intersection is one that
alekssr [168]

 open intersection is one without traffic control signs or signals. When you enter one, you must yield the right-of-way if: A vehicle is already in the intersection. You enter or cross a state highway from a secondary road. hope this helped


4 0
3 years ago
Read 2 more answers
A document format is
anyanavicka [17]

Answer:

A document file format is a text or binary file format for storing documents on a storage media, especially for use by computers. There currently exist a multitude of incompatible document file formats.

Explanation:

8 0
2 years ago
Read 2 more answers
Which mitigation technique would prevent rogue servers from providing false ip configuration parameters to clients?
IrinaVladis [17]
DHCP snooping is a mitigation technique<span> to </span>prevent rogue<span> DHCP </span>servers  <span>from </span>providing false IP configuration parameters to clients.  DHCP snooping<span> is a security feature that acts like a firewall between untrusted hosts and trusted </span>DHCP<span> servers. It is</span><span> a series of techniques applied to improve the security of a </span>DHCP<span> infrastructure. </span>
6 0
3 years ago
Read 2 more answers
Other questions:
  • When you park facing downhill and there is a curb, turn your wheels _____ the curb. When you park facing uphill and there is a c
    13·2 answers
  • ____ are systems in which queues of objects are waiting to be served by various servers
    5·1 answer
  • Which of the following represents inbound logistics for a bookstore
    13·1 answer
  • PLEASE HELP ASAP!!!
    8·1 answer
  • Why when i click home on iphone i still at my grandma house
    11·2 answers
  • Is USA TestPrep a test-taking site that won't let you access other windows without kicking you off?
    13·1 answer
  • What is my favorite color?<br> Red<br>Orange<br>Yellow<br>Blue <br>Gold<br>Silver
    13·1 answer
  • What is the device that uses sprockets along a film's perforated edges to run 50 feet of film in thirty seconds? A. cinematograp
    10·1 answer
  • Nathaniel wanted to buy a microphone. He went to an electronics store and was told that there are actually two types of micropho
    13·2 answers
  • An operating system with _____ capabilities allows a user to run more than one program concurrently.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!