Test 2 - Theory of Computation | Computer Science(CS)
GATE Previous year Topic Wise Questions and Answers | Theory of Computation
Questions
Consider the following Finite State Automaton:

The language accepted by this automaton is given by the regular expression
- b* ab* ab* ab*
- (a + b)*
- ba (a + b)
- b* ab* ab*
The language {0i 21i | i $\ge$0} over the alphabet {0, 1, 2} is:
- not recursive
- is recursive and is a deterministic CFL.
- is a regular language.
- is not a deterministic CFL but a CFL.
A minimum state deterministic finite automaton accepting the language L = {w | w $\in${0, 1}*, number of 0s and 1s in w are divisible by 3 and 5, respectively} has
- 15 states
- 11 states
- 10 states
- 9 states
Which of the following statements is false?
- Every NFA can be converted to an equivalent DFA
- Every non-deterministic Turing machine can be converted to an equivalent deterministic Turing machine
- Every regular language is also a context-free language
- Every subset of a recursively enumerable set is recursive
Which of the following is true for the language $\left\{ a^p \text{ | p is a prime} \right\} $?
- It is not accepted by a Turing Machine
- It is regular but not context-free
- It is context-free but not regular
- It is neither regular nor context-free, but accepted by a Turing machine
Consider the following Finite State Automaton:

The minimum state automaton equivalent to the above FSA has the following number of states
- 1
- 2
- 3
- 4
Which of the following are decidable?
I. Whether the intersection of two regular languages is infinite
II. Whether a given context-free language is regular
III. Whether two push-down automata accept the same language
IV. Whether a given grammar is context-free
- I and II
- I and IV
- II and III
- II and IV
If L and $\bar L$ are recursively enumerable then L is
- regular
- context-sensitive
- context-free
- recursive
S $\rightarrow$ aSa | bSb | a | b; The language generated by the above grammar over the alphabet {a, b} is the set of
- All palindromes.
- All odd length palindromes.
- Strings that begin and end with the same symbol
- All even length palindromes.
Which one of the following languages over the alphabet {0, 1} is described by the regular expression:
(0 + 1)*0(0 + 1)0(0 + 1)?
- The set of all strings containing the substring 00.
- The set of all strings containing at most two 0's.
- The set of all strings containing at least two 0's.
- The set of all strings that begin and end with either 0 or 1.
Which of the following are regular sets?
I. $\left\{a^nb^{2m} \mid n \geq 0, m \geq 0 \right\}$
II. $\left\{a^nb^m \mid n =2m \right\}$
III. $\left\{a^nb^m \mid n \neq m \right\}$
IV. $ \left\{xcy \mid x, y, \in \left\{a, b\right\} ^* \right\} $
- I and IV only
- I and III only
- I only
- IV only
Which of the following statements are true?
I. Every left-recursive grammar can be converted to a right-recursive grammar and vice-versa
II. All $\epsilon$ productions can be removed from any context-free grammar by suitable transformations
III. The language generated by a context-free grammar all of whose productions are of the form X --> w or X --> wY (where, w is a string of terminals and Y is a non-terminal), is always regular
IV. The derivation trees of strings generated by a context-free grammar in Chomsky Normal Form are always binary trees
- I, II, III and IV
- II, III and IV only
- I, III and IV only
- I, II and IV only
Which of the following languages is regular?
- $\left\\{ww^R \mid w \in \{0, 1\}^+\right\\}$
- $\left\\{ww^Rx \mid x,w \in \{0, 1\}^+\right\\}$
- $\left\\{wxw^R \mid x, w \in \{0, 1\}^+\right\\}$
- $\left\{xww^R \mid x, w \in \{0, 1\}^+\right\}$
Which one of the following is FALSE?
- There is unique minimal DFA for every regular language
- Every NFA can be converted to an equivalent PDA.
- Complement of every context-free language is recursive.
- Every nondeterministic PDA can be converted to an equivalent deterministic PDA.

The above DFA accepts the set of all strings over {0, 1} that
- begin either with 0 or 1
- end with 0
- end with 00
- contain the substring 00.
Match the following NFAs with the regular expressions they correspond to

- $ \epsilon + 0 \left(01^*1+00\right)^*01^*$
- $ \epsilon + 0 \left(10^*1+00\right)^*0$
- $ \epsilon + 0 \left(10^*1+10\right)^*1$
- $ \epsilon + 0 \left(10^*1+10\right)^*10^*$
- P −2, Q −1, R −3, S −4
- P −1, Q −3, R − 2, S − 4
- P − 1, Q − 2, R − 3, S − 4
- P − 3, Q − 2, R − 1, S − 4
Match all items in Group 1 with correct options from those given in Group 2.
| Group 1 | Group 2 |
| P. Regular expression | 1. Syntax analysis |
| Q. Pushdown automata | 2. Code generation |
| R. Dataflow analysis | 3. Lexical analysis |
| S. Register allocation | 4. Code optimization |
- P-4. Q-1, R-2, S-3
- P-3, Q-1, R-4, S-2
- P-3, Q-4, R-1, S-2
- P-2, Q-1, R-4, S-3
Let L = L1 $\cap$ L2, where L1 and L2 are languages as defined below:
L1 = $(a^m b^m\ ca^n b^m | m,n \ge 0)$
L2 = $(a^i b^j\ c^k | i,j \ge 0)$
Then L is
- Not recursive
- Regular
- Context free but not regular
- Recursively enumerable but not context free.
Match the following:
| E. | Checking that identifiers are declared before their use | P. | $L : = : \left\{a^nb^mc^nd^m \mid n: \geq1, m \geq 1\right\}$ | |
| F. | Number of formal parameters in the declaration of a function agrees with the number of actual parameters in a use of that function | Q. | $X: \rightarrow XbX \mid XcX \mid dXf \mid g$ | |
| G. | Arithmetic expressions with matched pairs of parentheses | R. | $L: = \left\{wcw\mid w : \in \left(a\mid b\right)^* \right\}$ | |
| H. | Palindromes | S. | $X : \rightarrow : bXb \mid :cXc : \mid \epsilon $ |
- E −P, F −R, G −Q, H −S
- E −R, F −P, G −S, H −Q
- E −R, F −P, G −Q, H −S
- E −P, F −R, G −S, H −Q
Given the following state table of an FSM with two states A and B, one input and one output:
| Present State A | Present State B | Input | Next State A | Next State B | Output |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 0 | 0 | 1 |
If the initial state is A = 0, B = 0, what is the minimum length of an input string which will take the machine to the state A = 0, B = 1 with Output = 1?
- 3
- 4
- 5
- 6
Given below are two finite state automata (→ indicates the start state and F indicates a final state)
Y:
| a | b | |
|---|---|---|
| $\rightarrow$ 1 | 1 | 2 |
| 2(F) | 2 | 1 |
Z:
| a | b | |
|---|---|---|
| $\rightarrow$ 1 | 2 | 2 |
| 2(F) | 1 | 1 |
Which of the following represents the product automaton Z × Y?
- | | a | b | |-----------------|---|---| | $\rightarrow$ P | S | R | | Q | R | S | | R(F) | Q | P | | S | Q | P |
- || a | b | |-----------------|---|---| | $\rightarrow$ P | S | Q | | Q | R | S | | R(F) | Q | P | | S | P | Q |
- | | a | b | |-----------------|---|---| | $\rightarrow$ P | Q | S | | Q | R | S | | R(F) | Q | P | | S | Q | P |
- || a | b | |-----------------|---|---| | $\rightarrow$ P | S | Q | | Q | S | R | | R(F) | Q | P | | S | Q | P |



















