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]
3 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]3 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
Different the policies and protocols in the industry
Rashid [163]

Answer:

7ALWAYS KEEP FOCUS on brainly and I am have been a

8 0
2 years ago
You designed a program to create a username using the first three letters from the first name and the first four letters of the
Pavel [41]

Answer:

See Explanation

Explanation:

The question would be best answered if there are options to select from; since none is provided, I will provide a general explanation.

From the question, we understand that, you are to test for Jo Wen.

Testing your program with this name will crash the program, because Jo has 2 letters (3 letters are required), and Wen has 3 letters (4 letters are required)

So, the step that needs to be revisited is when the username is generated.

Since the person's name cannot be changed and such person will not be prevented from registering on the platform, you need to create a dynamic process that handles names whose lengths are not up to the required length.

7 0
2 years ago
​______________________ is a general security term that includes computer​ viruses, worms, and trojan horses.
VashaNatasha [74]
Malware
-------------------
6 0
3 years ago
Photography is harder with digital cameras than with film cameras.<br>true<br>false
Oliga [24]

the answer is false bc digutal is easeir




7 0
2 years ago
Read 2 more answers
Which of the following correctly identifies a voltage source and its method of developing electric potential?
Semenov [28]
Dry cell- Chemical action
8 0
3 years ago
Read 2 more answers
Other questions:
  • Why is color theory important
    6·2 answers
  • Analyst is investigating proxy logs and found out that one of the internal user visited website storing suspicious java scripts.
    8·1 answer
  • Anna’s computer will not power on. What aspect of the computer should Anna check (hardware or software)? How can Anna work to re
    5·1 answer
  • Who is the founder of javascript? ​
    14·2 answers
  • write the cell address for the following 1. First row and first column 2.First column and last row. 3. 10th column and 19th row.
    5·1 answer
  • Jennifer works as a clerk in a company. The essential function of her job is typing on a keyboard. If she develops crippling art
    11·1 answer
  • Write a java program to create and display unique three digit number using 1,2,3 and 4 also count how many three digit number ar
    10·1 answer
  • If a friend gave a used Wii disc to someone, and they put it in their Wii, could they play it? Nintendo Switch games can only be
    14·1 answer
  • Lab 8-1: Working with Boot Loader and Runlevels what is the root password
    9·1 answer
  • What are three ways of verifying legitimate right of access to a computer system?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!