subject

Last assignment, we had a function able to calculate the power by multiplying every time the base, which leads to the following oz function: declare fun power n m) if m-= 0 then 1 else n power n m-1) end end for example, (power 2 8) returns 256 after 8 recursive calls.
the complexity of this function is o(m), since there are m recursive calls, each responsible for one multiplication operation.

write a more efficient version of power, by reusing the intermediate results.

for example, the previous computation may be done using only 3 multiplications, namely 2-22, 2-(2) (2), 2(2 (2)

what will be the complexity of this efficient algorithm?

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 13:00
"in program arrays12.java a swap method is called. does the swap method exchange parameter values x and y? "
Answers: 3
question
Computers and Technology, 21.06.2019 23:30
You picked the corridor which led you here. if the guards find you, they're going to be really angry! what is the synonym of angry
Answers: 1
question
Computers and Technology, 23.06.2019 01:20
Me with this program in c++ ! computers represent color by combining sub-colors red, green, and blue (rgb). each sub-color's value can range from 0 to 255. thus (255, 0, 0) is bright red. (130, 0, 130) is a medium purple. (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (in other word, equal amounts of red, green, blue yield gray).given values for red, green, and blue, remove the gray part. ex: if the input is 130 50 130, the output is: 80 0 80. thus, find the smallest value, and then subtract it from all three values, thus removing the gray.
Answers: 3
question
Computers and Technology, 23.06.2019 06:10
The head restraint should be adjusted so that it reaches a.the top of your ears b.the base of your skull c.the top of the head
Answers: 1
You know the right answer?
Last assignment, we had a function able to calculate the power by multiplying every time the base, w...
Questions
question
Mathematics, 12.04.2021 17:00
question
Chemistry, 12.04.2021 17:00
question
Chemistry, 12.04.2021 17:00
question
Mathematics, 12.04.2021 17:00
Questions on the website: 13722360