Consider the following iterative function:
int pentagonal(int n)
{
int result = 0;
for (int i = 1; i <= n; i++) result+= 3 * i – 2;
return result;
}
Rewrite the function pentagonal usingrecursion and add preconditions and postconditions as comments.Then prove by induction that the recursive function you wrote iscorrect.
Suppose the number of steps required in the worst case for twoalgorithms are as follows:
Algorithm 1: f(n) = 10n2 + 6
Algorithm 2: g(n) = 21n + 7
Determine at what point algorithm 2becomes more efficient than algorithm 1.
Given the following function that evaluates a polynomial whosecoefficients are stored
PayPal Gateway not configured
PayPal Gateway not configured