Menu

(Solved) : 8 Iterative Algorithm Understanding 13 Points Mysteryly Z Positive Integer 1x 0 2 Z 0 3 Z Q44155916 . . .

8. Iterative algorithm understanding (13 points) Mysteryly, z: positive integer) 1x=0 2 while z>0 3 if z mod 2 ==1 then 4 x=

8. Iterative algorithm understanding (13 points) Mysteryly, z: positive integer) 1x=0 2 while z>0 3 if z mod 2 ==1 then 4 x= x+y y = 2y 6 z = floor(2/2) //floor is the rounding down operation 7 return x Simulate this algorithm for y=4 and z=7 and answer the following questions: (3 points) At the end of the first execution of the while loop, x=_ v=__ and z= __ (3 points) At the end of the second execution of the while loop, x=_ Y_ and Z=- (3 points) At the end of the third execution of the while loop, x= y= and za (2 points) Value returned by the algorithm = (2 points) What does this algorithm compute? Show transcribed image text 8. Iterative algorithm understanding (13 points) Mysteryly, z: positive integer) 1x=0 2 while z>0 3 if z mod 2 ==1 then 4 x= x+y y = 2y 6 z = floor(2/2) //floor is the rounding down operation 7 return x Simulate this algorithm for y=4 and z=7 and answer the following questions: (3 points) At the end of the first execution of the while loop, x=_ v=__ and z= __ (3 points) At the end of the second execution of the while loop, x=_ Y_ and Z=- (3 points) At the end of the third execution of the while loop, x= y= and za (2 points) Value returned by the algorithm = (2 points) What does this algorithm compute?

Expert Answer


Answer to 8. Iterative algorithm understanding (13 points) Mysteryly, z: positive integer) 1x=0 2 while z>0 3 if z mod 2 ==1 then …

OR