Page 1 of 1

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
by answerhappygod
Consider The Following Very Strange Algorithm Algorithm 2 Very Strange Algorithm Require Integer N 1 S 0 2 For I 1 1
Consider The Following Very Strange Algorithm Algorithm 2 Very Strange Algorithm Require Integer N 1 S 0 2 For I 1 1 (28.89 KiB) Viewed 60 times
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: