Question: Computing the exponent of a number ( i . e . , nk ) can take O ( n ) time if done by simply

Computing the exponent of a number (i.e., nk) can take O(n) time if done by simply multiplying by n, k number of times. A logarithmic way for computing exponents is by using the idea of successive squaring. For instance, rather than computing n8 as: n * n * n * n * n * n * n * n, we can compute it by repeatedly squaring, beginning with n, computing n2, n4 and finally n8. In general, the algorithm would do the following:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!