Subject: Theory of Computation

advertisement
(to be filled by Examinee)
Student’s Name:…………………………………………………………….Student’s Code:……………………………………..Date:………
______________
Invigilator’s Sign
Duration: 1:30 hr.
________________
Student’s Sign
MCA III SEM (Sessional (Minor II) Examination, Nov. 2013)
Subject: Theory of Computation
Max Marks: 50
Section A
I. (Objective Type Questions) 25 questions of 1 mark each
1.A grammar has the following productions: S->aSSb | a | bSa
Which of the following sentences are in the language that is generated by this grammar?
a) aaaaabb
b) aabbaabb
c) bbbaabbaa
Marks Obtain:…………
d) All of the above
2. Look at the following non-deterministic finite-state automaton (NFA), with A as the start state, and D as the only
accepting state.
Which deterministic finite-state automaton (DFA) with δ as its state transition function accepts the same language?
a) Start state A , accepting states C and D.
δ(A,b)=B
δ(B,a)=C
δ(C,a)=D
b) Start state A , accepting state C.
δ(A,b)=B
δ(B,a)=C
δ(C,a)=C
c) Start state A , accepting state D.
δ(A,b)=B
δ(B,a)=D
δ(B,b)=C
δ(C,a)=D
d) All the answers above are correct
3. Let G1 and G2 be context-free grammars. Which of the following is the most precise statement that holds?
a) L(G1) U L(G2) is always context-free
b) Sometimes, G1 U G2 is context-free
c) L(G1)  L(G2) is never context-free
d) All statements above are valid
4. Take a look at the following regular grammar (with S as the start symbol), the regular expression, and the given
nondeterministic finite-state automaton (where S is the only start state, and also the only accepting state):
Which statement holds?
a) The NFA and the grammar describe the same language (but not the regular expression)
b) The NFA and the regular expression describe the same language (but not the grammar)
c) The regular expression and the grammar describe the same language (but not the NFA)
d) All three describe the same language
5. Which of the following statements is the most correct answer?
a) A language is ambiguous if every sentence has two or more parse trees
b) A language is unambiguous if every sentence has a unique left-most derivation
c) A context-free grammar is ambiguous if the right-hand side of one of its production rules starts with the non-terminal
that appears on the left-hand side.
d) All three statements above are valid.
6. Which of the following statements is the most correct answer?
a) Every finite language is regular.
b) For some regular grammar G, it holds that L(G) = L(G)*.
c) Syntactically different regular expressions can describe the same language.
d) All statements above are valid.
7. Which of the following statements are correct?
a) An alphabet is a finite sequence of distinct symbols. b) A word is a finite sequence of symbols over a given alphabet.
c) A regular language is always infinite.
d) None of the above
8. Consider the following regular expression:
R=a∗(ab)∗(abc)∗
Which of the following regular expressions denote the same language as the above regular expression?
a) (a + ab + abc)∗
b) a∗(a + b)∗(a + b + c)∗
c) a∗(Ԑ + ab)∗(∅ + abc)∗
d) a∗+ (ab)∗+ (abc)∗
9. In a finite state machine, m = (Q, ∑, d, q0 , F) transition function d is a function which maps
A) Q ->∑xQ
B) Qx∑->Q
C) Q->F
D) Qxq0 ->∑
10. Let the class of languages accepted by finite state machines be L1 and the class of languages represented by regular
expressions be L2 then,
A) L1L2.
B) L2L1.
C) L1L2 =∅.
D) L1 = L2.
11. Push down machine represents which grammar:
A) Type 0
B) Type 1
C) Type-2
D) Type-3
12. Which of the following regular expression over {0,1} denotes the set of all strings not containing 100 as substring
A) 0 * (1* 0)*
B) 0 *1010 *
C) 0 *1* 01*
D) 0 * (10 +1)*
13. What kind of strings is rejected by the following automaton?
A) All strings with two consecutive zeros
C) All strings with alternate 1 and 0
B) All strings with two consecutive ones
D) None of these
14. Which of the following regular expressions describes a language that includes the strings”a”, ”aba”, ”ababa”?
a) a*b*
b) (ab)*
c) (a/b)*
d) a/aba/ababa(ba)*
15. Which of the following strings is not included in the language described by the regular expression x(yz/zy)*z?
a) xz
b) xyz
c) xyzzyz
d) xzyyzz
16. If R=Q+RP, where P and Q are regular expressions, then
a) R=QP*
b) R=PQ*
c) R=P+Q*
d) R=Q/P*
17. L = {aP | p is prime}
a) regular
c) accepted by FSA
d) accepted by PDA
b) not regular
18. For which of the following application, regular expressions cannot be used?
a) Designing Computers
b) Designing Compilers
c) Both a & b
d) Developing computer
19. Regular expression a / b denotes the set
a) {a}
b) {a,b}
c) {^, a,b}
d) {b}
20. The regular sets are closed under
a) Union
b) Kleene Closure
c) concatenation
d) all of the above
Section B
II. (Fill in the blanks) 5 questions of 1 mark each
1. For syntax analysis in any computer programming language ……………………………………………………………….language is used.
2. The union of two regular language is also ……………………………………………………
3. ^ (null) is a …………………………………………… expression.
4. If there are more than one parse tree for a given grammar for same type of derivation, then the grammar is ………………
5. A push down machine is actually a………………………………………… data structure.
Section C
III. (True/False) 10 questions of 1 mark each
1. Two grammars of different types can generate the same language.
2. The language {anbcn|n>=1} is regular.
3. If a grammar G has productions S->aS|bS|a, then L(G)=the set of all strings over {a,b} ending is a.
4. If the productions of G are S->aS|Sb|a|b, then abab belongs to L(G).
5. aa*+bb* is same as (a+b)*.
6. a4b3 is in the regular set given by a*(a+b)b*.
7. The regular expression (a+b)*c* is the same as a*(b+c)*.
8. A regular language is also context free.
9. There exist context-free language that are not regular.
10. The leaf node of parse tree should contain non-terminal.
Section D
IV. (One word/One sentence questions) 5 questions of 1 mark each
1. Draw finite automata for regular expression a|b.
2. For pumping lemma for regular language, what is w, x, y, z and write lemma.
3. Draw Parse tree for given string “abaa” if grammar G is: S->aAS|a|SS, A->SbA|ba
4. Write statement of context-free grammar.
5. What are the applications of automaton?
Section E
V. Short answer type(5 marks each) 2 questions.
1. Show that language L={anbncn|n>=1} is not context free language using pumping lemma.
2. Show that language L={anbm|m,n>=1} is regular language using pumping lemma.
Download