Page 1 of 1

Consider the following code fragment: 1 2 3 4 Do-Math(x, y) result = x Z=0 while z
Posted: Mon May 09, 2022 7:16 am
by answerhappygod
Consider The Following Code Fragment 1 2 3 4 Do Math X Y Result X Z 0 While Z Y Z 2 1 Result Result 2 Retu 1
Consider The Following Code Fragment 1 2 3 4 Do Math X Y Result X Z 0 While Z Y Z 2 1 Result Result 2 Retu 1 (25.55 KiB) Viewed 26 times
Consider the following code fragment: 1 2 3 4 Do-Math(x, y) result = x Z=0 while z <y z = 2 + 1 result = result / 2 return result 5 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 = 1/2- 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.