GATE 2015 (Session 1)
65 questions
MCQ 45 · NAT 201-mark 30 · 2-mark 35
Questions 46–50 of 65
A variable x is said to be live at a statement in a program if the following three conditions hold simultaneously:
i. There exists a statement that uses x
ii. There is a path from to in the flow graph corresponding to the program
iii. The path has no intervening assignment to x including at and
The variables which are live both at the statement in basic block 2 and at the statement in basic block 3 of the above control flow graph are
i. There exists a statement that uses x
ii. There is a path from to in the flow graph corresponding to the program
iii. The path has no intervening assignment to x including at and
The variables which are live both at the statement in basic block 2 and at the statement in basic block 3 of the above control flow graph are
Answer: (C)
For a block : , where holds the variables read in before any write, and is the union of of the successors.
Block 1 uses before defining them (, , are defined and then used inside the block). Block 1 is in a loop (4 1), so check that nothing more is added. Start with .
-
-
-
- , and , which is already inside . So no set changes and these values are final.
Live at both the statement in block 2 and the one in block 3: .
Answer: (C)
Block 1 uses before defining them (, , are defined and then used inside the block). Block 1 is in a loop (4 1), so check that nothing more is added. Start with .
-
-
-
- , and , which is already inside . So no set changes and these values are final.
Live at both the statement in block 2 and the one in block 3: .
Answer: (C)
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 _______________.
Answer: 8
In SSA, each result is stored in a new variable. Let us count the operations:
t1 = r / 3, t2 = q + t1, t3 = t2 + s, t4 = t * 5, t5 = t3 t4, t6 = u * v, t7 = t6 / w, t8 = t5 + t7
There are 8 operations so 8 temporaries are needed.
Answer: 8
t1 = r / 3, t2 = q + t1, t3 = t2 + s, t4 = t * 5, t5 = t3 t4, t6 = u * v, t7 = t6 / w, t8 = t5 + t7
There are 8 operations so 8 temporaries are needed.
Answer: 8
Consider an Entity-Relationship (ER) model in which entity sets E1 and E2 are connected by an m : n relationship R12. E1 and E3 are connected by a 1 : n (1 on the side of E1 and n on the side of E3) relationship R13.
E1 has two single-valued attributes a11 and a12 of which a11 is the key attribute. E2 has two single-valued attributes a21 and a22 of which a21 is the key attribute. E3 has two single-valued attributes a31 and a32 of which a31 is the key attribute. The relationships do not have any attributes.
If a relational model is derived from the above ER model, then the minimum number of relations that would be generated if all the relations are in 3NF is _______.
E1 has two single-valued attributes a11 and a12 of which a11 is the key attribute. E2 has two single-valued attributes a21 and a22 of which a21 is the key attribute. E3 has two single-valued attributes a31 and a32 of which a31 is the key attribute. The relationships do not have any attributes.
If a relational model is derived from the above ER model, then the minimum number of relations that would be generated if all the relations are in 3NF is _______.
Answer: 4
Go through each part of the model:
- E1(a11, a12) and E2(a21, a22): each entity set gives one relation.
- R12 is m:n, so it needs a relation of its own with (a11, a21).
- R13 is 1:n, so no separate table is needed. Put a11 in E3 as a foreign key: E3(a31, a32, a11).
Total = 4
Answer: 4
- E1(a11, a12) and E2(a21, a22): each entity set gives one relation.
- R12 is m:n, so it needs a relation of its own with (a11, a21).
- R13 is 1:n, so no separate table is needed. Put a11 in E3 as a foreign key: E3(a31, a32, a11).
Total = 4
Answer: 4
Consider the DFAs M and N given above. The number of states in a minimal DFA that accepts the language L(M) L(N) is___________
Answer: 1
Look at each DFA:
- M accepts the strings that end with a.
- N accepts the strings that end with b.
A string cannot end with both a and b, so . The minimal DFA has only one state, and that state is non-accepting.
Answer: 1
- M accepts the strings that end with a.
- N accepts the strings that end with b.
A string cannot end with both a and b, so . The minimal DFA has only one state, and that state is non-accepting.
Answer: 1
Consider the NPDA , where (as per usual convention) Q is the set of states, is the input alphabet, is the stack alphabet, is the state transition function, is the initial state, is the initial stack symbol, and is the set of accepting states. The state transition is as follows:
Which one of the following sequences must follow the string 101100 so that the overall string is accepted by the automaton?
Which one of the following sequences must follow the string 101100 so that the overall string is accepted by the automaton?
Answer: (B)
The automaton works in three phases. In the first state it pushes each input symbol on the stack. It then moves to the middle state, either on or by reading one symbol (an optional middle symbol) without changing the stack. In the middle state, reading pops a and reading pops a . When only is left, an move goes to the final state. So the input must be , where is or one symbol and is the reverse of with every bit complemented.
The total length is , which is odd, so there is a middle symbol: and . So (the first five symbols of ) and the middle symbol is the sixth, . The five symbols that follow are .
Reverse of : . Complement: . All five pushed symbols are then popped, so the machine can reach the final state.
Note: the paper's figure names the states q0, q2 and q3 (read them as q0, q1 and q2, as in the text) and writes the stack top as Z, which is not in the stack alphabet. Z stands for the current stack symbol, with at the bottom.
Answer: (B)
The total length is , which is odd, so there is a middle symbol: and . So (the first five symbols of ) and the middle symbol is the sixth, . The five symbols that follow are .
Reverse of : . Complement: . All five pushed symbols are then popped, so the machine can reach the final state.
Note: the paper's figure names the states q0, q2 and q3 (read them as q0, q1 and q2, as in the text) and writes the stack top as Z, which is not in the stack alphabet. Z stands for the current stack symbol, with at the bottom.
Answer: (B)