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
2 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]2 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
Software that interprets command from mouse is a
balu736 [363]
I think it would be me because i interpret command from a mouse in my hole.
3 0
3 years ago
In a spreadsheet what does the following symbol mean?<br><br> $
Diano4ka-milaya [45]

Answer:

$ = dollar sign

Explanation:

6 0
3 years ago
What type of weathering is shown in the diagram? (chemical weathering/carbonation??)
fiasKO [112]
Can you give a better picture plz

7 0
3 years ago
Read 2 more answers
Match the word to its definition:
yuradex [85]

Answer :

All these are a type of computers and is used for processing data.

Explanation:

a. A small portable computer, such as a netbook -- 3. Tablet

b. A type of computer used by many people at the same time to allow access to the same secure data -- 4. Mainframes

c. A device that includes, text, and data capabilities -- 1. Smart phone

d. An individual’s personal computer that resides on a desk or table -- 6. Desktop

e. A computer that combines the features of a graphic tablet with the functions of a personal computer; sometimes called a tablet PC -- 5. Notebook

f. A large and powerful scientific computer that can process large amounts of data quickly -- 2. Super computer  

g. The coded instructions that tell a computer what to do; also to write the code for a program -- 7. Program

h. Is a machine that changes information from one form into another by performing four basic actions -- 8. Computer

3 0
2 years ago
You turn your computer on and the computer will not boot up where is something you should do to diagnose the problem?
Svetllana [295]
Is this an educational question
4 0
3 years ago
Other questions:
  • When did the first usb flash drive appear on the retail market? Which company developed this storage medium?
    14·1 answer
  • Which of the following was a major economic concern in the mid to late 1970
    8·2 answers
  • Nikolas has a idea that he could use the compressed carbon dioxide in a fire extinguisher to propel him on his skateboard. Nikol
    13·2 answers
  • Given the following method static void nPrint(String message, int n) { while (n &gt; 0) { System.out.print(message); n--; } } Wh
    12·1 answer
  • What determines gravitational pull?<br><br> volume<br><br> mass<br><br> the sun<br><br> acceleration
    9·2 answers
  • An airline has found about 7% of its passengers request vegetarian meals. On a flight with 166 passengers the airline has 16 veg
    11·1 answer
  • When entering data in Access if the data is entered using an Access form, that data is stored in a table or tables. TRUE FALSE
    12·1 answer
  • Please help and answerr
    8·1 answer
  • Hiiiiiiiiiiiiiiiiii <br>i'm new here!!!​
    14·2 answers
  • Please tell fast plzzzzzz.​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!