Question: Below are the pseudo codes of 3 algorithms. Alg 1 ( n ) : if n = 0 return 1 else return 2 * Alg

Below are the pseudo codes of 3 algorithms.
Alg1(n):
if n =0
return 1
else
return 2*Alg1(n-1)
end
Alg2(n):
if n =0
return 1
else
return Alg2(n-1)+ Alg2(n-1)
end
Alg3(n):
if n =0
return 1
else
m=[n/2]
p= Alg3(m)
p=p*p
if n is odd
return 2*p
else
return p
end
end
a) What does each algorithm compute?
b) What is the running time of each algorithm.

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 Programming Questions!