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
In java 1. Write a recursive algorithm to add all the elements of an array of...
In java 1. Write a recursive algorithm to add all the elements of an array of n elements 2. Write a recursive algorithm to get the minimum element of an array of n elements 3. Write a recursive algorithm to add the corresponding elements of two arrays (A and B) of n elements. Store the results in a third array C. 4. Write a recursive algorithm to get the maximum element of a binary tree 5. Write a recursive algorithm...
Write a Recursive Function Algorithm to find the terms of following recurrence relation. t(1)=3 t(k)=2×t(k-1)-5 (n>1)....
Write a Recursive Function Algorithm to find the terms of following recurrence relation. t(1)=3 t(k)=2×t(k-1)-5 (n>1). and (ii) If you call z←t(4) in a program then what value the program will use for z?   
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...
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.
Suppose a parameter family has parameter q = E(X3), where is q is real. Devise an...
Suppose a parameter family has parameter q = E(X3), where is q is real. Devise an estimator of q (hint: use the “Golden Rule” estimation) and show it is unbiased and consistent for q.
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
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT