Consider the following very strange algorithm: Algorithm 2 VERY STRANGE ALGORITHM Require: Integer n 1: S+0 2: for i 1..
Posted: Tue May 24, 2022 8:45 am
Consider the following very strange algorithm: Algorithm 2 VERY STRANGE ALGORITHM Require: Integer n 1: S+0 2: for i 1... ndo 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. • X: • Y: 2: