You are on page 1of 32

Multiple Choice Questions (Set I)

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

Consider the following derivation S aB aaBB aaBb aabSb aabbAb aabbab

This derivation is

a. a leftmost derivation b. a rightmost derivation c. both leftmost and rightmost derivation

d. neither leftmost nor rightmost derivation


6. Consider the following language L = {anbncndn|n 1} L 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. CFL but not regular b. CSL but not CFL c. regular

d. type 0 language but not type 1


9. The following CFG is in S AB B CD B AD Bb D AD Dd Aa Ca

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

c. Strong Chomsky normal form d. Greibach normal form


11. Which of the following CF language is inherently ambiguous?

a. {anbncmdm|n, m 1} b. {anbmcpdq|n = p or m = q, n, m, p, q 1} c. {anbmcpdq|n m p q} d. {anbmcpdq|n m p q}


12. Which string is not accepted by the following FSA?

a. 00111 b. 01010 c. 00110 d. 11010


13. Which string is accepted by the following FSA?

a. 00111 b. 11011 c. 01101 d. 0101


14. Can a DFSA simulate a NFSA

a. No b. Yes c. sometimes d. depends on NFA


15. Which of the following is true for an arbitrary language L.

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. parser c. code generation d. code optimization


17. The concept of grammar is much used in this part of the compiler

a. lexical analysis

b. parser c. code generation d. code optimization


18. (a + b)(cd)*(a + b) denotes the following set

a. {a(cd)nb|n 1} b. {a(cd)na|n 1} {b(cd)nb/n 1} c. {a(cd)na|n 0} {a(cd)nb/n 0} {b(cd)na/n 0} {b(cd)nb/n 0} d. {acndnb|n 1}


19. baa*c denotes the set

a. {bnamcp|n, m, p 1} b. {banc|n 0} c. {banc|n 1} d. {w|w is a string of a, b, c}


20. The set of all strings over the alphabet = {a, b} (including ) is denoted by

a. (a + b)* b. (a + b)+ c. a+b+ d. a*b*


21. Palindromes cant be recognized by any FSA because

a. FSA cannot remember arbitrarily large amount of information

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. CFL b. CSL c. recursive d. regular


25. Which of the following regular expressions denotes a language comprising of all possible strings over = {a, b} of length nwhere n is a multiple of 3.

a. (a + b + aa + bb + aba + bba)*

b. (aaa + bbb)* c. ((a + b)(a + b)(a + b))* d. (aaa + ab + a) + (bbb + bb + a)


26. A language is represented by a regular expression (a)*(a + ba). Which of the following string does not belong to the regular set represented by the above expression.

a. aaa b. aba c. ababa d. aa


27. Which of the following is not primitive recursive but partially recursive?

a. McCarthys function b. Riemann function c. Ackermanns function d. Bounded function


28. Consider the following right-linear grammar G = (N, T, P, S) N = {S} P : S aS|aA T = {a, b} A bA|b

Which of the following regular expression denotes L(G)?

a. (a + b)* b. a(ab)*b c. aa*bb*

d. a*b*
29. Which of the following strings is not generated by the following grammar? S SaSbS|

a. aabb b. abab c. aababb d. aaabb


30. Consider the following NFSA

The automaton accepts

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

a. NP hard b. NP complete c. recursive d. recursively enumerable


32. Consider the following statements

I. II. III.

Recursive languages are closed under complementation Recursively enumerable languages are closed under union Recursively enumerable languages are closed under complementation

Which of the above statement are TRUE?

a. I only b. I and II c. I and III d. II and III


33. Which of the following statement is wrong?

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. union b. homomorphism c. complementation d. concatenation


35. Which of the following problem is undecidable?

a. membership problem for CFL b. membership problem for regular sets

c. membership problem for CSL d. membership problem for type 0 languages


36. Recursive languages are

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?

a. R1 R2 neet not be regular b. * R1 is regular c. R1 R2 is regular d.


38.

is regular

Which of the following regular expression identity is true?

a. r(*) = r* b. (r*s*)* = (r + s)* c. (r + s)* = r* + s* d. r*s* = r* + s*


39. Which one of the following statement is FALSE?

a. context-free languages are closed under union b. context-free languages are closed under concatenation c. context-free languages are closed under intersection

d. context-free languages are closed under Kleene closure


40. Which of the following conversion is not possible (algorithmically)?

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

Multiple Choice Questions (Set II)


In each of the following questions, choose the correct answer from the four choices provided. 1. Consider three decision problems P1, P2 and P3. It is known that P1 is decidable and P2 is undecidable. Which one of the following is TRUE?

a. P3 is decidable if P1 is reducible to P3 b. P3 is undecidable if P3 is reducible to P2

c. P3 is undecidable if P2 is reducible to P3 d. P3 is decidable if P3 is reducible to P2s complement


2. Consider three problems P1, P2 and P3. It is known that P1 has polynomial time solution and P2 is NP-complete and P3 is in NP. Which one of the following is true.

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

The language recognized by M is

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?

Some of these questions have appeared in GATE examinations. Dp Np

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?

a. L1 L2 is a CFL b. L1 L2 is a CFL c. L1 L2 is inherently ambiguous d. L1 L2 is a CSL


6. Consider the languages L1 = {anbmcndp|n, m, p > 0} and L2 = {anbmcpdm|n, m, p> 0} Which one of the following statements is false?

a. L1 L2 is a CFL b. L1 L2 is a CFL c. L1 L2 is inherently ambiguous d. L1 L2 is a CSL

7.

Consider the languages L1 = {anbmcmdn|n, m > 0} and L2 = {anbncmdm|n, m > 0} Which one of the following statements is false?

a. L1 L2 is a CFL b. L1 L2 is a CFL c. L1 and L2 are CFL d. L1 L2 is a CSL


8. Let L and be a language and its complement. Which one of the following possibilities will not hold?

a. L and

are recursive is not recursively

b. L is recursively enumerable but not recursive enumerable c. L and d. L and


9.

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.

is recursive, is recursive, and

is recursively enumerable. is not recursively enumerable.

are recursively enumerable. is recursive.

is recursively enumerable and

Consider the languages L1 = {wwR|w {0,1}*}

L2 = {wcwR|w {0,1}*} L3 = {ww|w {0,1}*} Which one of the following is TRUE?

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?

a. R is NP complete b. R is NP hard c. Q is NP complete d. Q is NP hard


12. L1 = {an + m bn cm|n, m 0} L2 = {an + m bn + m cm|n, m 0} L3 = {an + m bn + m cm + n|n, m 0} Which of these languages are not CF.

a. L1 only b. L3 only c. L1 and L2 d. L2 and L3


13. If s is a string over (0+1)* then let m0 (s) denote the number of 0s

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.

G is ambiguous G produces all strings with equal number of as and bs

III.

G can be accepted by a deterministic PDA

Which combination below expresses all the true statements about G?

a. I only b. I and III only c. II and III only d. I, II and III


17. Let L1 be a regular language and L2 a deterministic CFL. L3 is recursively enumerable but not recursive. Which one of the following statement is FALSE?

a. L1 L2 is a DCFL b. L3 L1 is recursive c. L1 L2 is context-free d. L1 L2 L3 is recursively enumerable


18. Consider the regular language L = (111 + 11111)*. The minimum number of states in any DFA accepting the language is

a. 3 b. 5 c. 8 d. 9
19. Which one of the following grammars generates the language L = {aibj|i j}.

a. S AC|CB C aCb|a|b A aA|

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.

Which one of the following grammar generates L = {ai bj ck|i k, i, j, k 1}

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

a. 15 states b. 11 states c. 10 states

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?

i. ii. iii. iv.

(00)* (0 + ) (00)* 0* 0(00)*

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

1s or one more 1 than the number of 0s. d. none of the above


31. If L1 and L2 are CFL and R a regular set, one of the languages below is not necessarily a CFL. Which one?

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)*

b. 0*1010* c. 0*1*01 d. 0*(10 + 1)*


34. Which one of the following is not decidable?

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

a. an arbitrary TM has 15 states

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. L is undecidable b. L is recursive c. L is a CSL d. L is a regular set


40. Which of the following statements is TRUE?

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

PREVIEW Not a subscriber?

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

36. 37. 38. 39. 40.

c c a d c

START A FREE TRIAL

You might also like