Home > Marketing Management 101 > Quizzes > Theory of Computation and Compiler Design Practice Test
Theory of Computation and Compiler Design Practice Test
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 0% Most missed: “Which of the following describes a handle (as applicable to LR-parsing) appropri…”

Automata theory (also known as Theory Of Computation) is a theoretical branch of Computer Science and Mathematics, which mainly deals with the logic of computation with respect to simple machines, referred to as automata. Automata* enables scientists to understand how machines compute the functions and solve problems.
Theory of Computation is very important in compiler design as it helps in writing efficient algorithms, which help make efficient compiler construcion.

Theory of Computation and Compiler Design Practice Test
Time left 00:00
25 Questions

1. Consider the grammar S → (S) | a Let the number of states in SLR(1), LR(1) and LALR(1) parsers for the grammar be n1, n2 and n3 respectively. The following relationship holds good
2. Which is True about SR and RR-conflict:
3. Consider the following decision problems: (P1) Does a given finite state machine accept a given string (P2) Does a given context free grammar generate an infinite number of stings
Which of the following statements is true?
4. Consider the following C code segment. for (i = 0, i{ for (j=0; j{ if (i%2)
{ x += (4*j + 5*i); y += (7 + 4*j);
}
}
}. Which one of the following is false?
5. Consider the following statements: (I) The output of a lexical analyzer is groups of characters. (II) Total number of tokens in printf('i=%d, &i=%x', i, &i); are 11. (III) Symbol table can be implementation by using array and hash table but not tree.
Which of the following statement(s) is/are correct?
6. Consider the following context free languages:
L1 = {0^i 1^j 2^k | i+j = k}
L2 = {0^i 1^j 2^k | i = j or j = k}
L3 = {0^i 1^j | i = 2j+1}
Which of the following option is true?
7. Consider the grammar shown below S → i E t S S' | a S' → e S | ε E → b In the predictive parse table. M, of this grammar, the entries M[S', e] and M[S', $] respectively are
8. A language L allows declaration of arrays whose sizes are not known during compilation. It is required to make efficient use of memory. Which of the following is true?
9. Consider the following grammar.
S -> S * E
S -> E
E -> F + E
E -> F
F -> id
Consider the following LR(0) items corresponding to the grammar above. (i) S -> S * .E (ii) E -> F. + E (iii) E -> F + .E
Given the items above, which two of them will appear in the same set in the canonical sets-of-items for the grammar?
10. Let be the encoding of a Turing machine as a string over ∑= {0, 1}. Let L = { |M is a Turing machine that accepts a string of length 2014 }. Then, L is
11. Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states. The relationship between n1 and n2 is:
12. An LALR(1) parser for a grammar G can have shift-reduce (S-R) conflicts if and only if
13. The number of tokens in the following C statement is (GATE 2000) printf('i = %d, &i = %x', i, &i);
14. Consider the intermediate code given below:
1. i = 1
2. j = 1
3. t1 = 5 * i
4. t2 = t1 + j
5. t3 = 4 * t2
6. t4 = t3
7. a[t4] = –1
8. j = j + 1
9. if j <= 5 goto(3)
10. i = i + 1
11. if i < 5 goto(2)
The number of nodes and edges in the control-flow-graph constructed for the above code, respectively, are
15. Which of the following statements is false?
16. 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 Note : This question was asked as Numerical Answer
Type.
17. Let L1 be a recursive language, and let L2 be a recursively enumerable but not a recursive language. Which one of the following is TRUE?
18. The expression (a*b)* c op........ where 'op' is one of '+', '*' and '↑' (exponentiation) can be evaluated on a CPU with a single register without storing the value of (a * b) if
19. Which one of the following is FALSE?
20. For S ∈ (0 + 1) * let d(s) denote the decimal value of s (e.g. d(101) = 5). Let L = {s ∈ (0 + 1)* d(s)mod5 = 2 and d(s)mod7 != 4}. Which one of the following statements is true?
21. Let L1 be a regular language, L2 be a deterministic context-free language and L3 a recursively enumerable, but not recursive, language. Which one of the following statements is false?
22. S –> aSa| bSb| a| b ; The language generated by the above grammar over the alphabet {a,b} is the set of
23. Which of the following grammar rules violate the requirements of an operator grammar ? P, Q, R are nonterminals, and r, s, t are terminals.
1. P → Q R
2. P → Q s R
3. P → ε
4. P → Q t R r
24. A minimum state deterministic finite automation accepting the language L = {W |W € {0,1}* , number of 0's and 1's in W are divisible by 3 and 5 respectively has
25. Incremental-Compiler is a compiler