You are on page 1of 8

1.

Number of trivial substrings in “GATE2013” are:

(a) 37 (b) 35 (c) 2 (d) 36

Solution: (c)
Explanation:
For any string, there will always be only 2 trivial substrings, ∈ and the given string itself.

2. Let the string be defined over symbols a and b then what will be the number of states in minimal
DFA, if every string starts and ends with different symbols?
(a) 5
(c) 3
(b) 4
(d) None

Solution: Option (a)


Explanation:

3. The total number of substrings present in “GATE” is:


(a) 7
(c) 11
(b) 10
(d) 8
Solution: Option (c)
Explanation:
L = {ε, G, A, T, E, GA, AT, TE, GAT, ATE, GATE}
Total number of substrings in a string of length n is
(n(n+1)/2) +1

4. Let ∑= {a, b}, what are the number of states in minimal DFA, length of every string congruent
to mod 5.
(a) 2
(c) 5
(b) 3
(d) None
Solution: Option (c)

5. A minimal DFA that is equivalent to a NDFA has:


A. Always more states
C. Exactly 2n states
(b) Always less no. of states
(d) Sometimes more states
Solution: Option (d)
Explanation :
Example which shows that number of states in NFA is greater than DFA.
Consider this NFA which accept (a+b)*.

Its corresponding minimal DFA is:

Hence number of states can be more in NFA

6. Consider following Regular Expression:


(i) a*b*b (a+ (ab)*)* b*
(ii) a*(ab + ba)* b*
What is length of shortest string which is in both (i) & (ii)?
(a) 2
(c) 4
(b) 3
(d) None
Solution: Option (d)
Explanation:
The shortest string is b generated by both the regular expressions.

7. S→AB
A→BB/ a
B→AB/ b
Choose incorrect statement?
A. aabbb can be derived from above grammar
B. aabb can be derived from above grammar
C. ababab can be derived from above grammar
D. abbb can be derived from above grammar
Solution: Option (b)
Explanation:
abb cannot be generated by C, whereas it is generated by all other regular expressions. Another
method to approach this:
(a) (a*+ b*a*)* , assume a* is epsilon then it is equal to (a*+b*)* == (a+b)* // as this is identity of
regular expression.
(b) (a*b*+b*a*)*(a*b*)* // assume all highlighted one is epsilon so this is again equal to (a+b)*
(d) (a+b)*a*b*a*b* // assume all highlighted one is epsilon so this is again equal to (a+b)*

But (c) ((ab)*+a*)* here you cannot make it equal to (a+b)* hence this is odd one.

8. One of the following Regular Expressions is not the same as others. Which one?
(a) (a* + b*a*)*
(c) ((ab)* + a*)*
(b) (a*b* + b*a*)* (a*b*)*
(d) (a + b)* a*b*a*b*
Solution: Option (c)
Explanation:
abb cannot be generated by C, whereas it is generated by all other regular expressions.

9. The complement of CFL:


(a) Recursive
(c) Not RE
(b) Recursive enumerated
(d) The empty set
Solution: Option (a)
Explanation :
CFL is not closed under complement means complement of a CFL may or may not be CFL. Plz
don't assume that complement of CFL will never be CFL.

Hence If L is CFL then its complement L' may or may not be CFL.
As every CFL is CSL also, so we can assume CFL as CSL.
As CSL is closed under complement so complement of CSL must be CSL

Hence complement of CFL must be CSL in worst case.


As every CSL is recursive so complement of CFL is recursive also.
In options CSL is not given hence recursive is correct option.

10. The language of primes in unary is:


(a) Regular
(c) DCFL
(b) CFL
(d) Context Sensitive
Solution: Option (d)
Explanation:
The language of primes in unary is {1 p /p is prime}. Finite automata cannot recognize this
language as it has no memory. PDA also cannot recognize this as there is no pattern in the strings
that can be remembered using one stack. LBA can accept this, so it is a context sensitive language.

11. Consider the regular grammar generating the set of all strings ending with ‘00’, with terminals
{0,1} and non-terminals {S, A, B}, S being the initial state and B, the final state.
S  1S/ 0A
A → 0B
B → 0B/1S/0
The production missing is
(a) A → 1S
(c) A → 1B
(b) B → ε
(d) S → 1B
Solution: Option (a)
Explanation:

12. What are the number of states needed in minimal DFA, that accepts (1+1111)*, with 1 as
alphabet.
(a) 5
(c) 1
(b) 4
(d) None
Solution: Option (c)
Explanation:
The language is 1*.

13. Consider the grammar:


SaSbS/ bSaS/ ε ,
The smallest string for which the grammar has two derivation trees:
(a) abab
(c) bbaa
(b) aabb
(d) aaabbb
Solution: Option (a).

