Write a recursive function in pseudocode that computes the v

Write a recursive function in pseudocode that computes the value of the following recurrence relation:

H(n) =

Give descriptive preconditions and postconditions.

H(n) =

1 if n = 1
H(n 1) + 6n 6     if n > 1.

Solution

I think for this one because of the n-1, the possibility for n becomes smaller and smaller for the input into the recursive function H(n), eventually reaching 1 which satisfies condition n = 1; therefore 1 and so terminating the algorithm.

and For this one I assume it will be H(n) = H(n-1) + 6n-6, since every time you run it \'a\' is the input and adding every input together will give you the total.

now description about

When you invoke a function — or, all right, a method — you have a sense of what needs to be true when you invoke it, and what it guarantees to be true when it returns. For example, when you call a function oneMoreThan(val), you undertake to ensure that val is an integer, and the function undertakes to ensure that the value it returns is one more than the one you passed in. These two promises — the precondition and postcondition — constitute the contract of the function. So:

and also

Predcondition: 1,2,3, …
Postcondition: 3n^2-3n+1

function H( 1,2,3, … )
if 1 then
return 1
else
return 6 (n- 1 )+ H(n-1)

Write a recursive function in pseudocode that computes the value of the following recurrence relation: H(n) = Give descriptive preconditions and postconditions.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site