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
Drupady [299]
4 years ago
14

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:
Archy [21]4 years ago
8 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
Why can videos be streamed from the cloud to a computer with no loss in
mezya [45]
I think the answer is B
3 0
3 years ago
Read 2 more answers
Write a job back with my best Interest
Katena32 [7]

Answer:

be a doctor

Explanation:

u will help people and save them and get paid

6 0
3 years ago
Read 2 more answers
Notice that the iris.target array contains 3 different labels. Create a plot that you think is interesting using the data from t
Alexeev081 [22]

Answer:

from sklearn.datasets import load_iris

import seaborn as sns

import pandas as pd

data = load_iris()

final_data = data.data[:]

final_data = pd.DataFrame(final_data)

final_data.columns = ['SepalLengthCm', 'SepalWidthCm', 'PetalLengthCm', 'PetalWidthCm']

species = data.target[:]

final_data['Species'] = species

sns.pairplot(final_data, hue='Species')

Explanation:

8 0
3 years ago
Lisa and her husband would like to buy a house soon. She continuously pays bills late. How do her actions affect her and others?
stiks02 [169]
Well actually it affects her credit. Home owners would not want to sell a house to someone who doesn't pay bills on time. It shows he/she is unreliable

3 0
3 years ago
Read 2 more answers
What is the difference between a ROM chip and a RAM chip?
Leokris [45]

Answer:

A: A ROM chip is non-volatile and will keep its data in the case of a power failure. A RAM chip is volatile and will wipe its data in the case of a power failure.

Explanation:

ROM chips were widely used at the time of the old consoles, because with it you had an extremely fast and non-volatile memory, but this technology is very expensive and started to use CDs in the Consoles, while the RAM memory is a memory of execution random (RAM = RANDOM ACESS MEMORY).

4 0
3 years ago
Other questions:
  • Can you find the ip address from a physical address
    13·1 answer
  • Using the ____ browsing mode offered by some browsers can prevent personal information from being left on a public computer.
    10·1 answer
  • Kaira's company recently switched to a new calendaring system provided by a vendor. Kaira and other users connect to the system,
    11·1 answer
  • A(n) _____ access file is also known as a direct access file.
    13·1 answer
  • A company used computer auditing techniques to compare employees' telephone numbers with vendors' telephone numbers. This is an
    10·2 answers
  • What is the correct html element for playing audio files?
    11·1 answer
  • How are computers used in education and entertainment? List them.​
    10·1 answer
  • A computer follows step-wise instructions to complete any task which is known as?
    5·1 answer
  • Ransomware as a service has allowed the increase of:.
    10·1 answer
  • Write a function that receives a StaticArray and returns an integer that describes whether the array is sorted. The method must
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!