Menu

(Solved) : 6 8 Marks Consider Sequence Ro X1 Defined Xo 0 X1 1 Xi X 1 2 2 Consider Following Algorit Q44112830 . . .

6. 8 marks) Consider the sequence ro, x1,... defined by xo = 0, x1 = 1, and xi = x;-1+ i-2 for all i > 2. Consider the follow

6. 8 marks) Consider the sequence ro, x1,… defined by xo = 0, x1 = 1, and xi = x;-1+ i-2 for all i > 2. Consider the following algorithm that attempts to compute the value xn, given an n > 0. Algorithm 6 1: //pre: (n e Z) ^ (n > 0) 2: if n == 0 then 3: 4: else 5: 6: 7: //LoopInv: 8: while i <n do 9: c + a+b 10: 11: 12: i ti+1 13: end while 14: 15: end if 16: //post: b== xn Prove that Algorithm 6 satisfics the Partial Correctness property. You will need to provide (and prove) your own loop invariant LoopInv for line 8. Show transcribed image text 6. 8 marks) Consider the sequence ro, x1,… defined by xo = 0, x1 = 1, and xi = x;-1+ i-2 for all i > 2. Consider the following algorithm that attempts to compute the value xn, given an n > 0. Algorithm 6 1: //pre: (n e Z) ^ (n > 0) 2: if n == 0 then 3: 4: else 5: 6: 7: //LoopInv: 8: while i

Expert Answer


Answer to 6. 8 marks) Consider the sequence ro, x1,… defined by xo = 0, x1 = 1, and xi = x;-1+ i-2 for all i > 2. Consider the f…

OR