Question 13 (4 marks) A code fragment FragQ13 is given below, where n is an integer and n ≥ 0. // FragQ13 var aSpot in S
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Question 13 (4 marks) A code fragment FragQ13 is given below, where n is an integer and n ≥ 0. // FragQ13 var aSpot in S
Question 13 (4 marks) A code fragment FragQ13 is given below, where n is an integer and n ≥ 0. // FragQ13 var aSpot in Spot var i in Int aSpot.leftOne () aSpot.leftOne () aSpot.upOne () for (i <-- 1 to n). { aSpot.upOne () aSpot.upOne () aSpot.rightOne() Let aSpot be the state of the variable aSpot after k executions of the body of the for loop in Frag013 (where k≥ 0 is an integer). Let p(k) be the following proposition. p(k): aSpot, is (k-2, 2k + 1). Explain why the proposition p(0) is true. (Note: You are asked only to explain why p(0) is true, not p(k) for a general integer k.)