Question: 1. (15) Suppose input is a function which returns a user-specified positive integer. For each of the following problems, do the following tasks: Determine if


1. (15) Suppose input is a function which returns a user-specified positive integer. For each of the following problems, do the following tasks: Determine if the following program halts for all possible sequences of (valid) inputs. Either provide a proof of termination for all possible sequences of (valid) inputs or provide a sequence which causes the program to loop. If the program does not halt, explain why the potential method does not apply. 4: 1: x + input() 2: yt input() 3: while x > 0 and y> 0 do zt input() (a) 5: if z is even then 6: x + x - 2 7: y + y + 5 else 9: yty - 1 8: 1: x + input() 2: yt input() 3: while x > 0 and y> 0 do 4: zt input() b) 5: if z is even then 6: Er - 2 7: y + y + 3 8: else 9: ye y 3 10: x + x + 2 This line differs from the program in (a) (c) 1: x + input() 2: yt input() 3: while x > 0 or y > 0 do 4: zt input() 5: if z is even then 6: X + X 2 7: yty +3 8: else 9: yty - 1 1. (15) Suppose input is a function which returns a user-specified positive integer. For each of the following problems, do the following tasks: Determine if the following program halts for all possible sequences of (valid) inputs. Either provide a proof of termination for all possible sequences of (valid) inputs or provide a sequence which causes the program to loop. If the program does not halt, explain why the potential method does not apply. 4: 1: x + input() 2: yt input() 3: while x > 0 and y> 0 do zt input() (a) 5: if z is even then 6: x + x - 2 7: y + y + 5 else 9: yty - 1 8: 1: x + input() 2: yt input() 3: while x > 0 and y> 0 do 4: zt input() b) 5: if z is even then 6: Er - 2 7: y + y + 3 8: else 9: ye y 3 10: x + x + 2 This line differs from the program in (a) (c) 1: x + input() 2: yt input() 3: while x > 0 or y > 0 do 4: zt input() 5: if z is even then 6: X + X 2 7: yty +3 8: else 9: yty - 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
