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
Does the estimate of a tolerance level of 68.26% of all patient waiting times provide evidence that at least two-thirds of all p
ivanzaharov [21]

Answer:

Yes, because the upper limit is less Than 8 minutes

Explanation:

According to the empirical formula :

68.26% of data lies within 1 standard deviation from the mean;

Hence,

Mean ± 1(standard deviation)

The sample mean and sample standard deviation of the given data is :

Sample mean, xbar = Σx / n = 546 / 100 = 5.46

Sample standard deviation, s = 2.475 (Calculator)

The interval which lies within 68.26% (1 standard deviation is) ;

Lower = (5.460 - 2.475) = 2.985

Upper = (5.460 + 2.475) = 7.935

(2.985 ; 7.935)

Since the interval falls within ; (2.985 ; 7.935) whose upper level is less than 8 means patients will have to wait less Than 8 minutes.

8 0
3 years ago
Why dose this keep popping up will give brainlest for first person answer
torisob [31]
What happens when you click answer questions? If nothing happens, exit out or restart, it’s a glitch.
6 0
3 years ago
What's the code?
lys-0071 [83]

Answer:

Explanation:

#include <iostream>

using namespace std;

// Recipe of single portion salad

int main()

{

   float Qing[3]={0.0,0.0,0.0};

   string ItemName[3]={" "," "," "};

   int qty=0;

   cout<<"Please enter 3 Ingredients required for Salad and Quantity required for a single serve"<<endl;

   for (int i=0;i<3;i++)

   {

       cout<<"Enter the ingredient number "<<(i+1)<<" :";

       cin>>ItemName[i];

       cout<<"Qty required for single serve (in Oz) :";

       cin>>Qing[i];

   }

   cout<<"Number of servings required :";

   cin>>qty;

   cout<<endl<<"Total Quantities required for "<<qty<<" servings"<<endl;

   for (int i=0;i<3;i++)

   {

       cout<<ItemName[i]<<" Qty for "<<qty<<" servings :"<<(Qing[i]*qty)<<" Oz."<<endl;

   }

   return 0;

}

// You can run this after compiling without any problem.

3 0
3 years ago
Select the best answer for the question. 2. What is the simplest way to permanently get rid of an unwanted file?
Kobotan [32]
To permanetly get rid of an unwanted file, you delete it
3 0
3 years ago
John’s grandparents make wine for special occasions. They add a pinch of yeast to crushed grapes. Over time, this action release
luda_lava [24]
The answer is 1. A<span>lcoholic Fermentation

Hope that helped :)</span>
4 0
3 years ago
Read 2 more answers
Other questions:
  • What type of network does not have centralized control, such as one in a small office or home office?
    5·1 answer
  • Blogs are typically written by large companies or organizations as a way to express formal, technical, or scholarly information
    5·2 answers
  • Which of the following statements is true of intrapreneurs
    15·1 answer
  • A typist is entering text on keyboard at the rate of 30 words per minute. if each word is 6 characters long on average, what ban
    5·2 answers
  • What is an activity that can help you enhance the appearance of your computer’s desktop?
    13·1 answer
  • All of the following are reserved keywords in C++ EXCEPT
    5·1 answer
  • Which of the following information would best be displayed throughout the use of a time line
    11·1 answer
  • Write program to read 10 random numbers, then find how many of them accept division by 4,
    6·1 answer
  • 5. Nadia wants to calculate the total interest, which is the total amount of the payments minus the loan amount. In cell F6, ent
    8·1 answer
  • Thirty percent of a magazine's subscribers are female. A random sample of 50 subscribers Answer the following questions using Ex
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!