Question: 8. In class we discussed a recursive algorithm, Pow2(n), to compute 2 for nonnegative integer n. The algorithm runs in O(n) time. By using the

8. In class we discussed a recursive algorithm, Pow2(n), to compute 2" for nonnegative integer n. The algorithm runs in O(n) time. By using the following recurrence relation, it is possible to develop an algorithm with better running time. 2 = 1. 2n = (21/2)*(21/2), when n > 0 and is even 2n = (2n/2)*(21/2)*2, when n > 0 and is odd (The divisions above are integer divisions). Write an algorithm in pseudo code to compute 2" for nonnegative integer n. The algorithm should have time complexity Odlog n). (12 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
