Question: [ 4 marks ] Assume that the function pow 2 ( int a , int k ) has the specification ( pre , post )

[4 marks] Assume that the function pow2(int a, int k) has the specification (pre, post), returns (:a2k} and that this function has been proved fully correct.
Using induction, prove that the following recursively defined function is fully correct.
// pre: )>(1)(0)(1
int mySum(int k)
if )==(1
return M
else
return mySum (k-1)+M**pow2(a,k-1)
// post: returns M**a2k-1a**a-1
 [4 marks] Assume that the function pow2(int a, int k) has

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!