Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. Consider the following intermediate program in three address code
    P = a – b
    q = P * c
    P = u * v
    q = p + q
    Which one of the following corresponds to a static single assignment form of the above code?
    1. p1 = a – b
      q1 = p1 * c
      p1 = u * v
      q1 = p1 + q1
    2. p3 = a – b
      q4 = p3 * c
      p4 = u * v
      q5 = p4 + q4
    3. p1 = a – b
      q1 = p2 * c
      p3 = u * v
      q2 = p4 + q3
    4. p1 = a – b
      q1 = p * c
      p2 = u * v
      q2 = p + q
Correct Option: B

Consider all options.
1. In option (a), p1 and q1 are initialized twice or used again for temporary storage, which is not allowed under static single assignment.
2. In option (b), there is no initialization again of the variables and all the statement are correct.
3. In option (c), the second line statement is not correct. It should be q1 = p1 * C.
And P2, P4, q3 are not initialized anywhere.
4. In option (d), the second line statements is not correct. It should be q1 = P1 * C So, option (b) is correct.



Your comments will be displayed only after manual approval.