Page 1 of 1

Question #3 (20 points) Consider the following code fragment: 1 2 X 3 Do-Math(x, y) result z = 0 while z
Posted: Mon May 09, 2022 7:15 am
by answerhappygod
Question 3 20 Points Consider The Following Code Fragment 1 2 X 3 Do Math X Y Result Z 0 While Z Y Z Z 1 Re 1
Question 3 20 Points Consider The Following Code Fragment 1 2 X 3 Do Math X Y Result Z 0 While Z Y Z Z 1 Re 1 (62.94 KiB) Viewed 21 times
Question #3 (20 points) Consider the following code fragment: 1 2 X 3 Do-Math(x, y) result z = 0 while z <y z = z + 1 result = result / 2 return result 5 6 = 7 Provide clear, concise answers to each of the following related questions. • (3 points). What does Do-Math(32,4) return? • (12 points). Argue the correctness of the following loop invariant for Do-Math(): result = x/22 Be sure to argue both the initial condition and the maintenance condition. • (5 points). Using the invariant, prove the correctness of Do-Math(). Don't forget to use the loop test condition.