Course Solutions Uncategorized (Solved) : Consider Following Iterative Function Int Pentagonal Int N Int Result 0 Int 1 Target Retur Q30689739 . . . .

(Solved) : Consider Following Iterative Function Int Pentagonal Int N Int Result 0 Int 1 Target Retur Q30689739 . . . .

 

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

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post