Computers and Technology
Computers and Technology, 27.11.2019 00:31, shawn4544

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?

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 12:00, xojade
Which of these is an example of an integrated presentation? a. a table created in powerpoint b. an image pasted into powerpoint c. a caption created in powerpoint d. an excel chart pasted into powerpoint
Answers: 1
image
Computers and Technology, 24.06.2019 00:50, anthonycraig0205
3. what is the output of the following statements? temporary object1; temporary object2("rectangle", 8.5, 5); temporary object3("circle", 6, 0); temporary object4("cylinder", 6, 3.5); cout < < fixed < < showpoint < < setprecision(2); object1.print(); object2.print(); object3.print(); object4.print(); object1.set("sphere", 4.5, 0); object1.print();
Answers: 1
image
Computers and Technology, 24.06.2019 10:30, johngayden46
This device directs network traffic. bridge hub nic repeater router switch
Answers: 3
image
Computers and Technology, 24.06.2019 16:00, kamo90
How are roger williams, james oglethorpe, and william penn similar?
Answers: 3
Do you know the correct answer?
Last assignment, we had a function able to calculate the power by multiplying every time the base, w...

Questions in other subjects:

Konu
Biology, 29.10.2020 21:50
Konu
Mathematics, 29.10.2020 21:50