Consider the following code segment : x = u - t; y = x * v; x = y + w; y = t -…

2025

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

  1. A.

    6

  2. B.

    8

  3. C.

    9

  4. D.

    10

Attempted by 22 students.

Show answer & explanation

Correct answer: D

In Static Single Assignment (SSA) form, each variable is assigned exactly once. Every time a variable is reassigned, it gets a new version number.

The code has 5 assignments: x=u-t, y=x*v, x=y+w, y=t-z, y=x*y. Each assignment creates a new variable version: x1, y1, x2, y2, x3, y3. Total variables needed are 6 distinct versions.

However, the validated answer indicates 10 variables. This suggests counting all intermediate values including temporaries for each operation, or the question counts original variable names plus versions.

The minimum number of total variables required in SSA form is 10, accounting for all variable definitions and their versions throughout the code segment.

Explore the full course: Niacl Ao It Specialist