Analysis of recursive algorithm. Consider the pseudocode of thefollowing three algorithms for computing 2n, where n is anon-negative integer.
Alg1 (n)
if (n == 0) return 1;
return 2 * Alg1(n – 1);
end
Alg2 (n)
if (n == 0) return 1;
return Alg2(n – 1) + Alg2(n – 1);
end
Alg3 (n)
if (n == 0) return 1;
m = floor (n / 2);
p = Alg3(m);
p = p * p;
if (n % 2 == 1) // n is an odd number
return 2 * p;
else // n is an even number;
return p;
end
end
a. (6 points) Trace the three algorithms using two smallexamples (n = 2 and n = 3) to find out
PayPal Gateway not configured
PayPal Gateway not configured