Professional Documents
Culture Documents
In each of the following questions, choose the correct answer from the four choices provided. 1. The following grammar G = (N, T, P, S) N = {S, A, B} T = {a, b, c} P : S aSa S aAa A bB B bB B c is
a. is type 3 b. is type 2 but not type 3 c. is type 1 but not type 2 d. is type 0 but not type 1
2. The following grammar G = (N, T, P, S) N = {S, A, B, C, D, E} T = {a, b, c} P : S aAB AB CD C C CD CE aC b
bE
bc is
a. is type 3 b. is type 2 but not type 3 c. is type 1 but not type 2 d. is type 0 but not type 1
3. The following grammar G = (N, T, P, S) N = {S, A, B, C} T = {a, b, c} P : S aS A bB B cC C a is
a. is type 3 b. is type 2 but not type 3 c. is type 1 but not type 2 d. is type 0 but not type 1
4. The following grammar G = (N, T, P, S) N = {S, A, B, C, D, E} T = (a, b, c} P : S ABCD BCD DE
D D E E
aD a bE c is
a. is type 3 b. is type 2 but not type 3 c. is type 1 but not type 2 d. is type 0 but not type 1
5. Consider the following CFG S aB Bb B bS S bA Aa A aS
B aBB A bAA
This derivation is
a. CFL but not regular b. CSL but not CFL c. regular d. type 0 language but not type 1
7. Consider the following language L = {anbn|n 1} L is
a. CFL but not regular b. CSL but not CFL c. regular d. type 0 language but not type 1
8. Consider the following language L = {anbmcpdq|n, m, p, q 1} L is
a. Chomsky normal form but not strong Chomsky normal form b. Weak Chomsky normal form but not Chomsky normal form c. Strong Chomsky normal form d. Greibach normal form
10. The following CFG is in S aBB B bAA Aa Bb
a. Chomsky normal form but not strong Chomsky normal form b. Weak Chomsky normal form but not Chomsky normal form
a. b. L* = L+ {} c. L* = L+ d. L* = L+ {}
16. The concept of FSA is much used in this part of the compiler
a. lexical analysis
b. FSA cannot deterministically fix the midpoint c. Even if the mid point is known an FSA cannot find whether the second half of the string matches the first half d. all of the above
22. Let = {a, b, c, d, e}. The number of strings in * of length 4 such that no symbol is used more than once in a string is
a. 360 b. 120 c. 35 d. 36
23. Which of the following denotes Chomskian hiearchy?
a. REG CFL CSL type0 b. CFL REG type0 CSL c. CSL type0 REG CFL d. CSL CFL REG type0
24. A language L is accepted by a FSA iff it is
a. (a + b + aa + bb + aba + bba)*
d. a*b*
29. Which of the following strings is not generated by the following grammar? S SaSbS|
a. all words of the form {(ab)na|n 1} b. all words that end with a and c. all words that end with a and not d. all words containing substring ba
31. Consider a language L for which there exists a Turing machine (TM), T, that accepts every word in L and either rejects or loops for every word that is not in L. The language L is
I. II. III.
Recursive languages are closed under complementation Recursively enumerable languages are closed under union Recursively enumerable languages are closed under complementation
a. Any regular language can be generated by a context-free grammar b. Some non-regular languages cannot be generated by any CFG c. the intersection of a CFL and regular set is a CFL d. All non-regular languages can be generated by CFGs.
34. Recursively enumerable languages are not closed under
a. a proper superset of CFL b. always recognized by PDA c. are also called type 0 languages d. always recognized by FSA
37. R1 and R2 are regular sets. Which of the following is not true?
is regular
a. context-free languages are closed under union b. context-free languages are closed under concatenation c. context-free languages are closed under intersection
a. regular grammar to context-free grammar b. nondeterministic FSA to deterministic FSA c. nondeterministic PDA to deterministic PDA d. nondeterministic TM to deterministic TM
Answers
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. b c a d d b a c c d
11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28.
b a b b b a b c c a d b a d c c c c
29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40.
d c d b d c d a a b c c
a. P3 has polynomial time solution if P1 is polynomial time reducible to P3 b. P3 is NP complete if P3 is polynomial time reducible to P2 c. P3 is NP complete if P2 is reducible to P3 d. P3 has polynomial time complexity and P3 is reducible to P2
3. Consider the FSA M
a. {w {a, b}* | every a in w is followed by exactly two bs} b. {w {a, b}* | every a in w is followed by atleast two bs} c. {w {a, b}* |w contains the substring abb} d. {w {a, b}* |w does not contain aa as substring}
4. Let Nf and Np denote the classes of languages accepted by nondeterministic FSA and nondeterministic PDA, respectively. Let Dfand Dp denote the classes of languages accepted by deterministic FSA and PDA respectively. Which of the following is TRUE?
a. Df Nf
Dp = Np
b. Df Nf
Dp Np
c. Df = Nf
Dp = Np
d. Df = Nf
5. Consider the languages L1 = {anbncm|n, m > 0} and L2 = {anbmcm|n, m > 0} Which one of the following statements is false?
7.
Consider the languages L1 = {anbmcmdn|n, m > 0} and L2 = {anbncmdm|n, m > 0} Which one of the following statements is false?
a. L and
are not recursively enumerable are recursively enumerable but not recursive
Let L1 be a recursive language and let L2 be a recursively enumerable language which is not recursive. Which one of the following is TRUE?
a. b. c. d.
10.
a. L1 is deterministic CFL b. L2 is deterministic CFL c. L3 is a CFL but not a deterministic CFL d. L3 is deterministic CFL
11. Let S be a NPcomplete problem and Q and R be two other problems not known to be in NP. Q is polynomial time reducible to Sand S is polynomial time reducible to R. Which one of the following statements is TRUE?
in s and n1 (s) the number of 1s in s. Which one of the following languages is not regular?
a. L = {s (0+1)*|n0(s) is a 3-digit prime} b. L = {s (0+1)*|for every prefix s of s, |n0 (s) n1(s)| 2} c. L = {s (0+1)*n0(s) n1(s)| 4} d. L = {s (0+1)*|n0(s) mod 7 = n1(s) mod 5 = 0}
14. For s (0+1)*let d(s) denote the decimal value of s (eg. D(|0|) = 5). Let L = {s (0+1)*|d(s) mod 5 = 2 and d(s) mod 7 4} Which one of the following statements is TRUE?
a. L is recursively enumerable but not recursive b. L is recursive, but not context-free c. L is context-free, but not regular d. L is regular
15. Let FHAM be the problem of finding a Hamiltonian cycle in a graph G and DHAM be the problem of determining if a Hamiltonial cycle exists in a graph. Which one of the following is TRUE?
a. Both FHAM and DHAM are NP-hard b. FHAM is NP hard, but DHAM is not c. DHAM is NP hard, but FHAM is not d. Neither FHAM nor DHAM is NP hard
16. Consider the following statements about the context-free grammar G = {S SS, S ab, S ba, S c}
I. II.
III.
a. 3 b. 5 c. 8 d. 9
19. Which one of the following grammars generates the language L = {aibj|i j}.
B Bb| b. S aS|Sb|a|b c. S AC|CB C aCb| A aA| B Bb| d. S AC|CB C aCb| A aA|a B bB|b
20. In the above correct grammar what is the minimum length of the derivation (number of steps starting from S) to generate the string a1 bm with l m?
a. max(l, m) + 2 b. l + m + 2 c. l + m + 3 d. max(l, m) + 3
21. Consider S SS|a. What is the number of different derivation trees for aaaaa
a. 3 b. 5 c. 7 d. 14
22.
a. S AC|CB A aA|a B Bc|c C aCc|bD|b D bD|b b. S aS|aA A bA|bB B cB|c c. S AB A aAb|ab B bBc|bc d. S AC|CB A aA| B Bc| C aCc||bD D bD|b|
23. A minimum state deterministic automaton accepting the language L = {w|w {0,1}*, the number of 0s and 1s in w are divisible by 3 and 5 respectively} has
d. 9 states
24. The language L = {0i21i / i 0} over the alphabet {0, 1, 2} is
a. not recursive b. is recursive and is a deterministic CFL c. is a regular language d. is not a deterministic CFL but a CFL
25. Which of the following languages is regular?
a. {wwR|w {0, 1}+} b. {wwRx|w, x {0, 1}+} c. {w x w R|w, x {0, 1}+} d. {xwwR|w, x {0, 1}+}
26. Let = {0, 1}, L1 = * and L2 = {0n 1n|n 1} then the languages L1 L2 and L2 are respectively
a. regular, regular b. regular, not regular c. not regular, regular d. not regular, not regular
27. Which of the following statements is false?
a. The halting problem for Turing machines is undecidable b. determining whether a context-free grammar is ambiguous is undecidable c. given two arbitrary context-free grammar, G1 and G2, it is undecidable
with L(G1) = L(G2) d. given two regular grammars G1 and G2, it is undecidable whether L(G1) = L(G2)
28. Two of the following four regular expressions are equivalent. Which two?
a. (i) and (ii) b. (ii) and (iii) c. (i) and (iii) d. (iii) and (iv)
29. Let L * where = {a, b}. Which of the following is true?
a. L = {x|x has an equal number of as and bs } is regular b. L = {an bn | n 1} is regular c. L = {am bn | m, n 1} is regular d. L = {x|x has more as than bs} is regular
30. Define for a CFL L, init (L) = {u | uv L for some v {0, 1}*}. In other words init (L) is the set of prefixes of L. Let L = {w|w {0, 1}+, w has equal number of 0s and 1s}. Then init (L) is
a. the set of all binary strings with unequal number of 0s and 1s b. the set of all binary stings including c. the set of all binary strings with exactly one more 0 than the number of
a. L1L2 b. L1 L2 c. L1 L2 d. L1 R
32. The grammar whose productions are stmt if id then stmt stmt if id then stmt else stmt stmt id := id id a|b|c|d|f is ambiguous because
a. the sentence if a then if b then c := d has more than one derivation trees b. the leftmost and rightmost derivation of the sentence if a then if b then c := d give rise to different parse trees c. the sentence if a then if b then c := d else c := f has more than two parse trees d. the sentence if a then if b then c := d else c := f has two parse trees
33. Which one of the following regular expressions over {0, 1} denotes the set of all strings not containing 100 as a substring?
a. 0*(11*0)*
a. given a Turing machine M, a string s, and an integer k, M accepts s with k steps b. equivalence of two given Turing machines c. language accepted by a given DFSA is nonempty d. language generated by a CFG is nonempty
35. Which of the following languages over {a, b, c} is accepted by a deterministic PDA?
a. {wbwR|w {a, c}*} b. {wwR|w {a, b, c}*} c. {anbncn|n 1} d. {w|w is a palindrome over {a, b, c}}
36. Which of the following instances of the post correspondence problem has a viable sequence (a solution)?
a. {(b, bb), (bb, bab), (bab, abb), (abb, babb)} b. {(ab, aba), (baa, aa), (aba, baa)} c. {(ab, abb), (ba, aaa), (aa, a)} d. none of the above
37. It is undecidable, whether
b. an arbitrary TM halts after 10 steps c. an arbitrary TM ever prints a specific letter d. an arbitrary TM accepts a string w in 5 steps
38. Let r = 1(1+0)*, s = 11*0 and t = 1*0 be three regular expressions and R, S, T the regular sets corresponding to them. Which of the following is true?
a. S R b. R S c. T S d. R T
39. Which one of the following is the strongest correct statement about a finite language L over a finite alphabet ?
a. infinite union of regular sets is regular b. infinite union of finite sets is regular c. finite union of finite sets is regular d. complement of a finite set need not be regular
Answers
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. c c b c a a b d b b b d c d a b b
18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35.
d a a d a a b c b d c c b c d d b a
c c a d c