b Compute the n th power of a number xx with n nonnegalive i

b) Compute the n th power of a number x,x with n non-negalive integcr. The alaorithm should be designed in such wau that M is possible to write a recurren relation for the total number of multiplicat cas by the alaorithm for which the moster theorem apoils. r Hl such a recurren and apply the master thorom to aban an asymp bound for int Tower int x, int n) if ins. O) raturn Li return X tower (x, n-);

Solution

step1: start

step 2: input number n

step 3: call power(n) function

step 4: print power p.

step 5: end.

power(n)

step1: if n==0 then return 1

step2: else

p=x*power(x,n-1).

step3: return p

 b) Compute the n th power of a number x,x with n non-negalive integcr. The alaorithm should be designed in such wau that M is possible to write a recurren rela

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site