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
defon
3 years ago
11

Implement a sublinear running time complexity recursive function in Java public static long exponentiation (long x, int n) to ca

lculate x^n. Note: In your function you can use only the basic arithmetic operators (+, -, *, and /).
Computers and Technology
1 answer:
Charra [1.4K]3 years ago
4 0

Answer:

Following are the code block in the Java Programming Language.

//define recursive function

public static long exponentiation(long x, int n) {

//check the integer variable is equal to the 0.

if (x == 0) {

//then, return 1

return 1;

}

//Otherwise, set else

else {

//set long data type variable

long q = exponentiation(x, n/2);

q *= q;

//check if the remainder is 1

if (n % 2 == 1) {

q *= x;

}

//return the variable

return q;

}

}

Explanation:

<u>Following are the description of the code block</u>.

  • Firstly, we define the long data type recursive function.
  • Then, set the if conditional statement and return the value 1.
  • Otherwise, set the long data type variable 'q' that sore the output of the recursive function.
  • Set the if conditional statement and check that the remainder is 1 and return the variable 'q'.
You might be interested in
A good example of an agency relationship in a hotel is the relationship between a bartender and a server. True False
ololo11 [35]

Answer:

False

Explanation:

An agency relationship is a fiduciary relationship, where one person (called the 'principal') allows an agent to act on his or her behalf. The agent is subject to the principal's control and must consent to her instructions.

A good example of agency relationship is between celebrities (musicians, actors etc.) and their managers.

A bartender and a server are nowhere near two parties in an agency relationship with each other.

8 0
3 years ago
Acceptance tests are normally conducted by the
dedylja [7]
The answer is D. System engineers
7 0
4 years ago
Read 2 more answers
The risk of carbon monoxide poisoning can be reduced by
lisov135 [29]
A machine. I foget the name but there can be a machine, or fresh air, or turning off your car, or opening doors and getting out when there;s a fire or smoke.
5 0
4 years ago
What are table buffers?
laiz [17]

Answer:

Table buffers are tools used to avoid the process of accessing a database in servers.

4 0
3 years ago
Many Internet servers have an easy-to-remember name, such as nike. The official term for this name is ____.
san4es73 [151]

Answer:

SSID

Explanation:

i tried

..............

6 0
3 years ago
Other questions:
  • Write down the pseudo code of a program that calculates the Body Mass Index (BMI) of
    9·1 answer
  • The next four octal numbers after 36 is:________.
    10·1 answer
  • What does the regular expression [a-z0-9\-] mean?
    8·1 answer
  • Caitlyn's Crafty Creations computes a retail price for each product as the cost of materials plus $14 multiplied by the number o
    10·1 answer
  • What is the value of alpha[3] after the following code executes?
    6·1 answer
  • Write a C++ program that would take 10 integers and outputs mean, median, and range. Create at least three functions: one for so
    7·1 answer
  • The fractional_part function divides the numerator by the denominator, and returns just the fractional part.
    10·1 answer
  • You are the network administrator for a city library. Throughout the library, there are several groups of computers that provide
    12·1 answer
  • PLEASE HELP!!! NO LINKS!! I'LL GIVE BRAINLIEST!!
    12·2 answers
  • 3.12 LAB: Output range with increment of 5 Write a program whose input is two integers, and whose output is the first integer an
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!