
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

(a) int f(int n) { int i; sum = 0; for (i=0; i<n; i=i+2) sum++; return sum; } (b) int g(int n) { int i; sum = 0; for (i=0; i<n; i=i+1) sum += f(n); // function f from part a return sum; } (c) int h(int n) { for (i=1; i<n; i=i*2) sum += f(n); // function f from part a return sum; }
(a) int recursive1(int n) { if (n <= 1) return 1; else return recursive1(n-2) + recursive1(n-2); } (b) int recursive2(int n) { if (n <= 1) return 1; else return 2 * recursive2(n-2); }