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
True or false a mirrorless camera has a pentaprism
inessss [21]

Answer:

No the pentaprism or pentamirror are both optical viewfinder viewing systems and are not part of the mirrorless camera. Some thing the pentaprism actually operates better than the electronic viewfinder of mirrorless cameras.

Explanation:

7 0
3 years ago
Read 2 more answers
Are storage devices input devices
Nonamiya [84]

Answer:

Exphfbdplanation:

8 0
3 years ago
Which attributes are indicators that a website is reliable? Check all that apply is up to date explains sources of data is an ed
Ahat [919]

Answer:

1 - Is up to date

2 - explains sources of data

3 - is an educational website

6 - will not share personal information

7 - has articles written by experts

7 0
2 years ago
Ipv6 includes a native information security framework (ipsec) that provides both data and control packets. true false
Galina-37 [17]
<span>The statement that IPv6 includes a native information security framework (IPsec) that provides both data and control packets is false.
</span>IPSec is a mandatory component for IPv6, and is used to natively protect IPv6 data <span>as it is sent over the network,. and not control packets.
</span>The IPv6 IPSec is a set of Internet standards that uses cryptographic security services to provide confidentiality ,data origin authentication and data integrity<span>
</span>

5 0
3 years ago
If necessary, create a new project named Advanced19 Project, and save it in the Cpp8\Chap06 folder. Enter (or copy) the instruct
Digiron [165]

Answer:  If a customer orders more than four pizzas, the program should deduct 10% from the cost of the order. Modify the program appropriately, and then save, run, and test it.

4 0
3 years ago
Other questions:
  • How is it possible to find encyclopedias and reference texts on the internet
    11·2 answers
  • Select the correct answer from each drop-down menu.
    6·1 answer
  • An example of creative curating is when a:
    9·1 answer
  • What simple machine is most often used to lift the blinds on a window?
    8·2 answers
  • What type of waves in the electromagnetic spectrum has the Search for Extraterrestrial Intelligence (SETI) mostly analyzed in th
    15·1 answer
  • Which composer below was not part of the classical period? <br> A. Beethoven B. Bach<br> C. Mozart
    6·1 answer
  • 50 POINTS!!!!!!!!!!!<br><br> Give at least two examples of how the transport layer is used.
    13·2 answers
  • What is the main function of processing unit​
    5·2 answers
  • Which are the 2 main elements that’s make up computer architecture?
    6·2 answers
  • A Network Intrusion Detection System watches for potentially malicious traffic and _______ when it detects an attack.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!