Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

62 .. Given the. ecursive fünction definition a( n) s x a( n-1)6x a n-2) ao a a

ID: 3703637 • Letter: 6

Question

62 .. Given the. ecursive fünction definition a( n) s x a( n-1)6x a n-2) ao a a evaluate a(3) b. write the source code to impleme , c. . ve nt this function. rity for n 3 that the following is an explicit formula for a( n): a( n) 3 x 2 3 2. Given the recursive function definition: g(n-1), g( 0 ) g(1) 1 g( n ) = . 10 25 * g(n-2 ) 2 * - , a. evaluate (3) b write the source code to implement this function. verify ..for:" ", 3. th?t the following is an explic, formula for gn): ..: .?., 3 , G?ven.the. recursive. function definition:- (o) 2 (17 t(n) n t+ 3t(n1) + t(n-2) a. evaluate: t(3 write. the source code to. implement, this function

Explanation / Answer

/* Following is the program that evaluated the output

*/

#include <iostream>
using namespace std;

int a(int n)
{
if(n==0)
return 4;
if(n==1)
return 9;
return (5*a(n-1))-(6*a(n-2));
}

int g(int n)
{
if(n==0)
return 2;
if(n==1)
return 1;
return (10*g(n-1))-(25*g(n-2));
}

int t(int n)
{
if(n==0)
return 2;
if(n==1)
return 1;
return n+(3*t(n-1))+(t(n-2));
}

int main() {
cout << "a(3) = " << a(3) << endl;
cout << "g(3) = " << g(3) << endl;
cout << "t(3) = " << t(3) << endl;
}

/* Following is the program that evaluated the output

  a(3) = 51  g(3) = -425  t(3) = 25

*/

#include <iostream>
using namespace std;

int a(int n)
{
if(n==0)
return 4;
if(n==1)
return 9;
return (5*a(n-1))-(6*a(n-2));
}

int g(int n)
{
if(n==0)
return 2;
if(n==1)
return 1;
return (10*g(n-1))-(25*g(n-2));
}

int t(int n)
{
if(n==0)
return 2;
if(n==1)
return 1;
return n+(3*t(n-1))+(t(n-2));
}

int main() {
cout << "a(3) = " << a(3) << endl;
cout << "g(3) = " << g(3) << endl;
cout << "t(3) = " << t(3) << endl;
}