14. Consider the following languages:


L 1 = {a n b n (n ≥ 0)}
L 2 = Complement (L 1 )
Choose appropriate options regarding languages L 1 and L 2
(a) L 1 & L 2 are context free
(b) L 1 is CFL but L 2 is RL
(c) L 1 is CFL and L 2 is CSL
(d) None
Solution: Option (a)
Explanation:
L1 is CFL and L2= {�p bq /� ≠ � �𝑛� �, � > 1} ∪ {b*a*} which is CFL.

15. The language L= { a N b N / 0< N < 327 th Prime number} is


(a) Regular
(c) Not recursive
(b) Not context sensitive
(d) None
Solution: Option (a)
Explanation:
Since this is finite language, it is regular.

16. Let ∑= {a}, assume language, L= {a 2012.K / K> 0}, what is minimum number of states
needed in a DFA to recognize L?
(a) 2 2012 + 1
(c) 2 2013
(b) 2013
(d) None
Solution: Option (b)
Explanation:

17. The following CFG,


S→ aB/ bA
A→ a/ aS/ bAA
B→ b/ bS/ aBB generates strings with
(a) Odd number of a's & odd number of b’s
(b) Even number of a's & even number of b's
(c) Equal number of a’s & b’s
(d) Odd number of a’s & even number of b’s
Solution: Option (c)
Explanation:
Grammar generates string : “aabb” hence (a) is wrong.
Grammar generates string : “ab” hence (b) is wrong.
Grammar generates string : “aabb” which has even number of “a” hence (d) is wrong.

18. What type of grammar is this most accurately described as?


S→ b/aD
D→ a/aDD
(a) A regular grammar
(c) CSG
(b) CFG
(d) Type-0
Solution: Option (b)
Explanation:
(a) This cannot be regular because regular grammars are of the form A → a, A → aB
(b) It is CFG because all the productions satisfy the constraints, they are of the form A → γ where
γ is a string of terminals and/or non-terminals.
(c) It can be CSG because all the productions are of the form αAβ → αγβ, where α, β, γ are strings
of terminals and/or non-terminals.
(d) It can be Type – 0 or unrestricted grammar, because all productions are of the form α → β (no
restrictions).
But it can be most accurately described as CFG.

19. Consider the following NFA M over the alphabet {0,1}.

Let M 1 be the NFA obtained by interchanging final and non-final states of M. Let the language
accepted by M be L and that accepted by M 1 be L 1 . Choose correct statement:
(a) L 1 = L
(b) L 1 ∩ L 2 = Φ
(c) L 1 ⊆ L 2
(d) L 1 = (0+ 1) *
Solution: Option (d)
Explanation:
By interchanging final and non-final states, we get L 1 = (0 + 1) ∗ .

20. Let M= (Q, ∑, δ, S, F) and M’= (Q, ∑, δ, S, Q – F) where M accepts L and M’ accepts L 1 and
M is NFA, what could be the relation between L and L’ ?
(a) L and L’ are complement to each other
(b) L and L’ are similar to each other
(c) L and L’ relation cannot be predicted
(d) None of the above
Solution: Option (c)
M is an NFA where set F is final state and M' we have Q-F final state, means all the non final state
in NFA M are final states in NFA, M'.

In other words this question says that if we complement an NFA (change all non final states into
final states and vice versa) which accept language L, then do we get automata which accept L' ?
The answer is no in NFA its not true while if M is DFA then it is true. The reason is NFA don't have
dead states so even though if we change all non final states in NFA but the dead state will be not
present hence some string which is suppose to accept in L' will be missed.
If M is a DFA and if language accepted by DFA is L then if we make every non final state as final
state and every final state as non final state then the DFA after modification will accept L' (i.e.
complement of L)\

But M is an NFA and changing final state to non final state and vice versa will not work here ,
hence L and L' don't have any relation.

COMMON DATA QUESTIONS: Q.21, Q.22 AND Q.23, Q.24

21.

The DFA above accepts:


(a) The set of all strings containing two consecutive 1’s
(b) (0+1)*
(c) Set of all strings not containing two consecutive 1’s
(d) Set of all strings containing two consecutive 0’s
Solution: Option (b)

22. The minimal DFA of the above machine has:


(a) 1 State
(c) 3 States
(b) 5 States
(d) 2 States
Solution: Option (a)
Explanation:
The minimal DFA for (0+1)* has 1 state which is given below:
23.

(a) twice as many tigers as lions


(c) more tigers than lions
(b) any number of tigers and lions
(d) unequal number of tigers and lions

Solution: Option (b)

24. The string for which the grammar has maximum of two derivation trees is:
(a) lion tiger lion
(c) tiger lion
(b) lion tiger
(d) None of the above
Solution: Option (d)

You might also like