FORMAL LANGUAGE & AUTOMATA THEORY
100406Module 1: Introduction & Regular Languages
Q1a. The minimum number of states required to recognize an octal number divisible by 3 is: (i) 1 (ii) 3 (iii) 5 (iv) 720222m
Module 1: Introduction & Regular Languages
View this question on its own page →The minimum number of states required to recognize an octal number divisible by 3 is:
(i) 1
(ii) 3
(iii) 5
(iv) 7Worked SolutionAnswer
Correct Option: (ii) 3
Explanation
To check divisibility by , we only need the remainder modulo 3 of the number. Whether the input is binary, decimal, or octal does not change the number of remainders.
For modulus , there are exactly possible remainders:
- → number divisible by 3 (accepting state)
- → remainder 1
- → remainder 2
DFA Construction for Octal Alphabet
- Alphabet:
- States: representing remainder
- Start state: (value 0)
- Accepting state:
- Transition: On reading octal digit from state ,
Since , this simplifies to .
This DFA is complete and minimal – each remainder is distinguishable (Myhill-Nerode equivalence).
Why other options are wrong
- (i) 1 state: would accept all or no strings, cannot distinguish remainders.
- (iii) 5 and (iv) 7: unnecessary extra states; is not relevant.
Final Answer
Minimum number of states = 3 (one per residue class mod 3).
Q1b. Which of the following is a regular language? (i) Strings whose length is a sequence of prime numbers (ii) Palindrome strings (iii) Strings containing substring ww^r (iv) Strings with even number of 0’s20242m
Module 1: Introduction & Regular Languages
View this question on its own page →Which of the following is a regular language?
(i) Strings whose length is a sequence of prime numbers
(ii) Palindrome strings
(iii) Strings containing substring
(iv) Strings with even number of ’sWorked SolutionAnswer
Correct Option: (iv) Strings with even number of ’s
Explanation
(iv) Even number of ’s — Regular
Language is regular. DFA with 2 states suffices:
- : even count (start, accepting)
- : odd count
.
Regular expression: or .
By Myhill-Nerode, only 2 equivalence classes.
(i) Length is prime — Not regular
. Use Pumping Lemma. Let be pumping length, choose where prime, pump gives length which will be composite for suitable (e.g., ). So not regular. Primes set not ultimately periodic.
(ii) Palindromes — Not regular
Classic non-regular. Requires unbounded stack to compare second half with first reversed. Pumping lemma: in palindrome form fails. Needs PDA, is CFL but not regular.
(iii) Contains as substring — also Not regular
Need to remember arbitrarily long to check follows. This is not regular (can be shown via Myhill-Nerode with infinitely many distinct suffixes). It is context-sensitive.
Final Answer
Only (iv) is regular.
Q1b. Let N be an NFA with n states and let M be the minimized DFA with m states recognizing the same language. Which of the following is necessarily true? (i) m \le 2^n (ii) n \le m (iii) M has one accept state (iv) m = 2^n20232m
Module 1: Introduction & Regular Languages
View this question on its own page →Let be an NFA with states and let be the minimized DFA with states recognizing the same language. Which of the following is necessarily true?
(i)
(ii)
(iii) has one accept state
(iv)Worked SolutionAnswer
Correct Option: (i)
Explanation
NFA → DFA subset construction:
- Each DFA state corresponds to a subset of NFA states.
- With NFA states, there are at most subsets.
- Hence the DFA obtained (before minimization) has states.
- Minimized DFA has number of subset-construction DFA states .
So (i) is always true.
Other options:
- (ii) is false: NFA can be exponentially smaller (e.g., language of from end needs NFA states but DFA states → sometimes, but not necessarily; sometimes DFA is smaller).
- The converse is not guaranteed.
Final Answer
→ Option (i). (Minimized DFA minimal, so is even tighter, but certainly .)
Q1b. For a given Moore machine, given input = 101010, the output would be of length: (i) |Input| + 1 (ii) |Input| (iii) |Input| − 1 (iv) Cannot be predicted20222m
Module 1: Introduction & Regular Languages
View this question on its own page →For a given Moore machine, given input =
101010, the output would be of length:(i) |Input| + 1
(ii) |Input|
(iii) |Input| − 1
(iv) Cannot be predictedWorked SolutionAnswer
Correct Option: (i)
Explanation
Moore Machine: Output depends only on present state, and output is associated with state entry, including the initial state before any input is consumed.
- For input length , the machine visits states: (initial, no input) .
- Each state produces one output symbol .
- Hence output string length = .
Mealy Machine contrast: Output depends on transition (state + input), so output length = = (one per input symbol).
Given input
101010, → Moore output length = .Final Answer
Moore machine output length is → Option (i).
Q1b. Regular languages belong to which type in the Chomsky hierarchy? (i) Type-0 (ii) Type-2 (iii) Type-1 (iv) Type-320252m
Module 1: Introduction & Regular Languages
View this question on its own page →Regular languages belong to which type in the Chomsky hierarchy?
(i) Type-0
(ii) Type-2
(iii) Type-1
(iv) Type-3Worked SolutionAnswer
Correct Option: (iv) Type-3
Explanation
Chomsky Hierarchy (Noam Chomsky, 1956)
Type Language Class Grammar Automaton Type-0 Recursively Enumerable Unrestricted Turing Machine Type-1 Context-Sensitive Context-Sensitive Linear Bounded Automaton Type-2 Context-Free Context-Free Pushdown Automata Type-3 Regular Regular (Left/Right-linear) Finite Automaton (DFA/NFA) Regular languages are the most restricted class, generated by:
- Right-linear grammars:
- Left-linear grammars
- Regular expressions
and recognized by DFA/NFA/ε-NFA.
They are strictly contained:
Final Answer
Regular languages are Type-3 languages. Correct option (iv).
Q1c. The total number of states and transitions required to form a Moore machine that produces residue mod 3 are: (i) 3 and 6 (ii) 3 and 5 (iii) 2 and 4 (iv) 2 and 520222m
Module 1: Introduction & Regular Languages
View this question on its own page →The total number of states and transitions required to form a Moore machine that produces residue mod 3 are:
(i) 3 and 6
(ii) 3 and 5
(iii) 2 and 4
(iv) 2 and 5Worked SolutionAnswer
Correct Option: (i) 3 states and 6 transitions (for residue mod 3 Moore machine)
Explanation
To produce residue mod 3, need 3 states corresponding to remainders .
- Alphabet: e.g., binary or unary? For general input, Moore machine that outputs residue after each symbol needs 3 states.
- Transitions: For binary alphabet , from each of 3 states there are 2 outgoing transitions ( and ): transitions. Formula: new remainder .
If alphabet were unary, transitions =3; but typical exam assumes binary/decimal digit input, hence 6.
Other options (3,5), (2,4) insufficient to represent 3 residues.
Final Answer
3 states, 6 transitions → Option (i). If input alphabet size , transitions .
Q1c. Which of the following languages is NOT regular? (i) {a^n b^n | n \ge 0} (ii) {a, b}* (iii) Finite languages (iv) Languages accepted by DFA20252m
Module 1: Introduction & Regular Languages
View this question on its own page →Which of the following languages is NOT regular?
(i) {}
(ii) {}*
(iii) Finite languages
(iv) Languages accepted by DFAWorked SolutionAnswer
Correct Option: (i)
Explanation
- (ii) → Regular, regex , DFA with 1 state.
- (iii) Finite languages → Regular: any finite set is regular (union of finitely many strings).
- (iv) Languages accepted by DFA → Definition of regular.
- (i) → Classic non-regular. Requires counting unbounded and matching 's with 's. Pumping Lemma: let be pumping length, , pumping (all 's) breaks equality .
It is Context-Free (PDA can push 's, pop for 's) but not regular.
Final Answer
NOT regular is → Option (i).
Q1c. A minimum state deterministic FA accepting the language: L = \{ w \mid w \in \{0,1\}^* \} where the number of 0's and 1's in w are divisible by 3 and 5 respectively, has: (i) 15 states (ii) 11 states (iii) 10 states (iv) 9 states20232m
Module 1: Introduction & Regular Languages
View this question on its own page →A minimum state deterministic FA accepting the language:
where the number of 0's and 1's in are divisible by 3 and 5 respectively, has:
(i) 15 states
(ii) 11 states
(iii) 10 states
(iv) 9 statesWorked SolutionAnswer
Correct Option: (i) 15 states (Other options typically include 8, etc., correct is 15)
Explanation
Language .
This is intersection of two regular languages:
- → DFA with 3 states ().
- → DFA with 5 states ().
Intersection via product construction: states = → states.
Transitions: , .
Initial , accepting only. Minimal because all pairs distinguishable (Myhill-Nerode: $(i,j)
ot\equiv (i',j')i
eq i'j
eq j'$).Final Answer
15 states (product DFA, minimal).
Q1c. NFA has 'non-deterministic' in its name because: (i) The result is undetermined (ii) The choice of path is nondeterministic (iii) The next state is nondeterministic (iv) All of the mentioned20242m
Module 1: Introduction & Regular Languages
View this question on its own page →NFA has 'non-deterministic' in its name because:
(i) The result is undetermined
(ii) The choice of path is nondeterministic
(iii) The next state is nondeterministic
(iv) All of the mentionedWorked SolutionAnswer
Correct Option: (ii) The choice of path is nondeterministic (and equivalently (iii); if “All of the mentioned” is offered, (iv) is also defensible)
Explanation
Deterministic FA: — exactly one next state for each .
Nondeterministic FA: — a set of possible next states. The machine may:
- be in several states simultaneously (subset view), or
- guess a path.
So “non-deterministic” means:
- Next state is not uniquely determined → (iii)
- Choice of computation path is nondeterministic → (ii)
The “result” (accept/reject) is determined (exists some accepting path ⇔ accept), so (i) “result undetermined” is misleading.
In many textbooks the canonical answer is (ii) Choice of path is nondeterministic (or (iii)). If option (iv) “All of the mentioned” lumps (ii)+(iii), some keys mark (iv) as correct.
Formal
, . On input , accepts iff there exists a path .
Final Answer
NFA is nondeterministic because the next state / path is not uniquely determined → Option (ii) (and (iii)).
Q1d. Which of the following is NOT a component of a finite automaton? (i) States (ii) Input alphabet (iii) Transition function (iv) Output tape20242m
Module 1: Introduction & Regular Languages
View this question on its own page →Which of the following is NOT a component of a finite automaton?
(i) States
(ii) Input alphabet
(iii) Transition function
(iv) Output tapeWorked SolutionAnswer
Correct Option: (iv) Output tape (is NOT a component)
Explanation
Finite Automaton (DFA/NFA) formal definition:
Components:
- : Finite set of states
- : Input alphabet
- : Transition function (or for NFA)
- : Start state
- : Set of accepting states
Output tape belongs to Turing Machine or Transducer (Mealy/Moore), not to basic finite automaton. FA has no output tape; it only accepts/rejects.
Note: and stack are for PDA, tape for TM.
Final Answer
Output tape is not a component of FA → Option (iv).
- Install PocketlyBudget App•POCKETLY
Pocketly on Android
Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.
Q1d. Which of the following is a correct statement? (i) Moore machine has no accepting states. (ii) Mealy machine has accepting states. (iii) We can convert Mealy to Moore but not vice versa. (iv) All of the above20222m
Module 1: Introduction & Regular Languages
View this question on its own page →Which of the following is a correct statement?
(i) Moore machine has no accepting states.
(ii) Mealy machine has accepting states.
(iii) We can convert Mealy to Moore but not vice versa.
(iv) All of the aboveWorked SolutionAnswer
Correct Option: (i) Moore machine has no accepting states (in transducer sense; strictly all (i)-(iii) as stated are inaccurate, so if “None of the above” were an option it would be correct — see note)
Explanation
Moore vs Mealy as Transducers
- Moore: Output (state output). Mealy: (transition output).
- In classical transducer definition (Hopcroft-Ullman), they are not acceptors — they have no set. They translate every input to an output, not accept/reject. In that sense (i) “Moore has no accepting states” is true for the pure transducer, and similarly Mealy also has none, making (ii) false.
Convertibility
- Mealy ↔ Moore are interconvertible:
- Mealy → Moore: expand states (at most ), output delayed by one symbol.
- Moore → Mealy: keep same states, shift output to transitions.
- So (iii) “Mealy to Moore but not vice versa” is false. Both directions possible.
Evaluation
Statement Truth (i) Moore has no accepting states (pure transducer) True (ii) Mealy has accepting states False (pure Mealy also has none) (iii) Mealy→Moore only one way False (iv) All of above False If the question is asked in the acceptor + transducer mixed sense where Moore/Mealy can be defined with , then (i) and (ii) are both false and no option is strictly correct; the intended exam key is usually (i).
Final Answer
Per standard syllabus, (i) is the expected correct choice. Rigorously, pure Moore/Mealy are transducers without , and they are mutually convertible.
Q1d. The maximum number of states of a DFA converted from an NFA with n states is: (i) n (ii) n^2 (iii) 2^n (iv) None of the above20212m
Module 1: Introduction & Regular Languages
View this question on its own page →The maximum number of states of a DFA converted from an NFA with states is:
(i)
(ii)
(iii)
(iv) None of the aboveWorked SolutionAnswer
Correct Option: (iii)
Explanation
NFA with states → DFA via subset construction:
Each DFA state is a subset of NFA states. NFA states set , .
Number of distinct subsets = .
This includes (dead state).
Hence DFA has at most states. Upper bound is tight: there exist NFA families (e.g., language “th symbol from end is 1”) that require exactly DFA states.
Final Answer
Maximum states → Option (iii). (Minimal DFA may be smaller, but maximum is .)
Q1e. A DFA can have: (i) Multiple start states (ii) Multiple accepting states (iii) Transitions on \varepsilon (iv) None of the above20242m
Module 1: Introduction & Regular Languages
View this question on its own page →A DFA can have:
(i) Multiple start states
(ii) Multiple accepting states
(iii) Transitions on
(iv) None of the aboveWorked SolutionAnswer
Correct Option: (ii) Multiple accepting states
Explanation
DFA definition:
- : Exactly one start state → (i) multiple start states false. (NFA can have multiple, DFA has one).
- : Set of final/accepting states. Can be 0, 1, or multiple → (ii) true. Example even number of 0's DFA has 1 accept, but language needs 1, language “ends with 00 or 11” needs 2.
- Transitions: is total deterministic, no -moves. -transitions allowed only in -NFA → (iii) false.
Final Answer
DFA can have multiple accepting states → Option (ii).
Q1e. The minimum number of transitions to reach the final state as per the regular expression: \{a, b\}^* baaa is: (i) 4 (ii) 5 (iii) 6 (iv) 320222m
Module 1: Introduction & Regular Languages
View this question on its own page →The minimum number of transitions to reach the final state as per the regular expression:
is:
(i) 4
(ii) 5
(iii) 6
(iv) 3Worked SolutionAnswer
Correct Option: (i) 4
Explanation
Regular expression: — language is all strings over ending with suffix baaa.
To accept, a DFA must detect suffix b a a a (length 4).
Minimal DFA (suffix automaton)
States represent longest suffix of processed prefix that is prefix of baaa:
- : no part matched (or last irrelevant)
- : suffix b
- : suffix ba
- : suffix baa
- : suffix baaa (accepting)
Transitions: each new character extends/collapses the match. From , on b → , on a → ; etc.
Number of transitions on the shortest path from start to final is 4 (b→a→a→a).
Number of states =5, transitions to reach final =4. Some keys count states=5 as “transitions”, but minimum edge traversals is 4.
Final Answer
4 transitions (5 states) to reach final — Option (i) 4. If counting states, answer is 5.
Q1e. The string 1101 does not belong to the set represented by: (i) 1^* 0^* (0+1) (ii) 1(0+1)^*101 (iii) (1(0)^*(0+1)^*(0+1))^* (iv) \{00 + (11)^*0\}^*20232m
Module 1: Introduction & Regular Languages
View this question on its own page →The string does not belong to the set represented by:
(i)
(ii)
(iii)
(iv)Worked SolutionAnswer
Correct Option: (iv)
Explanation
Test against each regex:
(i) : = then then single or . → belongs.
(ii) : Must start with and end with . ? Actually = + + with middle ? where ? For , ? Wait exactly, so ? No with ? , remaining → → belongs.
(iii) : This is essentially variant (can generate any string) → belongs.
(iv) : Generators: (ends 0) and = even 1's followed by 0, also ends 0. Any concatenation of blocks ending in 0 always ends in 0. ends in 1 → does not belong.
Final Answer
$1101
otin {00 + (11)^0}^$ → Option (iv).Q1f. Let w = xyz, y is the middle portion and |y| > 0. Repeating y zero or more times before checking membership in L is known as: (i) Generating (ii) Pumping (iii) Producing (iv) None of the above20222m
Module 1: Introduction & Regular Languages
View this question on its own page →Let , is the middle portion and . Repeating zero or more times before checking membership in is known as:
(i) Generating
(ii) Pumping
(iii) Producing
(iv) None of the aboveWorked SolutionAnswer
Correct Option: (ii) Pumping
Explanation
Pumping Lemma concept: For regular/CFL languages, any long string (with , ) can be pumped: for all (repeating zero, one, or more times).
- Pumping = repeating the middle portion zero or more times and checking membership.
- Generating is general derivation.
- Producing is vague.
The lemma is used to prove non-regularity/non-CFL by contradiction.
Final Answer
Repeating is Pumping → Option (ii).
Q1f. Which of the following is a type of grammar in the Chomsky hierarchy? (i) Regular (ii) Context-Free (iii) Context-Sensitive (iv) All of the above20242m
Module 1: Introduction & Regular Languages
View this question on its own page →Which of the following is a type of grammar in the Chomsky hierarchy?
(i) Regular
(ii) Context-Free
(iii) Context-Sensitive
(iv) All of the aboveWorked SolutionAnswer
Correct Option: (iv) All of the above
Explanation
Chomsky Hierarchy classifies grammars into 4 types:
Type Name Production Form Language Class Type-0 Unrestricted , no restriction Recursively Enumerable (TM) Type-1 Context-Sensitive , with context CSL (LBA) Type-2 Context-Free , CFL (PDA) Type-3 Regular , Regular (FA) - (i) Regular → Type-3 ✓
- (ii) Context-Free → Type-2 ✓
- (iii) Context-Sensitive → Type-1 ✓
All three are in Chomsky hierarchy (Type-0 is the super-set).
Final Answer
All are types → Option (iv) All of the above.
Q1g. For an NFA with n states, the minimized DFA has: (i) m \le 2^n (ii) n \le m (iii) one accept state (iv) m = 2^n20212m
Module 1: Introduction & Regular Languages
View this question on its own page →For an NFA with states, the minimized DFA has:
(i)
(ii)
(iii) one accept state
(iv)Worked SolutionAnswer
Correct Option: (i)
Explanation
Same as Q28 / Q87: Subset construction.
NFA states → DFA has at most subsets. Minimized DFA ≤ subset DFA ≤ .
- (ii) is not necessarily true (NFA can be smaller).
- (iv) is not always (upper bound, but often smaller).
- (iii) one accept state is false (can be multiple).
Final Answer
→ Option (i).
Q1g. If \Sigma = \{a, b\}, then \Sigma^* contains (i) Only finite strings (ii) Only infinite strings (iii) All finite strings over \Sigma including \epsilon (iv) Only strings of equal length20252m
Module 1: Introduction & Regular Languages
View this question on its own page →If , then contains
(i) Only finite strings
(ii) Only infinite strings
(iii) All finite strings over including
(iv) Only strings of equal lengthWorked SolutionAnswer
Correct Option: (iii) All finite strings over including
Explanation
Definition: , where , , , ...
For :
- (empty string, length 0) ∈
- ∈
- ∈
- … all finite concatenations.
Properties:
- Countably infinite set.
- Does not contain infinite strings (each string is finite; there are infinitely many strings, but each has finite length).
- Not limited to equal length.
Options:
- (i) Only finite strings but missing → incomplete
- (ii) Only infinite strings → false
- (iv) Only equal length → false
Final Answer
All finite strings including → Option (iii).
Q1h. The \epsilon-closure of a state is (i) The set of states reachable using \epsilon only (ii) The set of unreachable states (iii) The set of final states (iv) The dead states20252m
Module 1: Introduction & Regular Languages
View this question on its own page →The -closure of a state is
(i) The set of states reachable using only
(ii) The set of unreachable states
(iii) The set of final states
(iv) The dead statesWorked SolutionAnswer
Correct Option: (i) The set of states reachable using only
Explanation
-closure for NFA-:
— all states reachable from by zero or more -moves, including itself.
Example: → ECLOSE() = .
Used in subset construction for -NFA → DFA/NFA conversion: .
Other options are incorrect: not unreachable, not just finals, not dead states.
Final Answer
-closure = states via only → Option (i).
- Install PocketlyBudget App•POCKETLY
Pocketly on Android
Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.
Q1i. A minimum state DFA for the language: L = \{ w \in \{0,1\}^* : \#0(w) \equiv 0 \mod 3,\; \#1(w) \equiv 0 \mod 5 \} has: (i) 15 states (ii) 11 states (iii) 10 states (iv) 9 states20212m
Module 1: Introduction & Regular Languages
View this question on its own page →A minimum state DFA for the language:
has:
(i) 15 states
(ii) 11 states
(iii) 10 states
(iv) 9 statesWorked SolutionAnswer
Correct Option: (i) 15 states
Explanation
Language is same as Q92 / Q112.
As before: DFA for needs 3 states, for needs 5 states. Product → minimal states.
Transitions: .
Other options 11,10,9 would be for different moduli (e.g., 3+5=8) — incorrect; must multiply, not add.
Final Answer
15 states → Option (i).
Q1i. Which of these represents a regular language? (i) \{ a^n b^n \mid n \ge 0 \} (ii) Strings with equal number of a’s and b’s (iii) \{ a^n \mid n \text{ is prime} \} (iv) \{ w \mid w \text{ starts with 'a' and ends with 'b'} \}20242m
Module 1: Introduction & Regular Languages
View this question on its own page →Which of these represents a regular language?
(i)
(ii) Strings with equal number of ’s and ’s
(iii)
(iv)Worked SolutionAnswer
Correct Option: (iv)
Explanation
Test each:
- (i) → Not regular (needs stack, CFL).
- (ii) Equal number of 's and 's → not regular (needs counting). Pumping fails.
- (iii) → Not regular (non-periodic), also not CFL.
- (iv) Starts with a and ends with b → Regular.
DFA for (iv): 3 states
- start (no symbol yet, non-accepting)
- = last symbol a? Actually needs start a, so , .
- = seen start a, last is a (non-accepting)
- = seen start a, last is b (accepting)
Transitions: , , , .
Regular expression: (plus handle length 1? Actually inclusive). More precisely .
Hence regular.
Final Answer
Only (iv) is regular.
Q1j. If P and Q are regular expressions (P is not null), then R = Q + RP has the unique solution: (i) R = QP (ii) R = PQ^* (iii) R = QP^* (iv) R = QP^*20232m
Module 1: Introduction & Regular Languages
View this question on its own page →If and are regular expressions ( is not null), then has the unique solution:
(i)
(ii)
(iii)
(iv)Worked SolutionAnswer
Correct Option: (iii) (Arden’s Theorem)
Explanation
Arden’s Theorem: If does not contain , then equation has unique solution .
Proof: . As , contributes no finite strings if language, so .
- (i) missing star → incomplete.
- (ii) swaps order (concatenation not commutative).
- (iv) duplicate of (iii).
Condition: not null ($\epsilon
otin P$) ensures uniqueness.Final Answer
→ Option (iii) (also (iv) if duplicate).
Q1j. The construction time for DFA from NFA with m nodes is: (i) O(m^2) (ii) O(2^m) (iii) O(m) (iv) O(\log m)20212m
Module 1: Introduction & Regular Languages
View this question on its own page →The construction time for DFA from NFA with nodes is:
(i)
(ii)
(iii)
(iv)Worked SolutionAnswer
Correct Option: (ii)
Explanation
NFA with states → DFA via subset construction:
Number of DFA states in worst case, and constructing each state requires processing transitions for each symbol ().
Time is proportional to number of subsets times alphabet:
(If counting edges, but dominant exponential.)
Options:
- — polynomial, false for NFA→DFA
- — linear, false
- — false
Final Answer
→ Option (ii).
Q2a. Design a DFA for strings over \{a, b\} containing at least three occurrences of bbb (overlapping allowed). Example: bbbbbb is accepted.20227m
Module 1: Introduction & Regular Languages
View this question on its own page →Design a DFA for strings over containing at least three occurrences of
bbb(overlapping allowed). Example:bbbbbbis accepted.Worked SolutionAnswer
Design a DFA for at least three occurrences of substring
bbb(overlapping allowed). Examplebbbbbbaccepted.1. Language
.
Occurrences are counted with overlap:
bbbbcontains 2 occurrences (bbbat positions 1-3 and 2-4),bbbbbbcontains 4 occurrences.We need to count up to 3 and stay in accepting state after.
2. Construction Idea
Track:
- suffix of consecutive 's (0,1,2) and number of seen so far (0,1,2,≥3).
States: where = trailing run capped at 2, = count of seen (0-2, ≥3). But we can compress to 7 states:
State Meaning , trailing ’s no yet, ends with or start , ends with () , ends with () , seen 1 , ends with (c=3→2) , + ends with (after ) , ? etc. Simpler: count after detection seen 2 seen ≥3 (accepting, trap) Simplified minimal DFA with 7 states (–, accepting):
Transitions (partial, showing -chain):
q0 --a--> q0 , q0 --b--> q1 q1 --a--> q0 , q1 --b--> q2 q2 --a--> q0 , q2 --b--> q3 // first bbb detected, k=1 q3 --a--> q4 , q3 --b--> q5 // bbbb: overlapping second bbb (q3 --b--> q5) q4 --a--> q0 , q4 --b--> q1? Actually after a, reset; need systematic.Full systematic table (compressed):
State (1 with reset) ? For exam, you can draw diagram:
MermaidDiagramRendering diagram…Set initial , final .
Test:
bbbbbb:
→ accepted (4 occurrences ≥3).3. Minimality
states are minimal (need to distinguish counts 0,1,2 and trailing run). Could be reduced to 6 with optimization but 7 is clear for exam.
Final Answer
DFA with 7 states, one accepting trap that counts overlapping occurrences ≥3, as above. Regular expression: (overlap makes regex messy, DFA preferred).
Q2a. Discuss the Chomsky hierarchy of grammars with suitable examples.20237m
Module 1: Introduction & Regular Languages
View this question on its own page →Discuss the Chomsky hierarchy of grammars with suitable examples.
Q2a. What is Automata? Explain classification of Automata.20247m
Module 1: Introduction & Regular Languages
View this question on its own page →What is Automata? Explain classification of Automata.
Worked SolutionAnswer
1. What is Automata?
Automata (plural of Automaton) is an abstract mathematical model of computation. It is a finite representation of an infinite computation that reads input symbols, changes states according to transition rules, and decides acceptance. It is the theoretical foundation for compiler design, lexical analysis, and computability.
Formally, automaton = (Input + Finite Control + Memory + Output/Acceptance).
No physical infinite hardware is needed; the model studies what can be computed with given memory.
2. Classification of Automata
Classification follows memory power and matches Chomsky hierarchy:
MermaidDiagramRendering diagram…A. Finite Automata (FA) — Type-3, Regular
- Memory: Only finite control (), no auxiliary memory.
- Types: DFA (), NFA, -NFA (all equivalent).
- Power: Regular languages. Example: , .
- Use: Lexical analyzer, pattern matching.
B. Pushdown Automata (PDA) — Type-2, Context-Free
- Memory: Stack (LIFO). .
- Types: DPDA vs NPDA (different power).
- Power: CFLs. Example: , balanced parentheses, arithmetic expressions.
- Use: Syntax analysis (parsing).
C. Linear Bounded Automaton (LBA) — Type-1, Context-Sensitive
- Memory: Tape bounded by input length (plus two endmarkers). Can read/write but not beyond bounds.
- Power: CSLs. Example: , .
- Use: Rare in practice, studies context-sensitive features.
D. Turing Machine (TM) — Type-0, RE
- Memory: Infinite tape, read/write head, finite control.
- Types: Deterministic, Nondeterministic, Multi-tape, Universal (all equivalent in power).
- Power: Recursively Enumerable (Type-0) and Recursive (Decidable) with always-halting variant.
- Example: , Halting, any computable function.
- Use: Model of general-purpose computer.
Summary Table
Automaton Memory Grammar Type Language Decidability FA (DFA/NFA) Type-3 Regular Regular Decidable (all properties) PDA + Stack Type-2 CFG CFL Emptiness decidable, equivalence undecidable LBA + tape Type-1 CSG CSL Membership decidable () TM + tape Type-0 unrestricted RE Halting undecidable Hierarchy: and .
Final Answer
Automata are abstract computing models; classification by memory gives FA → PDA → LBA → TM corresponding to Chomsky Types 3→2→1→0.
Q2a. Tabulate the Chomsky hierarchy of grammars with an example for each.20217m
Module 1: Introduction & Regular Languages
View this question on its own page →Tabulate the Chomsky hierarchy of grammars with an example for each.
Worked SolutionAnswer
Chomsky Hierarchy of Grammars
Type Grammar Name Production Form Language Class Automaton Type-0 Unrestricted No restriction on (except $\alpha eq \epsilon$) Recursively Enumerable (RE) Turing Machine Type-1 Context-Sensitive , has in context Context-Sensitive (CSL) Linear Bounded Automaton Type-2 Context-Free , , Context-Free (CFL) Pushdown Automaton (PDA) Type-3 Regular / Right-Linear (or left-linear) Regular (REG) Finite Automaton (DFA/NFA) Examples
Type Example Grammar Language Generated Type-0 with unrestricted rules e.g. or any computable language Type-1 , , , , , Type-2 (balanced parentheses) Type-2 Balanced parentheses language Type-3 (all binary strings) Type-3 , (right-linear) Containment Relations
Each level strictly contained in the next (proper subsets).
Notes
- Type-0 = RE = recognized by TM; not all decidable.
- Type-1 = CSL = decided by LBA (PSPACE-complete membership).
- Type-2 = CFL = parsed in (CYK); inherently ambiguous CFLs exist.
- Type-3 = REG = recognized by FA/DFA; all decidable properties.
Final Answer
Table above summarizes all four Chomsky types with production forms, language classes, automata, and concrete grammar examples.
Q2b. Tabulate the Chomsky hierarchy of grammars with an example of each.20247m
Module 1: Introduction & Regular Languages
View this question on its own page →Tabulate the Chomsky hierarchy of grammars with an example of each.
Q2b. Let L \subseteq \{0,1,2\}^* be strings without consecutive identical symbols (no 00, no 11, no 22). Design a DFA for L.20227m
Module 1: Introduction & Regular Languages
View this question on its own page →Let be strings without consecutive identical symbols (no , no , no ). Design a DFA for .
Worked SolutionAnswer
Language:
DFA Construction
Idea: Track the last symbol seen (0, 1, or 2) or "none yet" (start). Forbid transition on same symbol as last.
States:
- : start, no symbol yet (also accepting)
- : last symbol was 0 (accepting)
- : last symbol was 1 (accepting)
- : last symbol was 2 (accepting)
- : dead/reject state (non-accepting)
Alphabet:
Transition Function :
State Input 0 1 2 Formal DFA: where
- initial
- (all except dead)
- as table above
State Diagram (Mermaid)
MermaidDiagramRendering diagram…Regular Expression (for verification)
More compactly using complement:Test Cases
Input Path Accept? Yes Yes Yes No Yes Yes Minimality
5 states are minimal (Myhill-Nerode: are pairwise distinguishable; dead state needed).
Final Answer
DFA with 5 states (), accepting all except , transitions as table above. Rejects any string with or .
- Install PocketlyBudget App•POCKETLY
Pocketly on Android
Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.
Q2b. Explain the Chomsky hierarchy of languages with examples.20257m
Module 1: Introduction & Regular Languages
View this question on its own page →Explain the Chomsky hierarchy of languages with examples.
Worked SolutionAnswer
Chomsky Hierarchy (Noam Chomsky, 1956) classifies formal grammars and their languages by production rule restrictions into 4 types, forming a strict containment hierarchy.
Hierarchy Overview
Type Name Production Form Language Class Recognizing Automaton Type-0 Unrestricted , , $\alpha eq \epsilon$ Recursively Enumerable (RE) Turing Machine (TM) Type-1 Context-Sensitive , with context Context-Sensitive (CSL) Linear Bounded Automaton (LBA) Type-2 Context-Free , , Context-Free (CFL) Pushdown Automaton (PDA) Type-3 Regular (right-linear) or (left-linear) Regular (REG) Finite Automaton (DFA/NFA) Containment:
Each is a proper subset of the next.
Detailed Explanation with Examples
Type-3: Regular Languages
- Grammar: Right-linear () or Left-linear.
- Automaton: DFA/NFA/-NFA (equivalent power).
- Properties: Closed under union, intersection, complement, concatenation, star. Membership in .
- Example 1:
- Grammar: ,
- Example 2: Binary strings with even number of 1's:
- DFA: 2 states tracking parity
Type-2: Context-Free Languages (CFL)
- Grammar: (single non-terminal LHS).
- Automaton: PDA (NPDA > DPDA in power).
- Properties: Closed under union, concat, star. Not closed under intersection, complement. Parsing (CYK).
- Example 1: (matching counts)
- Grammar:
- PDA: push 's, pop for 's
- Example 2: Balanced parentheses
- Grammar:
- Example 3: (palindromes)
- NPDA guesses middle
Type-1: Context-Sensitive Languages (CSL)
- Grammar: , productions like (context around ).
- Automaton: LBA = TM with tape bounded by .
- Properties: Membership decidable (PSPACE-complete). Closed under union, intersection, complement.
- Example:
- Grammar: , , , , ,
- Generates by expanding and reordering
Type-0: Recursively Enumerable (RE)
- Grammar: No restrictions (unrestricted).
- Automaton: Turing Machine (TM).
- Properties: Not closed under complement. Halting problem undecidable. Semi-decidable.
- Example: (Halting problem)
- Note: All computable languages are RE; recursive (decidable) are subset where TM always halts.
Summary Table with Examples
Type Language Grammar Example Automaton 3 (REG) DFA 3 (REG) , DFA (2 states) 2 (CFL) PDA 2 (CFL) NPDA 1 (CSL) (as above) LBA 0 (RE) Halting Problem Unrestricted TM
Practical Implications
- Type-3: Lexical analysis, regex matching
- Type-2: Syntax analysis (parsers), programming language grammars
- Type-1: Rare in practice; natural language features
- Type-0: Theoretical limits, computability
Final Answer
Chomsky hierarchy organizes languages by grammar restrictiveness: Type-3 (Regular) ⊂ Type-2 (CFL) ⊂ Type-1 (CSL) ⊂ Type-0 (RE), each with corresponding automaton (FA, PDA, LBA, TM). Examples: REG → DFA, CFL → PDA, CSL → LBA, RE → TM.
Q2b. Design a finite-state machine (FSM) for a parity checker.20217m
Module 1: Introduction & Regular Languages
View this question on its own page →Design a finite-state machine (FSM) for a parity checker.
Worked SolutionAnswer
Parity Checker FSM: Checks if number of
1s in input is even (even parity) or odd (odd parity). Common use: error detection in communication.Assumptions
- Input alphabet: (binary stream)
- Output: Even (0) or Odd (1) parity bit after each input, or final parity at end
- We present Moore and Mealy versions
1. Moore Machine (Output on State)
States:
- : Even number of 1's seen so far (initial, accepting for even parity)
- : Odd number of 1's seen so far
Output function :
- (even parity)
- (odd parity)
Transition function :
State Input 0 Input 1 State Diagram:
0 ┌────┐ │ ▼ (E)───►(O) ▲ │ └───1- On
0: stay in same parity state - On
1: flip parity
Formal Moore:
- , ,
2. Mealy Machine (Output on Transition)
States: (same states, no output on states)
Output on transition:
Transition Input Next State Output 0 0 1 1 0 1 1 0 State Diagram:
0/0 ┌─────┐ │ ▼ (E)──►(O) │1/1 │0/1 └─────1/0Formal Mealy: with .
3. Even Parity Generator (Output at End)
If only final parity needed (not running):
- Run Moore/Mealy above
- After last input, output (Moore) or last transition output (Mealy)
- Even parity = 0 if even # of 1's, 1 if odd
Test Sequence
Input Moore State Seq Moore Output Seq Mealy Output Seq 1011 0,1,1,1,0 1,1,1,0 Even # 1s: 1100 → ends in E, output 0 Odd # 1s: 110 → ends in O, output 1
Final Answer
Parity Checker FSM — 2-state Moore/Mealy machine tracking even/odd count of 1's.
- Moore: Output = state parity (E→0, O→1)
- Mealy: Output on each transition (flip on 1, hold on 0)
- Transitions:
0= stay,1= flip - Minimal: 2 states (even/odd are distinguishable)
Q3a. Construct an NFA accepting strings over \{0,1,2\} beginning with 0, followed by an odd number of 1s, ending with any number of 2s.20217m
Module 1: Introduction & Regular Languages
View this question on its own page →Construct an NFA accepting strings over beginning with 0, followed by an odd number of 1s, ending with any number of 2s.
Worked SolutionAnswer
Language:
Structure: starts with 0 → odd number of 1's → any number of 2's.
NFA Design
NFA:
- = start
- (final)
States meaning:
- : initial, expecting leading
0 - : saw
0, read first1(odd count = 1) - : in even number of 1's (after 2nd, 4th, ...)
- : in odd number of 1's (after 1st, 3rd, ...) — can transition to 2's
Transition Function
State Input Next State(s) No other transitions (missing transitions = dead/implicit reject).
State Diagram
0 ┌───────┐ │ ▼ (q0)──►(q1)──1──►(q2) │ ▲ │ │ │ │ └────1 │ 2 │ ▼ │ │ (q3)◄──2─────┘ 2
How It Works
Input Path Accept? 01→ no (ends in , even 1's) 011→ yes () 0111→ no (even) 012→ no ( has no 2-transition) 0112→ yes 01112→ no 01122→ yes 0→ no (no 1's, count=0 even)
Equivalent DFA (via Subset Construction)
States = subsets of NFA states:
- (accepting)
- Dead =
But NFA is simpler and sufficient.
Regular Expression
Verification:
01= ✓0111= ✓011122= ✓
Final Answer
NFA with 4 states ():
- (leading 0)
- (toggle odd/even 1's)
- (odd 1's → can start 2's)
- (any number of 2's)
- Final =
- Accepts exactly.
Q3a. Construct DFA for all strings over \{0,1\} interpreted as binary numbers divisible by 4.20247m
Module 1: Introduction & Regular Languages
View this question on its own page →Construct DFA for all strings over interpreted as binary numbers divisible by .
Worked SolutionAnswer
Language:
Interpret string as binary number (most significant bit first), check divisibility by 4.
Key Observation
A binary number is divisible by 4 iff its last two bits are 00 (or the string is just "0" or empty, treated as 0).
- Binary ends in
00. - Special case: empty string and
"0"represent 0, divisible by 4.
DFA Construction (4 states)
Track value modulo 4. States = residues .
DFA:
- where = value
- = start (value 0)
- (residue 0)
Transition: On input bit :
Transition Table:
State \ Input 0 1 (0) (1) (2) (3) Derivation:
State Diagram
MermaidDiagramRendering diagram…
Simplified 3-State DFA (Using Last-Two-Bits Insight)
Since divisibility by 4 depends only on last 2 bits =
00:DFA with 3 states:
- : start, also accept (0 or empty or ...00)
- : last bit = 1
- : last bit = 0, previous ≠ 0 (i.e., ends in
10)
State \ Input 0 1 (accept) . = last two bits
00(or empty/"0").Why 3 states minimal: Myhill-Nerode: are pairwise distinguishable mod 4.
Test Cases
Input Value Path Accept? 0 Yes 00 Yes 1004 Yes 10008 Yes 102 No ($q_2 otin F$) 1015 No 110012 ends in Yes
Regular Expression
(All strings ending in
00plus the single0; can be included as(0+1)*00 | 0 | \epsilon)
Final Answer
DFA with 4 states (mod 4 tracking) or minimal 3 states:
- States: residues 0,1,2,3 (or 3-state:
00, ends-in-1, ends-in-10) - Transitions:
- Accept: only
- Binary divisible by 4 ⇔ ends in
00(or is0/ε)
DFA(3 states): q0 --0--> q0 q0 --1--> q1 q1 --0--> q2 q1 --1--> q1 q2 --0--> q0 q2 --1--> q1 Accept: q0- Binary ends in
Q3b. Construct DFA that accepts strings over \Sigma = \{a,b\} which start with aba.20247m
Module 1: Introduction & Regular Languages
View this question on its own page →Construct DFA that accepts strings over which start with .
Q3b. Given the regular expression: (0+1)^*01(0+1) Describe the language generated, and construct an equivalent DFA.20257m
Module 1: Introduction & Regular Languages
View this question on its own page →Given the regular expression:
Describe the language generated, and construct an equivalent DFA.
Q4a. Design Mealy and Moore machines to detect the sequence 1010 (overlapping allowed). Then convert the Moore machine into a Mealy machine and prove equivalence.20227m
Module 1: Introduction & Regular Languages
View this question on its own page →Design Mealy and Moore machines to detect the sequence
1010(overlapping allowed). Then convert the Moore machine into a Mealy machine and prove equivalence.Q4a. Prove that L = \{ a^i b^i \mid i \ge 0 \} is not regular using the pumping lemma.20247m
Module 1: Introduction & Regular Languages
View this question on its own page →Prove that is not regular using the pumping lemma.
Q4a. Given a DFA D over the alphabet {a, b}, perform DFA minimization and draw the equivalent minimal DFA accepting the same language. 20257m
Module 1: Introduction & Regular Languages
View this question on its own page →Given a DFA D over the alphabet {a, b}, perform DFA minimization and draw the equivalent minimal DFA accepting the same language.

Q4b. Convert the following NFA to DFA. 20247m
Module 1: Introduction & Regular Languages
View this question on its own page →Convert the following NFA to DFA.

- Install PocketlyBudget App•POCKETLY
Pocketly on Android
Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.
Q4b. Design a DFA for the regular expression: 1^*(10)^*20217m
Module 1: Introduction & Regular Languages
View this question on its own page →Design a DFA for the regular expression:
Q4b. Use the pumping lemma to prove that the language L = \{a^n b^n : n \ge 1\} is not regular.20257m
Module 1: Introduction & Regular Languages
View this question on its own page →Use the pumping lemma to prove that the language is not regular.
Q4b. Obtain the regular expression for the given DFA. 20237m
Module 1: Introduction & Regular Languages
View this question on its own page →Obtain the regular expression for the given DFA.

Q5a. Prove that if L_1 and L_2 are regular, then L_1 \cup L_2 is regular.20237m
Module 1: Introduction & Regular Languages
View this question on its own page →Prove that if and are regular, then is regular.
Q5a. Give examples of L_1 and L_2 such that: (i) L_1 is regular, L_2 is not regular, and L_1 - L_2 is regular. (ii) L_1 and L_2 are not regular but L_1 \cup L_2 is regular.20227m
Module 1: Introduction & Regular Languages
View this question on its own page →Give examples of and such that:
(i) is regular, is not regular, and is regular.
(ii) and are not regular but is regular.Q5b. Construct an NFA that accepts all strings over the alphabet {0, 1, 2} that begin with one or more 0s, followed by an odd number of 1s, and end with any number of 2s.20257m
Module 1: Introduction & Regular Languages
View this question on its own page →Construct an NFA that accepts all strings over the alphabet {0, 1, 2} that begin with one or more 0s, followed by an odd number of 1s, and end with any number of 2s.
Q5b. Show that the language of palindromes over \{a, b\} is not regular.20227m
Module 1: Introduction & Regular Languages
View this question on its own page →Show that the language of palindromes over is not regular.
Q6a. Given the \varepsilon-NFA, compute \varepsilon-closures and convert to DFA. | State | \varepsilon-transition | a-transition | b-transition | |-------|--------------------------|--------------|--------------| | → | {r} | {q} | {p,r} | | q | ∅ | {p} | ∅ | | r | {p,q} | {r} | {p} |20237m
Module 1: Introduction & Regular Languages
View this question on its own page →Given the -NFA, compute -closures and convert to DFA.
State -transition a-transition b-transition → {r} {q} {p,r} q ∅ {p} ∅ r {p,q} {r} {p} Q6a. Show that the language: L = \{ a^{n!} : n \ge 0 \} is not regular or not context-free.20217m
Module 1: Introduction & Regular Languages
View this question on its own page →Show that the language:
is not regular or not context-free.
Q6b. Construct NFA for the regular expression: (0+1)^*00(0+1)^*20237m
Module 1: Introduction & Regular Languages
View this question on its own page →Construct NFA for the regular expression: