GATE 2017 (Session 2)
65 questions
MCQ 45 · NAT 201-mark 30 · 2-mark 35
Questions 51–55 of 65
Let L(R) be the language represented by regular expression R. Let L(G) be the language generated by a context free grammar G. Let L (M) be the language accepted by a Turning machine M. Which of the following decision problems are undecidable ?
I. Given a regular expression R and a string w, is wL(R)?
II. Given a context-free grammar G, L(G)=?
III. Given a context-free grammar G, is L(G)=* for some alphabet ?
IV. Given a Turning machine M and a string w, is wL(M)?
I. Given a regular expression R and a string w, is wL(R)?
II. Given a context-free grammar G, L(G)=?
III. Given a context-free grammar G, is L(G)=* for some alphabet ?
IV. Given a Turning machine M and a string w, is wL(M)?
Answer: (D)
Go through each statement:
- I: for a regular expression, make an automaton and run w on it decidable.
- II: for a CFG, check whether the start symbol S can produce a string of terminals (mark the variables that can, step by step) decidable.
- III: is for a CFG? undecidable. For a TM M and string w, the strings that are not an accepting computation history of M on w form a context-free language, so a CFG G can be built for it. Then exactly when M does not accept w. A decider for III would decide TM acceptance, which IV shows is impossible.
- IV: does a TM accept a string w? This is the acceptance problem, as hard as the halting problem undecidable.
So III and IV are undecidable.
Answer: (D)
- I: for a regular expression, make an automaton and run w on it decidable.
- II: for a CFG, check whether the start symbol S can produce a string of terminals (mark the variables that can, step by step) decidable.
- III: is for a CFG? undecidable. For a TM M and string w, the strings that are not an accepting computation history of M on w form a context-free language, so a CFG G can be built for it. Then exactly when M does not accept w. A decider for III would decide TM acceptance, which IV shows is impossible.
- IV: does a TM accept a string w? This is the acceptance problem, as hard as the halting problem undecidable.
So III and IV are undecidable.
Answer: (D)
The next state table of a 2-bit saturating up-counter is given below.
The counter is built as a synchronous sequential circuit using T flip-flops. The expression for are
The counter is built as a synchronous sequential circuit using T flip-flops. The expression for are
Answer: (B)
T is 1 only where a bit has to change:
- 00 01: T1 = 0, T0 = 1
- 01 10: T1 = 1, T0 = 1
- 10 11: T1 = 0, T0 = 1
- 11 11: T1 = 0, T0 = 0
Input for T1: , Input for T0:
Answer: Option 2
- 00 01: T1 = 0, T0 = 1
- 01 10: T1 = 1, T0 = 1
- 10 11: T1 = 0, T0 = 1
- 11 11: T1 = 0, T0 = 0
Input for T1: , Input for T0:
Answer: Option 2
Consider the following snippet of a C program. Assume that swap (&x, &y) exchanges the contents of x and y.
int main ( ) {
int array[]={3,5,1,4,6,2};
int done =0 ;
int i ;
while (done == 0) {
done = 1;
for (i = 0; i <=4; i ++) {
if (array [i] < array [i +1]) {
swap (& array [i], &array [i+1]);
done = 0;
}
}
for (i = 5 ; i >=1; i --) {
if (array [i] > array [ i-1]) {
swap ( & array [i] , &array [i-1]);
done = 0;
}
} }
printf ( " %d " , array [3] );
} The output of the program is ____________.Answer: 3
Each pass swaps two neighbours whenever the smaller one comes first. So the while loop keeps running until the array is in descending order: 6, 5, 4, 3, 2, 1.
In this order, array[3] = 3.
Answer: 3
In this order, array[3] = 3.
Answer: 3
Two transactions are given as:
where denotes a read operation by transaction on a variable V and denotes a write operations by transaction on a variable V. The total number of conflict serializable schedules that can be formed by is _____________.
where denotes a read operation by transaction on a variable V and denotes a write operations by transaction on a variable V. The total number of conflict serializable schedules that can be formed by is _____________.
Answer: 54
Let with and . Let with and . The only shared item is , and two reads do not conflict, so the conflicting pairs are , and . A schedule is conflict serializable only if all these pairs point the same way: either all of 's operations come before 's, or all of 's come before 's.
- before on : must come before . This is only the serial schedule , so there is 1 way.
- before on : must come before . There are interleavings in all. Count those with before : if no is before , then come first and can sit in any of 5 places among , giving 5. If only is before , then can be ordered in 3 ways and can sit in 4 places among , giving 12. So have before , and are valid.
Total =
Answer: 54
- before on : must come before . This is only the serial schedule , so there is 1 way.
- before on : must come before . There are interleavings in all. Count those with before : if no is before , then come first and can sit in any of 5 places among , giving 5. If only is before , then can be ordered in 3 ways and can sit in 4 places among , giving 12. So have before , and are valid.
Total =
Answer: 54
The read access times and the hit ratios for different caches in a memory hierarchy are as given below.
The read access time of main memory is 90 nanoseconds. Assume that the caches use the referred word-first read policy and the write back policy. Assume that all the caches are direct mapped caches. Assume that the dirty bit is always 0 for all the blocks in the caches. In execution of a program, 60% of memory reads are for instruction fetch and 40% are for memory operand fetch. The average read access time in nanoseconds (up to 2 decimal places) is______.
The read access time of main memory is 90 nanoseconds. Assume that the caches use the referred word-first read policy and the write back policy. Assume that all the caches are direct mapped caches. Assume that the dirty bit is always 0 for all the blocks in the caches. In execution of a program, 60% of memory reads are for instruction fetch and 40% are for memory operand fetch. The average read access time in nanoseconds (up to 2 decimal places) is______.
Answer: 4.72
The I-cache and the D-cache are the first-level (L1) caches, and both are backed by the same L2 cache. On an L1 miss the request goes to L2 (8 ns), and on an L2 miss it goes to main memory (90 ns). The caches use the referred-word-first policy, so the requested word is passed on as soon as it arrives, and the time to fill the rest of the block is not added. The dirty bit is always 0, so no write back time is added. Only the access times add up.
Cost of an L1 miss: ns
Instruction read: ns
Data read: ns
Average read time ns
Answer: 4.72 ns
Cost of an L1 miss: ns
Instruction read: ns
Data read: ns
Average read time ns
Answer: 4.72 ns