4. Prove the correctness of the following loop using the provided pre and post conditions, and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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? 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?
Expert Answer:
Answer rating: 100% (QA)
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 ... View the full answer
Related Book For
Numerical Methods With Chemical Engineering Applications
ISBN: 9781107135116
1st Edition
Authors: Kevin D. Dorfman, Prodromos Daoutidis
Posted Date:
Students also viewed these programming questions
-
What is the spring cloud API Gateway and how do you set it up to make a call to the product service via eureka service discovery server? Give me the complete code in detailed steps.
-
Design a controller to stabilize the system G(S) = with feedback H(S) +371
-
You have been asked to manage a $3 million university endowment fund, which is used to fund the additional salary stipend for 5 endowed chair positions. The stipend for each chair is $30,000 (for a...
-
Find Vo in the circuit shown using source transformation ImA Io
-
Find the x-intercepts of the given function. y = 3x 2 + 10x + 3
-
A spaceship flies past an experimenter who measures its length to be one-half the length he had measured when the spaceship was at rest. An astronaut aboard the spaceship notes that his clock ticks...
-
A (lightweight) pallet has a load of identical cases of tomato paste (See Fig. 7.40), each of which is a cube of length l. Find the center of gravity in the horizontal plane, so that the crane...
-
Lancer, Inc. has 100,000 shares of common stock outstanding on January 1 and issues another 50,000 shares on October 1. The weighted-average number of shares outstanding for the calendar year would...
-
Given two arrays each of length n, arr1, and arr2, in one operation, any two elements of an array can be swapped. This can occur any number of times. Find the maximum possible sum of i*(arr2[1]-...
-
Below are different networking tools, your job is to describe each and the roles they play. Crimper Cable stripper Wi-Fi analyzer Toner probe Punch down tool Cable tester Loopback plug Network tap...
-
A 2 . 0 - kg mass is attached to a spring with a spring constant of 8 0 0 N / m and oscillates with an amplitude of 5 0 cm . What is the ratio of the potential energy to the total energy when the...
-
How has the operational relationship between the U.S. intelligence community and the homeland security enterprise evolved in the past eight years?What do you believe are the biggest gaps in...
-
A financial analyst forecasts two equally likely scenarios for the economic state in the next month: Economic state Return of stock B 16% Boom Normal How much is the standard deviation of the returns...
-
Conflict management style and answer the following questions in a one or two page paper: 1. Do think it accurately reflects you? 2. How can you improve your low score?
-
Scenario : You are the Vice President (VP) of operations in a business. It has come to your attention that a policy or a procedure change is required. Your audience for the memo is employees. It is...
-
Kellogg is the original plant-based food company offering an unmatched portfolio of favorite foods to drive holistic wellbeing and also a company dedicated to feeding hungry children, protecting our...
-
A horizontal annulus with inside and outside diameters of 8 and 10 cm, respectively, contains liquid water. The inside and outside surfaces are maintained at 40 and 20oC, respectively. Calculate the...
-
Simplify Eq. (8.2.32) for evenly spaced data. f[x2, x1, xo]: = [f(x) - f(x) X2 - X1 2]: f(x)-f(xo) X1 - XO 1 X2 - XO (8.2.32)
-
Compute the third divided difference using the recursion relationship Eq. (8.2.28). f[xn, xn-1,...,x, xo] = = f[xn, xn-1,...,x2, X] - f[xn-1,..., X1, Xo] Xn - XO (8.2.28)
-
Consider a system of equations with a steady state Jacobian of where a is some rational number. For what values of a is the steady state a saddle point? J 13 - [18] a 0
-
Nestls financial statements are presented in Appendix B. Financial statements of Delfi Limited are presented in Appendix C. Instructions Refer to the financial statements and answer the following...
-
Writing Financial statement information about four different companies is as follows. Instructions a. Determine the missing amounts. (Hint: For example, to solve for (a), Assets Liabilities = Equity...
-
The financial statements of TSMC are presented in Appendix A. The complete annual report, including the notes to the financial statements, is available at the companys website. Instructions Refer to...
Study smarter with the SolutionInn App