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
I will mark brainillist if someone answers Donethkm question its How can a Word user insert a page break into a document to isol
zloy xaker [14]

Answer:

Open the dialog box.

Select the tab.

Select the tab.

Explanation:

cause

8 0
3 years ago
Read 2 more answers
A technician is tasked with installing the Windows OS on a Mac OS computer so that the computer can boot to either the Mac OS or
nata0808 [166]

Answer:

Key chain because it easier

Explanation:

4 0
2 years ago
Drag each tile to the correct box. Arrange the statements in sequence to correctly explain what the field of science includes. a
erastova [34]

These refer to the elementary steps of the scientific method.

The correct order is as follows:

  • Keen observation of natural phenomena.

  • The use of imagination and creativity to test understanding and predictions.

  • An attempt to verify the understanding of observed natural occurrences establishing verifiable scientific knowledge

  • Continued observance and testing to revise scientific knowledge.

  • An understanding of how or why these natural phenomena occur.

Learn more about the scientific methods at the link below:

brainly.com/question/497944

3 0
3 years ago
If you inadvertently rename a file that is associated with certain apps, the apps may not be able to find the file and may not r
ad-work [718]
No.... This wont happen.... The computer only renames the file and dont let those apps go....in easy words We can say that the comp tells the apps to stay here...
7 0
3 years ago
Read 2 more answers
You must create an instructional video for your company and are required to ensure it is compatible with your company's windows
enyata [817]
The best video format which should be chosen when creating an instructional video is WMV format. At first, you are asked to make video which will <span>compatible with windows systems and since WMV format is a</span><span> part of the </span>Windows Media<span> framework it is a sensible choice. WMV can be also put into the AVI container format which is quite common among the users.</span>
7 0
4 years ago
Other questions:
  • Computers have become easier to use and more powerful over time.
    12·2 answers
  • Protected base class members cannot be accessed by: a.friends of the base class.
    6·1 answer
  • An attacker captures an encrypted message. he tries decrypting with every possible key until the decryption process reveals a se
    14·1 answer
  • 18. When you turn off the power to a computer and unplug it at night, it loses the date, and you must reenter it each morning. W
    7·2 answers
  • A ___________ assigns levels of risk to various threats to network security by comparing the nature of the threats to the contro
    9·1 answer
  • When using the protection options in Excel 2016, what does the Protect Workbook function do?
    8·2 answers
  • Where would you go to access frequently used icons?
    12·2 answers
  • What is operating system​
    10·2 answers
  • You are building a game that needs to do the following:
    5·1 answer
  • Write algorithm and flowchart for the following<br>a.find the sum and average of any four numbers ​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!