Machine-translated by Google. Questions are authored in English.
Top

Discussion

Consider the following code segment :

x = u - t;
y = x * v;
x = y + w;
y = t - z;
y = x * y;

The minimum number of total variables required to convert the above code segment to static single assignment form is

  • A.6
  • B.8
  • C.9
  • D.10

Answer: D

The minimum number of variables is 10.

In static single assignment form every assignment creates a new variable:

\[ \begin{aligned} x_{1} &= u - t \\ y_{1} &= x_{1} \times v \\ x_{2} &= y_{1} + w \\ y_{2} &= t - z \\ y_{3} &= x_{2} \times y_{2} \end{aligned} \]

That gives five new variables (\(x_{1}, x_{2}, y_{1}, y_{2}, y_{3}\)) plus the five that are only read (u, t, v, w, z): 10 in all. 6, 8 and 9 reuse a name for two assignments or leave out some of the inputs.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.