edited by
27,256 views
69 votes
69 votes

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 __________.

edited by

12 Answers

11 votes
11 votes
t0 = u - t;

t1 = to * v;

t2 = t1 + w;

t3 = t - z;

t4 = t2 * t3;

Total variables required will be 5(t, u, v, w, z) + 5(temp. variables) = 10
edited by
9 votes
9 votes
ans. is 10

here every variable can be assigned with a value only once.

t1 =  t2 - t3

t4 = t1 * t5

t6 = t4 + t7

t8 = t2 - t9

t10 = t6 - t8
1 votes
1 votes
I got 6. Plz comment
0 votes
0 votes

well I might be totally wrong..but here's what I did ..

the expression was (t-z)((u-t)*v+w)

each var can be on left side only once

u=u-t

v=u*v

w=v+w

t=t-z

ans=w*t

so total 6 var.

i didnt get the total variable definition.I assumed it was referring to some variable which was both on left and right side..which are u,v,w,t

so I entered 4.

Answer:

Related questions

35 votes
35 votes
4 answers
1
Sandeep Singh asked Feb 12, 2016
10,023 views
The attribute of three arithmetic operators in some programming language are given below.$$\begin{array}{|c|l|}\hline \textbf{OPERATOR} & \textbf{PRECEDENCE} & \textbf{...
80 votes
80 votes
7 answers
2
makhdoom ghaya asked Feb 13, 2015
28,737 views
The least number of temporary variables required to create a three-address code in static single assignment form for the expression $q + r / 3 + s - t * 5 + u * v/w$ is_...