Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. Prove the correctness of the following loop using the provided pre and post conditions, and provided loop invariant. Require: A and B are

4. Prove the correctness of the following loop using the provided pre and post conditions, and provided loop

4. Prove the correctness of the following loop using the provided pre and post conditions, and provided loop invariant. Require: A and B are positive integers, x = A, y = B and p =0 1: while y # 0 do 2: 3: 4: 5: 6: 7: 8: 9: 10: end if 11: end while Ensure: p = A. B r = y mod 2 if r = 0 then x = 2.x y := ydiv 2 end if if r = 1 then p=p+x Ynew Yold 1 Loop invariant: I(n): x y+p= A.B What does this loop compute?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

To prove the correctness of the given loop with respect to the provided loop invariant and postcondition we need to show that 1 Initialization Before ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Numerical Methods With Chemical Engineering Applications

Authors: Kevin D. Dorfman, Prodromos Daoutidis

1st Edition

1107135117, 978-1107135116

More Books

Students also viewed these Programming questions

Question

What is a job description matrix?

Answered: 1 week ago

Question

4. How does a sex-linked gene differ from a sex-limited genepg105

Answered: 1 week ago

Question

6. How does an epigenetic change differ from a mutationpg105

Answered: 1 week ago