1. (a) Consider the following algorithm: Input: A number k 20 OUutput: ?? X +0 Y 1 while x k do X +x+1 Y EY * X return Y i. Give the output of this algorithm in terms of the input. ii. Write a loop...



please send answer for part a iii and iv


1. (a) Consider the following algorithm:<br>Input: A number k 20<br>OUutput: ??<br>X +0<br>Y 1<br>while x k do<br>X +x+1<br>Y EY * X<br>return Y<br>i. Give the output of this algorithm in terms of the input.<br>ii. Write a loop invariant for this algorithm.<br>iii. State and use the While-loop invariance theorem to prove that this algorithm<br>is correct with respect to the output you gave in Part i.<br>iv. Rewrite the algorithm using a For-loop rather than a While-loop.<br>(b) Derive the following judgement using natural deduction:<br>A implies (B and C), B implies D, C implies EH A implies (D andE)<br>State clearly all the rules that you use in your derivation.<br>

Extracted text: 1. (a) Consider the following algorithm: Input: A number k 20 OUutput: ?? X +0 Y 1 while x k do X +x+1 Y EY * X return Y i. Give the output of this algorithm in terms of the input. ii. Write a loop invariant for this algorithm. iii. State and use the While-loop invariance theorem to prove that this algorithm is correct with respect to the output you gave in Part i. iv. Rewrite the algorithm using a For-loop rather than a While-loop. (b) Derive the following judgement using natural deduction: A implies (B and C), B implies D, C implies EH A implies (D andE) State clearly all the rules that you use in your derivation.

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here