Question

A program devise a recursive algorithm to find a2n, where a is a real number and...

A program devise a recursive algorithm to find a2n, where a is a real number and n is a positive integer (hint: use the equality a2n+1 = (a^2n)^2

Homework Answers

Answer #1

In this question, we have to find the recursive algorithm to find a2^n, where a is a real number and n is a positive integer.

Also we know the equality that a2^n+1 = (a2^n)2.

This implies that a2^n+1 = (a2^n)2 = a2 . a2^n , for n>0.

For initial condition i.e n=0 , a2^1 = a2 = a*a . So to find recursive algorithm for a2^n, successively reduce it by using the recursive step .

The recursive algorithm to find a2^n is given below :

procedure power (a:real number, n:positive number)

if(n=1) then power(a,n) = a*a

else pow=power(a,n-1)

power(a,n) = pow * pow

If you have any doubt or query, then let me know in comment. If it helps, kindly give an upVote to this answer.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Foundation of computer science Let x be a real number, and n be an integer. 1....
Foundation of computer science Let x be a real number, and n be an integer. 1. Devise an algorithm that computes x n . [Hint: First, give a procedure for computing x n when n is nonnegative by successive multiplication by x, starting with 1 until we reach n. Then, extend this procedure and use the fact that x -n = 1/x n to compute x n when n is negative.] 2. Write its corresponding program using your favorite programming...
a. Design a non-recursive algorithm for computing an (discussed in the class). What is the basic...
a. Design a non-recursive algorithm for computing an (discussed in the class). What is the basic operation? How many times is the algorithm’s basic operation executed? b. Using an = a*an-1 (discussed in the class) to design a recursive algorithm for computing an . What is the basic operation? Set up and solve a recurrence relation for the number of times that algorithm's basic operation is executed. c. Using an = a*(a(n-1)/2) 2 (n is odd integer) and an =...
Consider the following recursive algorithm for computing the sum of the first ? cubes: ? (?)...
Consider the following recursive algorithm for computing the sum of the first ? cubes: ? (?) = 13 + 23 + ⋯+ ? 3 . Algorithm S(n) //Input: A positive integer n //Output: The sum of the first n cubes if n = 1 return 1 else return S(n-1) + n * n * n
a) Give a recursive algorithm for finding the max of a finite set of integers, making...
a) Give a recursive algorithm for finding the max of a finite set of integers, making use of the fact that the max of n integers is the larger of the last integer in the list and the max of the first n-1 integers in the list. Procedure power(x,n): If (n=0): return 1 Else: return power(x,n-1) · x b) Use induction to prove your algorithm is correct
Consider the following recursive algorithm. Algorithm Mystery(n) if n=1 then Execute Task A; // Requires Θ(1)...
Consider the following recursive algorithm. Algorithm Mystery(n) if n=1 then Execute Task A; // Requires Θ(1) operations else Mystery(n/3); Mystery(n/3); Mystery(n/3); Execute Task B;  //Requires 2n operations end if Let C(n) be the complexity of Mystery(n). Use the method of backward substitution to determine C(n) in three steps. a) Write the recurrence relation for C(n) including the initial condition. b) Write at least two substitution steps for C(n) and identify the pattern. c) Determine the complexity class of the algorithm in...
Consider the following recursive algorithm. Algorithm Test (T[0..n − 1]) //Input: An array T[0..n − 1]...
Consider the following recursive algorithm. Algorithm Test (T[0..n − 1]) //Input: An array T[0..n − 1] of real numbers if n = 1 return T[0] else temp ← Test (T[0..n − 2]) if temp ≥ T[n − 1] return temp else return T[n − 1] a. What does this algorithm compute? b. Set up a recurrence relation for the algorithm’s basic operation count and solve it.
Consider the following recursive equation s(2n) = 2s(n) + 3; where n = 1, 2, 4,...
Consider the following recursive equation s(2n) = 2s(n) + 3; where n = 1, 2, 4, 8, 16, ... s(1) = 1 a. Calculate recursively s(8) b. Find an explicit formula for s(n) c. Use the formula of part b to calculate s(1), s(2), s(4), and s(8) d Use the formula of part b to prove the recurrence equation s(2n) = 2s(n) + 3
Use a recurrence relation to approximate the number of comparisons done by the recursive FindMax function(Algorithm...
Use a recurrence relation to approximate the number of comparisons done by the recursive FindMax function(Algorithm 5.10)
Give a recursive algorithm to solve the following recursive function.    f(0) = 0;    f(1)...
Give a recursive algorithm to solve the following recursive function.    f(0) = 0;    f(1) = 1; f(2) = 4; f(n) = 2 f(n-1) - f(n-2) + 2; n > 2 Solve f(n) as a function of n using the methodology used in class for Homogenous Equations. Must solve for the constants as well as the initial conditions are given.
1. Suppose a parameter family has parameter q = E (X^3), where q is real. Devise...
1. Suppose a parameter family has parameter q = E (X^3), where q is real. Devise an estimator of q (hint: use the “Golden Rule”) and show it is unbiased and consistent for q.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT