toc sec b
toc sec b
a) {aa, ab, ba, bb} b) {aaaa, abab, ε, abaa, aabb} c) {aaa, aab,
aba, bbb} d) All of the mentioned
a) 7 b) 6 c) 8 d) 5
6 Consider NFA which starts with a and end with b ,then total d
number of states required in NFA are:
a)2 b)1 c)4 d)3
A. n B. n+1 C. n + 2 D. n + n
20 B
The finite automata accept the following language------
A. using PDA
(C answer)
22 C
Which among the following is the missing transition in the given
DFA?
A. δ (q0, a) =q0
B. δ (F, a) =D
C. δ (F, a) =q1
D. δ (q1, a) =D
23 A
Which of the following does the given Mealy machine represents?
A. 1’s Complement B.2’s Complement
24 c
Two finite state machines are said to be equivalent if they-----
25 A
Which of the following will not be accepted by the following
DFA?
A. ababaabaa
B. abbbaa C. abbbaabb D. abbaabbaa
MCQS on REGULAR EXPRESSION
2 The string 1101 does not belong the set represented by: C and D
A. 110*(0+1)
B. 1(0+1)*101
C. (10)*(01)*(00+11)*
D. (00+(11)*0)*
Answer: C & D Explanation:- R.E of option C won’t generate 1101
as you can see the language will contain L(C) =
{epsilon,10,1010,1001,0101,00,11,0011,1100,………..} Also, R.E of
option D has ‘1’ but here two ’11’ are together hence it’s impossible
to generate 1101. L(D) =
{Epsilon,0,00,110,11110,11000,…………….} Here Option (C) and
(D) both are correct.
4 Regular expression for all the strings starts with ab and ends c
with ba is
A. aba*b*ba
B. ab(ab)*ba
C. ab(a+b)*ba
D. All of above
Answer: C Explanation:- Starts with ab then any number of a or b
and ends with ba.
Answer:b
17 A CFG is ambiguous if B
a) It has more than one rightmost derivations
b) It has more than one leftmost derivations
c) No parse tree can be generated for the CFG
d) None of the mentioned
23 (a+b)* is equivalent to B
A. b*a* B. (a*b*)* C. a*b* D. none of the mentioned
Answer: B Explanation: (a+b)* = (a*b*)*
24 Concatenation Operation refers to which of the following set B
operations:
A. Union
B. Dot
C. Kleene
D. Two of the options are correct
Answer: B Explanation: Two operands are said to be performing
Concatenation operation AB = A•B
MCQs on GRAMMAR
15 . A CFG consist of : D
A. Set of Nonterminals
B. Start symbol
C. Set of terminals
D. All of these
Answer: D Explanation: G= {V, T, P, S} variables, Terminals,
Productions, start symbol
18 CFG for a+ D
A. S -> aS | a | ^
B. S → aS | b
C. S → aS | a
D. None of these
Answer: D
Explanation: S → aS | a L={a,aa, aaa, aaaa, ….}
20 A CFG is ambiguous if D
A. It has more than one rightmost derivations
B. It has more than one leftmost derivations
C. No parse tree can be generated for the CFG
D. Both A & B
Answer: D Explanation: A context free grammar is ambiguous if it
has more than one parse tree generated or more than one leftmost
derivations. An unambiguous grammar is a context free grammar
for which every valid string has a unique leftmost derivation.
a) stack
b) input tape
c) terminals
Explanation:
A PDA is a finite machine which has an additional
stack storage. Its transitions are based not only on input and the
correct state but also on the stack
5 If the PDA does not stop on an accepting state and the stack is A
not empty, the string is:
a) rejected
Explanation:
To accept a string, PDA needs to halt at an accepting
state and with a stack empty, else it is called rejec PDA M, we can
construct a PDA M' that accepts the same language as M, by both
acceptance criteria.
a. {0^n1^n|n>=0}
b. {0^n1^2n|n>=0}
c. {0^2n1^n|n>=0}
d. None of the mentioned
Answer: a
10 A turing machine is a d
a) real machine b) abstract machine c) hypothetical machine
d) more than one option is correct
A turing machine is abstract or hypothetical machine thought
by mathematician Alan Turing in 1936 capable of simulating
any algorithm, however complicated it is.
15 Match the following List-I with List-II and select the correct 2
answer using the codes given below the lists
List-I List-II
A. Laxical analyser 1. Pushdown automata
B. Parsing 2. Turing machine
C.Computing 3. Finite state automata
D.Non-deterministic
butfinite machine 4. Non-deterministic FA
0ptions
1. A-3, B-4, C-2, D-1
2. A-3, B-1, C-2, D-4
3. A-3, B-1, C-4, D-2
4. A-3, B-2, C-1, D-
10 A
Decidable can be taken as a synonym to:
A)Recursive
b) non recursive
c) recognizable
Answer: a
www.studymaterialz.in
f) Kleene closure
17
www.studymaterialz.in
c) (01)4
d) (0+1+ε)4
SOLUTION
Answer: d
Explanation: The extended notation would be (0+1)4 but however, we may allow
some or all the factors to be ε. Thus ε needs to be included in the given regular
expression.
5. Which among the following looks similar to the given expression?
((0+1). (0+1)) *
a) {xϵ {0,1} *|x is all binary number with even length}
b) {xϵ {0,1} |x is all binary number with even length}
c) {xϵ {0,1} *|x is all binary number with odd length}
d) {xϵ {0,1} |x is all binary number with odd
length} SOLUTION
Answer: a
Explanation: The given regular expression corresponds to a language of binary
strings which is of even length including a length of 0.
6. If R represents a regular language, which of the following represents the Venn-
diagram most correctly?
a) An Irregular Set
b) R*
c) R complement
d) R reverse
SOLUTION
Answer: b
Explanation: The given diagram represents the Kleene operation over the Regular
Language R in which the final states become the initial and the initial state becomes
final.
7. The given NFA corresponds to which of the following Regular expressions?
18
www.studymaterialz.in
a) Union
b) Dot
c) Kleene
d) Two of the options are correct
SOLUTION
Answer: b
Explanation: Two operands are said to be performing Concatenation operation AB =
A•B = {xy: x ∈ A & y ∈ B}.
9. Concatenation of R with Ф outputs:
a) R
b) Ф
c) R.Ф
d) None of the mentioned
SOLUTION
Answer: b
Explanation: By distributive property (Regular expression identities), we can prove
the given identity to be Ф.
10. RR* can be expressed in which of the forms:
a) R+
b) R-
c) R+ U R-
d) R
SOLUTION
Answer: a
Explanation: RR*=R+ as R+ means the occurrence to be at least once.
ANSWER: d
19
www.studymaterialz.in
Answer: c
Explanation: It matches the end of a string and not an internal line.The given
segment of code outputs:
Hello
World
is a string that ends with ‘d\n’
10. Conversion of a regular expression into its corresponding NFA :
a) Thompson’s Construction Algorithm
b) Powerset Construction
c) Kleene’s algorithm
d) None of the mentioned
SOLUTION
Answer: a
Explanation: Thompson construction algorithm is an algorithm in automata theory
used to convert a given regular expression into NFA. Similarly, Kleene algorithm is
used to convert a finite automaton to a regular expression.
22
www.studymaterialz.in
3. If we select a string w such that w∈L, and w=xyz. Which of the following portions
cannot be an empty string?
a) x
b) y
c) z
d) all of the mentioned
SOLUTION
Answer: b
Explanation: The lemma says, the portion y in xyz cannot be zero or empty i.e. |y|>0,
this condition needs to be fulfilled to check the conclusion condition.
4. Let w= xyz and y refers to the middle portion and |y|>0.What do we call the process
of repeating y 0 or more times before checking that they still belong to the language L
or not?
a) Generating
b) Pumping
c) Producing
d) None of the mentioned
SOLUTION
Answer: b
Explanation: The process of repeatation is called pumping and so, pumping is the
process we perform before we check whether the pumped string belongs to L or not.
5. There exists a language L. We define a string w such that w∈L and w=xyz and |w|
>=n for some constant integer n.What can be the maximum length of the substring xy
i.e. |xy|<=?
a) n
b) |y|
c) |x|
d) none of the mentioned
SOLUTION
Answer: a
Explanation: It is the first conditional statement of the lemma that states that
|xy|<=n, i.e. the maximum length of the substring xy in w can be n only.
6. Fill in the blank in terms of p, where p is the maximum string length in L.
Statement: Finite languages trivially satisfy the pumping lemma by having n =
a) p*1
b) p+1
c) p-1
d) None of the mentioned
SOLUTION
Answer: b
Explanation: Finite languages trivially satisfy the pumping lemma by having n equal
to the maximum string length in l plus 1.
23
www.studymaterialz.in
24
www.studymaterialz.in
SOLUTION
Answer: b
Explanation: Pigeon hole principle states the following example: If there exists n=10
pigeons in m=9 holes, then since 10>9, the pigeonhole principle says that at least
one hole has more than one pigeon.
25
www.studymaterialz.in
4. Let w= xyz and y refers to the middle portion and |y|>0.What do we call the process
of repeating y 0 or more times before checking that they still belong to the language L
or not?
a) Generating
b) Pumping
c) Producing
d) None of the mentioned
SOLUTION
Answer: b
Explanation: The process of repeatation is called pumping and so, pumping is the
process we perform before we check whether the pumped string belongs to L or not.
5. There exists a language L. We define a string w such that w∈L and w=xyz and |w|
>=n for some constant integer n.What can be the maximum length of the substring xy
i.e. |xy|<=?
a) n
b) |y|
c) |x|
d) none of the mentioned
SOLUTION
Answer: a
Explanation: It is the first conditional statement of the lemma that states that
|xy|<=n, i.e. the maximum length of the substring xy in w can be n only.
6. Fill in the blank in terms of p, where p is the maximum string length in L.
Statement: Finite languages trivially satisfy the pumping lemma by having n =
a) p*1
b) p+1
c) p-1
d) None of the mentioned
SOLUTION
Answer: b
Explanation: Finite languages trivially satisfy the pumping lemma by having n equal
to the maximum string length in l plus 1.
7. Answer in accordance to the third and last statement in pumping lemma:
For all xyiz ∈L
a) i>0
b) i<0
c) i<=0
d) i>=0
SOLUTION
Answer: d
Explanation: Suppose L is a regular language . Then there is an integer n so that for
any x∈L and |x|>=n, there are strings u,v,w so that
26
www.studymaterialz.in
x= uvw
|uv|<=n
|v|>0
for any m>=0, uvmw ∈L.
8. If d is a final state, which of the following is correct according to the given diagram?
27
www.studymaterialz.in
c) decidable
d) none of the mentioned
SOLUTION
Answer: b
Explanation: If two regular languages are closed under an operation op, then the
resultant of the languages over an operation op will also be regular.
2. Suppose a regular language L is closed under the operation halving, then the result
would be:
a) 1/4 L will be regular
b) 1/2 L will be regular
c) 1/8 L will be regular
d) Al of the mentioned
SOLUTION
Answer: d
Explanation: At first stage 1/2 L will be regular and subsequently, all the options will
be regular.
3. If L1′ and L2′ are regular languages, then L1.L2 will be
a) regular
b) non regular
c) may be regular
d) none of the mentioned
SOLUTION
Answer: a
Explanation: Regular language is closed under complement operation. Thus, if L1′
and L2′ are regular so are L1 and L2. And if L1 and L2 are regular so is L1.L2.
4. If L1 and L2′ are regular languages, L1 ∩ (L2′ U L1′)’ will be
a) regular
b) non regular
c) may be regular
d) none of the mentioned
SOLUTION
Answer: a
Explanation: If L1 is regular, so is L1′ and if L1′ and L2′ are regular so is L1′ U L2′.
Further, regular languages are also closed under intersection operation.
5. If A and B are regular languages, !(A’ U B’) is:
a) regular
b) non regular
c) may be regular
d) none of the mentioned
SOLUTION
Answer: a
Explanation: If A and B are regular languages, then A Ç B is a regular language and A
28
www.studymaterialz.in
29
www.studymaterialz.in
10. Which among the following is the closure property of a regular language?
a) Emptiness
b) Universality
c) Membership
d) None of the mentioned
SOLUTION
Answer: d
Explanation: All the following mentioned are decidability properties of a regular
language. The closure properties of a regular language include union, concatenation,
intersection, Kleene, complement , reverse and many more operations.
a) (0+1)*001(0+1)*
b) 1*001(0+1)*
c) (01)*(0+0+1)(01)*
d) None of the mentioned
SOLUTION
Answer: a
Explanation: There needs to be 001 together in the string as an essential substring.
Thus, the other components can be anything, 0 or 1 or e.
2. Which of the following statements is not true?
a) Every language defined by any of the automata is also defined by a regular
expression
b) Every language defined by a regular expression can be represented using a DFA
c) Every language defined by a regular expression can be represented using NFA with e
moves
d) Regular expression is just another representation for any automata definition
SOLUTION
Answer: b
Explanation: Using NFA with e moves, we can represent all the regular expressions
as an automata. As regular expressions include e, we need to use e moves.
30
www.studymaterialz.in
3. The total number of states required to automate the given regular expression
(00)*(11)*
a) 3
b) 4
c) 5
d) 6
SOLUTION
Answer: c
Explanation:
4. Which of the given regular expressions correspond to the automata shown?
31
www.studymaterialz.in
35
www.studymaterialz.in
d) None of these
SOLUTION
Answer: b
Explanation: G=(V, ∑, p, S), here V=Finite set of variables, ∑= set of terminals, p=
finite productions, S= Starting Variable.
5. Which among the following cannot be accepted by a regular grammar?
a) L is a set of numbers divisible by 2
b) L is a set of binary complement
c) L is a set of string with odd number of 0
d) L is a set of 0n1n
SOLUTION
Answer: d
Explanation: There exists no finite automata to accept the given language i.e. 0n1n.
For other options, it is possible to make a dfa or nfa representing the language set.
6. Which of the expression is appropriate?
For production p: a->b where a∈V and b∈
a) V
b) S
c) (V+∑)*
d) V+ ∑
SOLUTION
Answer: c
Explanation: According to the definition, the starting variable can produce another
variable or any terminal or a variable which leads to terminal.
7. For S->0S1|e for ∑={0,1}*, which of the following is wrong for the language
produced?
a) Non regular language
b) 0n1n | n>=0
c) 0n1n | n>=1
d) None of the mentioned
SOLUTION
Answer: d
Explanation: L={e, 01, 0011, 000111, ……0n1n }. As epsilon is a part of the set, thus all
the options are correct implying none of them to be wrong.
8. The minimum number of productions required to produce a language consisting of
palindrome strings over ∑={a,b} is
a) 3
b) 7
c) 5
d) 6
SOLUTION
Answer: c
36
www.studymaterialz.in
Explanation: The grammar which produces a palindrome set can be written as:
S-> aSa | bSb | e | a | b
L={e, a, b, aba, abbbaabbba…..}
9. Which of the following statement is correct?
a) All Regular grammar are context free but not vice versa
b) All context free grammar are regular grammar but not vice versa
c) Regular grammar and context free grammar are the same entity
d) None of the mentioned
SOLUTION
Answer: a
Explanation: Regular grammar is a subset of context free grammar and thus all
regular grammars are context free.
10. Are ambiguous grammar context free?
a) Yes
b) No
SOLUTION
Answer: a
Explanation: A context free grammar G is ambiguous if there is atleast one string in
L(G) which has two or more distinct leftmost derivations.
37
www.studymaterialz.in
Explanation:
6. The number of leaves in a parse tree with expression E*(E) where * and () are
operators
a) 5
b) 2
c) 4
d) 3
38
www.studymaterialz.in
SOLUTION
Answer: a
Explanation:
7. Which of the following does the given parse tree correspond to?
a) P->1100
b) P->0110
c) P->1100ε
d) P->0101
SOLUTION
Answer: b
Explanation: The following is a parse tree for the production 0110 over {0,1}*.
8. A grammar with more than one parse tree is called:
a) Unambiguous
b) Ambiguous
39
www.studymaterialz.in
c) Regular
d) None of the mentioned
SOLUTION
Answer: b
Explanation: A context free grammar G is ambiguous if there is at least one string in
L(G) having two or more distinct derivation trees or equivalently, two or more
distinct leftmost derivations.
9. is the acyclic graphical representation of a grammar.
a) Binary tree
b) Oct tree
c) Parse tree
d) None of the mentioned
SOLUTION
Answer: c
Explanation: In order to graphically represent a derivation of a grammar we need to
use parse trees.
10. Grammar is checked by which component of compiler
a) Scanner
b) Parser
c) Semantic Analyzer
d) None of the mentioned
SOLUTION
Answer: Parser or syntax analyzer is the one responsible for checking the grammar
and reporting errors. In this phase, parse tree is generated and syntax is analyzed.
TOPIC 3: Ambiguity in Grammars and Languages
1. Which of the following is not a notion of Context free grammars?
a) Recursive Inference
b) Derivations
c) Sentential forms
d) All of the mentioned
SOLUTION
Answer: d
Explanation: The following are the notions to express Context free grammars:
a) Recursive Inferences
b) Derivations
c) Sentential form
d) Parse trees
2. State true or false:
Statement: The recursive inference procedure determines that string w is in the
language of the variable A, A being the starting variable.
a) true
b) false
40
www.studymaterialz.in
SOLUTION
Answer: a
Explanation: We apply the productions of CFG to infer that certain strings are in the
language of a certain variable.
3. Which of the following is/are the suitable approaches for inferencing?
a) Recursive Inference
b) Derivations
c) Both Recursive Inference and Derivations
d) None of the mentioned
SOLUTION
Answer: c
Explanation: Two inference approaches:
1. Recursive inference, using productions from body to head
2. Derivations, using productions from head to body
4. If w belongs to L(G), for some CFG, then w has a parse tree, which defines the
syntactic structure of w. w could be:
a) program
b) SQL-query
c) XML document
d) All of the mentioned
SOLUTION
Answer: d
Explanation: Parse trees are an alternative representation to derivations and
recursive inferences. There can be several parse trees for the same string.
5. Is the following statement correct?
Statement: Recursive inference and derivation are equivalent.
a) Yes
b) No
SOLUTION
Answer: a
Explanation: Yes, they are equivalent. Both the terminologies represent the two
approaches of recursive inferencing.
6. A->aA| a| b
The number of steps to form aab:
a) 2
b) 3
c) 4
d) 5
SOLUTION
Answer: b
Explanation: A->aA=>aaA=>aab
7. An expression is mentioned as follows. Figure out number of incorrect notations or
41
www.studymaterialz.in
symbols, such that a change in those could make the expression correct.
L(G)={w in T*|S→*w}
a) 0 Errors
b) 1 Error
c) 2 Error
d) Invalid Expression
SOLUTION
Answer: a
Explanation: For the given expression, L(G)={w in T*|S→*w}, If G(V, T, P, S) is a CFG,
the language of G, denoted by L(G), is the set of terminal strings that have
derivations from the start symbol.
8. The language accepted by Push down Automaton:
a) Recursive Language
b) Context free language
c) Linearly Bounded language
d) All of the mentioned
SOLUTION
Answer: b
Explanation: Push down automata accepts context free language.
9. Which among the following is the correct option for the given grammar?
G->X111|G1,X->X0|00
a) {0a1b|a=2,b=3}
b) {0a1b|a=1,b=5}
c) {0a1b|a=b}
d) More than one of the mentioned is correct
SOLUTION
Answer: a
Explanation: Using the recursive approach, we can conclude that option a is the
correct answer, and its not possible for a grammar to have more than one language.
10. Which of the following the given language belongs to?
L={ambmcm| m>=1}
a) Context free language
b) Regular language
c) Both (a) and (b)
d) None of the mentioned
SOLUTION
Answer: d
Explanation: The given language is neither accepted by a finite automata or a push
down automata. Thus, it is neither a context free language nor a regular language.
11. Choose the correct option:
Statement: There exists two inference approaches:
a) Recursive Inference
42
www.studymaterialz.in
b) Derivation
a) true
b) partially true
c) false
d) none of the mentioned
SOLUTION
Answer: a
Explanation: We apply the productions of a CFG to infer that certain strings are in a
language of certain variable.
12. Choose the correct option:
Statement 1: Recursive Inference, using productions from head to body.
Statement 2: Derivations, using productions from body to head.
a) Statement 1 is true and Statement 2 is true
b) Statement 1 and Statement 2, both are false
c) Statement 1 is true and Statement 2 is false
d) Statement 2 is true and Statement 1 is true
SOLUTION
Answer: b
Explanation: Both the statements are false. Recursive Inference, using productions
from body to head. Derivations, using productions from head to body.
13. Which of the following statements are correct for a concept called inherent
ambiguity in CFL?
a) Every CFG for L is ambiguous
b) Every CFG for L is unambiguous
c) Every CFG is also regular
d) None of the mentioned
SOLUTION
Answer: a
Explanation: A CFL L is said to be inherently ambiguous if every CFG for L is
ambiguous.
14. Which of the theorem defines the existence of Parikhs theorem?
a) Parikh’s theorem
b) Jacobi theorem
c) AF+BG theorem
d) None of the mentioned
SOLUTION
Answer: a
Explanation: Rohit Parikh in 1961 proved in his MIT research paper that some context
free language can only have ambiguous grammars.
43
www.studymaterialz.in
a) Null production
b) Unit production
c) Greibach Normal Form
d) Chomsky Normal Form
SOLUTION
Answer: b
Explanation: A->ε is termed as Null production while A->B is termed as Unit
production.
2. Halting states are of two types. They are:
a) Accept and Reject
b) Reject and Allow
c) Start and Reject
d) None of the mentioned
SOLUTION
Answer: a
Explanation: Halting states are the new tuple members introduced in turing machine
and is of two types: Accept Halting State and Reject Halting State.
3. A push down automata can be represented as:
PDA= ε-NFA +[stack] State true or false:
a) true
b) false
SOLUTION
Answer: a
Explanation:
44
www.studymaterialz.in
c) or/not symbol
d) none of the mentioned
SOLUTION
Answer: a
Explanation: Using this notation, we can define moves and further acceptance of a
string by the machine.
6. Which among the following is true for the given statement?
Statement :If there are strings R and T in a language L so that R is prefix of T and R is
not equivalent to T.
a) No DPDA can accept L by empty stack
b) DPDA can accept L by an empty stack
c) L is regular
d) None of the mentioned
SOLUTION
Answer: a
Explanation: If M is a DPDA accepting L by an empty stsck, R and T are distinct
strings in L, and R is a prefix of T, then the sequence of moves M must make in order
to accept R leaves the stack empty, since R∈L. But then T cannot be accepted, since
M cant move with an empty stack.
7. Which of the following can be accepted by a DPDA?
a) The set of even length palindrome over {a,b}
b) The set of odd length palindrome over {a,b}
c) {xxc| where c stands for the complement,{0,1}}
d) None of the mentioned
SOLUTION
Answer: d
Explanation: Theorem: The language pal of palindromes over the alphabet {0,1}
cannot be accepted by any finite automaton , and it is therefore not regular.
8. For a counter automaton, with the symbols A and Z0, the string on the stack is
always in the form of
a) A
b) AnZ0, n>=0
c) Z0An, n>=0
d) None of the mentioned
SOLUTION
Answer: b
Explanation:The possible change in the stack contents is a change in the number of
A’s on the stack.
9. State true or false:
Statement: Counter Automaton can exist for the language L={0i1i|i>=0}
a) true
b) false
45
www.studymaterialz.in
SOLUTION
Answer: a
Explanation: The PDA works as follows. Instead of saving excess 0’s or 1’s on the
stack, we save *’s and use two different states to indicate which symbol there is
currently a surplus of. The state q0 is the initial state and the only accepting state.
10. Let ∑={0,1}* and the grammar G be:
S->ε
S->SS
S->0S1|1S0
State which of the following is true for the given
a) Language of all and only Balanced strings
b) It contains equal number of 0’s and 1’s
c) Ambiguous Grammar
d) All of the mentioned
SOLUTION
Answer: d
Explanation: A string is said to be balanced if it consist of equal number of 0’s and 1’s.
46
www.studymaterialz.in
general than context-free grammars, in the sense that there are some languages
that cannot be described by context-free grammars, but can be described by CSG.
3. From the definition of context free grammars,
G=(V, T, P, S)
What is the solution of VÇT?
a) Null
b) Not Null
c) Cannot be determined, depends on the language
d) None of the mentioned
SOLUTION
Answer: a
Explanation: V is the set of non terminal symbols while T is the st of terminal
symbols, their intersection would always be null.
4. If P is the production, for the given statement, state true or false.
P: V->(V∑T)* represents that the left hand side production rule has no right or left
context.
a) true
b) false
SOLUTION
Answer: a
Explanation: Here the production P is from the definition of Context free grammar
and thus, has no right or left context.
5. There exists a Context free grammar such that:
X->aX
Which among the following is correct with respect to the given assertion?
a) Left Recursive Grammar
b) Right Recursive Grammar
c) Non Recursive Grammar
d) None of the mentioned
SOLUTION
Answer: b
Explanation: The grammar with right recursive production is known as Right
recursive grammar. Right recursive production is of the form X->aX where a is a
terminal and X is a non terminal.
6. If the partial derivation tree contains the root as the starting variable, the form is
known as:
a) Chomsky hierarchy
b) Sentential form
c) Root form
d) None of the mentioned
SOLUTION
Answer: b
47
www.studymaterialz.in
48
www.studymaterialz.in
c) (1) S → aMb
(2) M → e
(3) M → aMb
(4) M → bMa
d) None of the mentioned
SOLUTION
Answer: a
Explanation:
The basic idea of grammar formalisms is to capture the structure of string by
a) using special symbols to stand for substrings of a particular structure
b) using rules to specify how the substrings are combined to form new substrings.
9. A CFG consist of the following elements:
a) a set of terminal symbols
b) a set of non terminal symbols
c) a set of productions
d) all of the mentioned
SOLUTION
Answer: d
Explanation: A CFG consists of:
a) a set of terminals, which are characters of alphabets that appear in the string
generated by the grammar.
b) a set of non terminals, which are placeholders for patterns of terminal symbols
that can be generated by the nonterminal symbols.
c) a set of productions, which are set of rules to transit from one state to other
forming up the string
d) a start symbol, a special non terminal symbol that appears in the initial string
generated in the grammar.
10. A CFG for a program describing strings of letters with the word “main” somewhere
in the string:
a) -> m a i n
-> | epsilon
-> A | B | … | Z | a | b … | z
b) –> m a i n
–>
–> A | B | … | Z | a | b … | z
c) –> m a i n
–> | epsilon
–> A | B | … | Z | a | b … | z
d) None of the mentioned
SOLUTION
Answer: a
Explanation: None.
49
Class Test - 01
Course: Theoretical Foundation of Computer Science
A. Yes
B. No
C. Yes, with input alphabet as ∑*
D. Can’t be determined
A. using PDA
B. making final state as non-final
C. making final as starting state and starting state as final state
D. None of the above.
In Mealy Machine the output is depends upon
a. Final State
b.Current State
c.Input
d. Current State & Input
Unit- 4 MCQ
1. Which of the functions can a turing machine not perform?
a) Copying a string b) Deleting a symbol
c) Accepting a pal d) Inserting a symbol
2. If T1 and T2 are two turing machines. The composite can be represented using the expression:
a) T1T2 b) T1 U T2
c) T1 X T2 d) None of the mentioned
3. A language L is said to be Turing decidable if:
a) recursive b) TM recognizes L
c) TM accepts L d) recursive & TM recognizes L
4. A Language L may not be accepted by a Turing Machine if:
a) It is recursively enumerable b) It is recursive
c) L can be enumerated by some turing machine d) None of the mentioned
5. A turing machine that is able to simulate other turing machines:
a) Nested Turing machines b) Universal Turing machine
c) Counter machine d) None of the mentioned
6. Which of the problems are unsolvable?
a) Halting problem b) Boolean Satisfiability problem
c) Halting problem & Boolean Satisfiability problem d) None of the mentioned
7. Which of the following a turing machine does not consist of?
a) input tape b) head c) state register d) none of the mentioned
8. The value of n if turing machine is defined using n-tuples:
a) 6 b) 7 c) 8 d) 5
9. If d is not defined on the current state and the current tape symbol, then the machine ______
a) does not halts b) halts
c) goes into loop forever d) none of the mentioned
10. Which of the following are the models equivalent to Turing machine?
a) Multi tape turing machine b) Multi track turing machine
c) Register machine d) All of the mentioned
11. Which among the following is incorrect for o-machines?
a) Oracle Turing machines b) Can be used to study decision problems
c) Visualizes Turing machine with a black box which is able to decide cerain decion problems in one
operation
d) None of the mentioned
12.
A turing machine has ____________ number of states in a CPU.
a. finite b. infinte
c. May be finite d. None of the mentioned