As an application of the property that a a = 0 for any bit vector a,

Question:

As an application of the property that a " a = 0 for any bit vector a, consider the following program:

1 2 3 4 5 void inplace_swap (int *x, int *y) { *y = *x /* Step 1 */ /* Step 2 */ /* Step 3 */ } *y = *x ~ *y;

As the name implies, we claim that the effect of this procedure is to swap the values stored at the locations denoted by pointer variables x and y. Note that unlike the usual technique for swapping two values, we do not need a third location to temporarily store one value while we are moving the other. There is no performance advantage to this way of swapping; it is merely an intellectual amusement. Starting with values a and b in the locations pointed to by x and y, respectively, fill in the table that follows, giving the values stored at the two locations after each step of the procedure. Use the properties of ᵔ to show that the desired effect is achieved. Recall that every element is its own additive inverse (that is, a ᵔ a = 0).

Step Initially Step 1 Step 2 Step 3 *X a *y b

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question

Computer Systems A Programmers Perspective

ISBN: 9781292101767

3rd Global Edition

Authors: Randal E. Bryant, David R. O'Hallaron

Question Posted: