Question: The loop invariant is a statement that could be proven by induction to be true before and after each iteration of the loop. So, when

The loop invariant is a statement that could be proven by induction to be true before and after each iteration of the loop. So, when the loop terminates because p1 = 0, the loop invariant implies that the answer to the multiplication is in extra. Write a function in C that implements this pseudocode with the following header.
The modulus parameter will represent a polynomial of degree which will be less than 32. Parameters a and b will each represent polynomials with degree less than degree. Develop this pseudocode into a C function with the intended signature. Test it thoroughly by picking strategic inputs and comparing hand-calculated results with computer-generated results.
Let pi and p2 be elements of GF(2 n) (ie, polynomials of degree less than n) extra = 0 Loop invariant: answer to original multiplication- (p1) (p2)+extra while (p1 not o) if (pi has x0 term) p1 = p1 -X extra- extra + p2 p2 = p2 * x if (p2 has x"n term) p2 = p2 -Xn + (modulus's lower terms) Loop invariant: answer to original multiplication - (p1) (p2)+extra Let pi and p2 be elements of GF(2 n) (ie, polynomials of degree less than n) extra = 0 Loop invariant: answer to original multiplication- (p1) (p2)+extra while (p1 not o) if (pi has x0 term) p1 = p1 -X extra- extra + p2 p2 = p2 * x if (p2 has x"n term) p2 = p2 -Xn + (modulus's lower terms) Loop invariant: answer to original multiplication - (p1) (p2)+extra
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
