Page 1 of 1

Question 8 Question 1h Consider the following very strange algorithm: Algorithm 2 VERY STRANGE ALGORITHM Require: Intege

Posted: Tue May 24, 2022 8:28 am
by answerhappygod
Question 8 Question 1h Consider The Following Very Strange Algorithm Algorithm 2 Very Strange Algorithm Require Intege 1
Question 8 Question 1h Consider The Following Very Strange Algorithm Algorithm 2 Very Strange Algorithm Require Intege 1 (50.58 KiB) Viewed 14 times
Question 8 Question 1h Consider the following very strange algorithm: Algorithm 2 VERY STRANGE ALGORITHM Require: Integer n 1: S+0 2: for i 1... n do 3: S+S+2-2-1 4: end for 5: return S What are the correct values for X, Y and Z in order to obtain a correct loop invariant: At the beginning of iteration; (i.e.. after; is updated in Line 2 and before the code in Line 3 is executed) the following property holds: S-X-2 +2^(1-2) Hint: recall that Σ2² =2²+1 -1. • X: • Y: • Z:

0 - - - - - & i+1 i+2