All mock tests are FREE till 31 December — register to save your progress
Paper 2 CS · UNIT 08 · MOCK TEST

Mock 1 – Finite Automata & Regular Languages (Part 1)

Unit 8: Theory of Computation and Compilers · 25 questions · about 30 minutes. Press End Mock any time to see your score and the correct answers.

All 10 topic-wise mocks in this unit
0 / 25 answered 00:00
Q1. If L1 is a regular language and L2 is a context free language, which of the following statement is correct?
Q2. The minimum state DFA of the following would be the following: (a DFA with states q0 (start), q1, q2, q3 and q4 (accepting) is given, with transitions q0→0 q1, q0→1 q3, q1→0 q1 (self-loop), q1→1 q4, q3→0 q2, q3→1 q4, q2→1 q4, over the alphabet {0,1})

Consider the following Context Free Grammar (G):

S → A B
B → + A B | ε
A → C D
D → * C D | ε
C → [ S ] | x

Variable = { S, A, B, C, D }

Terminals = { +, *, [, ], x }

Q3. Find the Follow (A) & Follow (C).

Consider the following Context Free Grammar (G):

S → A B
B → + A B | ε
A → C D
D → * C D | ε
C → [ S ] | x

Variable = { S, A, B, C, D }

Terminals = { +, *, [, ], x }

Q4. What will be the FIRST(S) & FIRST(D)?
Q5. Consider the following DFA over Σ = {a, b, c}. Start state q0; final states q2, q3, q4, q5. Transitions (any missing transition goes to a dead state):
Stateabc
→ q0q1––
q1q2q3q4
* q2q2q3q4
* q3q5–q3
* q4q0––
* q5q1––
Which of the following NFAs is valid (equivalent) for the given DFA?
Q6. Consider the following DFA over Σ = {a, b, c}. Start state q0, which is also the only final state. Transitions:
Stateabc
→* q0q1q0q0
q1q1q2q0
q2q1q0q3
q3q4q3q3
q4q4q5q3
q5q4q3q0
Which of the following is the best description of the language of this DFA?
Q7. Which of the following is TRUE about the Pumping Lemma for regular languages?
Q8. Which of the following represents the language accepted by the Turing machine with the transition function (δ):
δ(q0, a) = (q1, x, R)
δ(q1, a) = (q1, a, R)
δ(q1, y) = (q1, y, R)
δ(q1, b) = (q2, y, L)
δ(q2, y) = (q2, y, L)
δ(q2, a) = (q2, a, L)
δ(q2, x) = (q0, x, R)
δ(q0, y) = (q3, y, R)
δ(q3, y) = (q3, y, R)
δ(q3, □) = (qf, □, R)

Directions (Q91–95): A machine is represented by states Q, input alphabet Σ, transition function δ, initial state q0 and final states F. The machine accepts all strings over Σ = {a, b} which start and end with any combination of the alphabet symbols, and in which abb occurs as a substring (i.e. the language of all strings over {a, b} containing abb).

Q9. For the above-mentioned passage, which of the following automata is correct? Each option is described by its transitions (start state 1).

Directions (Q91–95): A machine is represented by states Q, input alphabet Σ, transition function δ, initial state q0 and final states F. The machine accepts all strings over Σ = {a, b} which start and end with any combination of the alphabet symbols, and in which abb occurs as a substring (i.e. the language of all strings over {a, b} containing abb).

Q10. For the above specified passage, which of the following represents the grammar for the language accepted by the machine?

Directions (Q91–95): A machine is represented by states Q, input alphabet Σ, transition function δ, initial state q0 and final states F. The machine accepts all strings over Σ = {a, b} which start and end with any combination of the alphabet symbols, and in which abb occurs as a substring (i.e. the language of all strings over {a, b} containing abb).

Q11. Which of the following represents the minimum-state DFA for the above specified passage?

Directions (Q91–95): A machine is represented by states Q, input alphabet Σ, transition function δ, initial state q0 and final states F. The machine accepts all strings over Σ = {a, b} which start and end with any combination of the alphabet symbols, and in which abb occurs as a substring (i.e. the language of all strings over {a, b} containing abb).

Q12. For the above specified passage, which of the following is a DFA for the language accepted by the machine?

Directions (Q91–95): A machine is represented by states Q, input alphabet Σ, transition function δ, initial state q0 and final states F. The machine accepts all strings over Σ = {a, b} which start and end with any combination of the alphabet symbols, and in which abb occurs as a substring (i.e. the language of all strings over {a, b} containing abb).

Q13. For the above specified passage, which of the following represents the regular expression?
Q14. Arrange the following stages of a Turing Machine (TM) operation in the correct order as they occur during computation.
(A) Writing a symbol on the tape
(B) Moving the tape head left or right
(C) Reading a symbol from the tape
(D) Transitioning to a new state based on the current state and symbol read
(E) Halting and accepting or rejecting the input
Choose the correct answer from the options given below:
Q15. Which of the following languages can be recognized by a Non-Deterministic Finite Automaton (NFA) but cannot be recognized by a Deterministic Finite Automaton (DFA)?
(A) L₁ = {w ∈ {0,1}* | the length of w is even}
(B) L₂ = {w ∈ {0,1}* | the length of w is odd}
(C) L₃ = {w ∈ {0,1}* | all 0's come before all 1's in w}
(D) L₄ = {w ∈ {0,1}* | w contains an equal number of 0's and 1's}
(E) L₅ = {w ∈ {0,1}* | all 1's come before all 0's in w}
Q16. Let A = {a, b} and L = A*. Let X = {aⁿbⁿ | n > 0}. The languages L ∪ X and X are respectively:
Q17. The sum of the minimum and maximum number of final states for a DFA having P states is equal to:
Q18. Which of the statements is/are CORRECT?
(A) Moore and Mealy machines are finite state machines with output capabilities.
(B) Any given Moore machine has an equivalent Mealy machine.
(C) Any given Mealy machine has an equivalent Moore machine.
(D) A Moore machine is not a finite state machine.
Choose the correct answer from the options given below:
Q19. Consider a finite automaton F1 with three states C (start), S and E (final), in which there are transitions in both directions between every pair of states (C ⇄ S, S ⇄ E, C ⇄ E). Let F2 be the finite automaton obtained by reversal of F1. Which of the following is correct?
Q20. Which of the following statements is correct?
Q21. For regular languages and context-free languages, which is NOT correct?
A. Both are closed under union
B. Both are closed under concatenation
C. Both are closed under intersection
D. Both are closed under complementation
E. Both are closed under Kleene star
Choose the most appropriate answer from the options given below:
Q22. Arrange in appropriate order the construction of a finite automaton:
A. Minimum-state DFA
B. Regular expression
C. NFA-ε
D. Problem statement
E. DFA
Choose the correct answer from the options given below:
Q23. The language of the following PDA would be:
δ(q0, a, z0) = (q0, aaaz0)
δ(q0, a, a) = (q0, aaaa)
δ(q0, b, a) = (q1, λ)
δ(q1, b, a) = (q1, λ)
δ(q1, ε, z0) = (qf, z0), where qf is the final state.
Q24. For the given two machines over {a, b}, which of the following is correct?
Machine 1: states A (start), B (final); A –a→ A, A –a→ B, B –b→ B, B –b→ A.
Machine 2: states A (start), B (final), C (final); A –a→ B, B –a→ B, B –b→ C, C –b→ C, C –a→ B.
Q25. In the pumping lemma for context-free languages, for a string uvwxy, what is the minimum length of vx together?