CSC262 · TU past paper
Theory of Computation 2076 question paper
The complete TU 2076 exam paper for Theory of Computation (CSC262), all 12 questions with solved model answers written to the mark scheme.
Tap a question to open its answer.
- 110 marksReduction of Regular Expression to ε – NFAHideAnswer
Define the NFA with ϵ−transition\epsilon-transitionϵ−transition and ϵ−closure\epsilon-closureϵ−closure of a state. Show that for every regular expression r, representing a language L, there is ϵ−NFA\epsilon-NFAϵ−NFA accepting the same language. Also convert regular expression (a+b)ab into equivalent Finite Automata.[10]
NFA with ε-Transition, ε-Closure, and Regular Expression to FA Conversion
1. NFA with ε-Transition (ε-NFA)
An NFA with ε-transition (also called ε-NFA) is a Nondeterministic Finite Automaton that allows transitions on the empty string ε (without consuming any input symbol).
Formally, an ε-NFA is defined as a 5-tuple:
M = (Q, Σ, δ, q₀, F)
where:
- Q = finite set of states
- Σ = finite input alphabet
- δ : Q × (Σ ∪ {ε}) → 2^Q = transition function (can take ε as input)
- q₀ ∈ Q = start state
- F ⊆ Q = set of final/accepting states
The key difference from a standard NFA is that the transition function accepts ε as a valid input, allowing the automaton to move from one state to another without reading any symbol.
2. ε-Closure of a State
The ε-closure of a state q is the set of all states reachable from q by following zero or more ε-transitions (including q itself).
ε-closure(q) = {p ∈ Q | p is reachable from q using only ε-transitions}
Properties:
- q is always in ε-closure(q) (reflexive)
- If p ∈ ε-closure(q) and r ∈ ε-closure(p), then r ∈ ε-closure(q) (transitive)
Example: If q --ε--> p --ε--> r, then ε-closure(q) = {q, p, r}
3. Theorem: For Every Regular Expression r, There Exists an ε-NFA Accepting L(r)
Proof by Structural Induction (Thompson's Construction Rules):
We show construction rules for each case of a regular expression.
Base Cases
Rule 1: r = ∅ (empty language)
→[q₀] (no transitions, no final state)The ε-NFA has start state q₀ with no accepting states.
Rule 2: r = ε (empty string)
→[q₀] --ε--> ((q_f))One ε-transition from start to final state.
Rule 3: r = a (single symbol a ∈ Σ)
→[q₀] --a--> ((q_f))One transition on symbol a from start to final state.
Inductive Cases
Assume ε-NFAs N(r) and N(s) exist for regular expressions r and s.
Rule 4: r = r₁ | r₂ (Union / Alternation)
Create a new start state and new final state, connect with ε-transitions:
ε --> [N(r₁)] --> ε →[q₀] --< >--> ((q_f)) ε --> [N(r₂)] --> ε- New start state q₀ goes to start of N(r₁) and N(r₂) via ε
- Final states of N(r₁) and N(r₂) go to new final state q_f via ε
Rule 5: r = r₁ . r₂ (Concatenation)
Connect the final state of N(r₁) to the start state of N(r₂) via ε:
→[N(r₁)] --ε--> [N(r₂)]-->((q_f))- Final state of N(r₁) becomes non-final
- ε-transition connects it to start of N(r₂)
Rule 6: r = r₁ (Kleene Star / Closure)*
ε (loop back) ↑___________↓ →[q₀] --ε--> [N(r₁)] --ε--> ((q_f)) |_________________________↑ ε (skip, for empty string)- New start state q₀ connects to start of N(r₁) via ε
- Final state of N(r₁) loops back to start of N(r₁) via ε
- New start state also connects directly to new final state via ε (to accept ε)
Since every regular expression is built from these base cases and operations, and we have shown an ε-NFA construction for each, by induction, every regular expression has an equivalent ε-NFA. ∎
4. Convert Regular Expression (a+b)ab to Equivalent Finite Automaton
The regular expression is: (a+b)*ab*
This means: strings over {a,b} that contain at least one 'a', ending with zero or more b's -- more precisely, any string of a's and b's, followed by 'a', followed by zero or more b's.
Step 1: Break the expression into parts
Part Meaning (a+b)* Zero or more a's or b's (any string) a Single symbol a b* Zero or more b's
Step 2: Build ε-NFA for each part
Part 1: (a+b)*
a ε ↗[q₁]↘ ε [q₀] [q₃] --ε--> ((q₄)) ε ↘[q₂]↗ ε bWith loop: q₄ --ε--> q₀ (for the * closure), and q₀ --ε--> q₄ (for accepting zero repetitions of (a+b), i.e. the empty string). This gives the complete ε-NFA fragment for (a+b)*, with q₀ as its start state and q₄ as its accepting state.
Part 2: Single symbol a
→[q5] --a--> ((q6))Part 3: b*
ε (loop back) ↑___________↓ →[q7] --ε--> [q8] --b--> ((q9)) |_____________________↑ ε (skip, for zero b's)
Step 3: Concatenate the Three Parts
By the concatenation rule (Rule 5 above), the accepting state of one block is joined to the start state of the next block with an ε-transition, and it stops being an accepting state in its own right (only the final block keeps an accepting state):
- q₄ --ε--> q₅ (end of the (a+b)* block feeds into the mandatory a)
- q₆ --ε--> q₇ (end of the mandatory a feeds into the b* block)
Step 4: Complete ε-NFA for (a+b)*ab*
State On ε On a On b q0 (start) q1, q2, q4 -- -- q1 -- q3 -- q2 -- -- q3 q3 q0 -- -- q4 q5 -- -- q5 -- q6 -- q6 q7 -- -- q7 q8, q9 -- -- q8 q9 -- q8 q9 (accept) -- -- -- Verification:
- On "ab": q0 --ε--> q4 (zero repetitions of (a+b)) --ε--> q5 --a--> q6 --ε--> q7 --ε--> q9 (zero b's). Accepted.
- On "aabb": q0 --ε--> q1 --a--> q3 --ε--> q0 --ε--> q4 --ε--> q5 --a--> q6 --ε--> q7 --ε--> q8 --b--> q8 --b--> q8 --ε--> q9. The symbols consumed, in order, are a (one turn of the star), a (the mandatory a), b, b (two turns of b*), i.e. exactly "aabb". Accepted.
This ε-NFA accepts precisely the language of (a+b)*ab*: any string over {a, b} (possibly empty), followed by a mandatory a, followed by zero or more b's. This completes the required conversion of the regular expression to an equivalent finite automaton via Thompson's construction.
- 210 marksConversion of PDA by Final State to PDA acHideAnswer
How can you define the language accepted by a PDA? Explain how a PDA accepting language by empty stack is converted into an equivalent PDA accepting by final state and vice-versa.[10]
A Pushdown Automaton (PDA) is a 7-tuple: $$P = (Q, \Sigma, \Gamma, \delta, q0, Z0, F)$$ Where: - $Q$ = finite set of states - $\Sigma$ = input alphabet - $\Gamma$ = stack alphabet - $\delta$ = transition function:
- 310 marksIntroduction to Turing MachinesHideAnswer
Define a Turing machine. Construct a TM that accept $L = { wcw^R \mid w \in {0, 1} \text{ and } c \text{ is } \varepsilon \text{ or } 0 \text{ or } 1 }$. Show that string 0110 is accepted by this TM with sequence of Instantaneous Description (ID). [10]
A Turing Machine (TM) is a theoretical model of computation defined as a 7-tuple: $$TM = (Q, \Sigma, \Gamma, \delta, q0, B, F)$$ Where: Component Meaning -------------------- $Q$ Finite set of states $\Sigma$ Input alphabet (finite set o...
- 45 marksDeterministic Finite AutomataHideAnswer
Give the formal definition of DFA. Construct a DFA accepting all strings of {0, 1} with even number of 0's and even number of 1's. [5]
A Deterministic Finite Automaton (DFA) is a 5-tuple: $$M = (Q, \Sigma, \delta, q0, F)$$ Where: Component Description ------------------------ $Q$ A finite, non-empty set of states $\Sigma$ A finite set of input symbols (alphabet)
- 55 marksChomsky Normal FormHideAnswer
Define Chomsky Normal Form and Greibach Normal Form in reference to CFG. Give a suitable example of each. [5]
--- A Context-Free Grammar (CFG) is said to be in Chomsky Normal Form if every production rule is of exactly one of the following two forms: A → BC (a non-terminal produces exactly two non-terminals) A → a (a non-terminal produces exactl...
- 65 marksRegular ExpressionsHideAnswer
Give the regular expressions for following language over alphabet {0, 1}. a. Set of all strings with 2nd symbol from right is 1. b. Set of all strings starting with 00 or 11 and ending with 10 or 01. [5]
Analysis: To ensure the 2nd symbol from the right is 1, the string must have the form: - The last symbol can be either 0 or 1, i.e., (0+1) - The 2nd from right must be 1 - Before that, there can be any string of 0s and 1s (including empt...
- 75 marksPumping LemmaHideAnswer
Show that language is not a regular language. $L = { 0^m 1^m \mid m \geq 1 }$ [5]
--- If A is a regular language, then there exists a pumping length p such that any string s with s ≥ p can be divided into three parts s = xyz satisfying: 1. xy^i z ∈ A for every i ≥ 0 2. y 0 (y cannot be empty) 3. xy ≤ p (xy together mu...
- 85 marksTuring Machine with Multiple TapesHideAnswer
Describe the Turing machines with multiple tape, multiple track and storage in state. [5]
--- A multiple tape Turing Machine is an extension of the standard TM that has k independent tapes, each with its own read/write head. The standard TM is a special case where k = 1. The transition function is extended as: This means: giv...
- 95 marksMethod for reduction of NFA to DFAHideAnswer
Construct a NFA accepting language of {0, 1} with each string ending with 01 and convert it into equivalent DFA. [5]
Language: L = { w w ∈ {0,1} and w ends with 01 } Example strings: 01, 001, 101, 0001, 1101, ... We need 3 states: State Role ------------- q0 Start state (reading any symbol, staying in loop) q1 Just read '0' (possible start of ending "0...
- 105 marksAcceptance of strings by PDAHideAnswer
Construct a PDA accepting language over {0, 1} representing strings with equal no of 0s and 1s. Show by sequence of IDs that 0101 is accepted by this PDA. [5]
A Pushdown Automaton (PDA) is a 7-tuple: M = (Q, Σ, Γ, δ, q₀, Z₀, F) --- Language: L = { w ∈ {0,1} 0(w) = 1(w) } Idea: Use the stack to track the difference between counts of 0s and 1s. - Push a symbol when one character is in excess. - ...
- 115 marksTime and Space complexity of A Turing MachHideAnswer
Define complexity of a Turing machine. Explain about big Oh, big Omega and big Theta notation used for complexity measurement. [5]
The complexity of a Turing Machine refers to the measurement of resources (primarily time and space) used during a computation. When a Turing Machine answers a specific instance of a decision problem: - Time is measured as the number of ...
- 125 marksIntractabilityHideAnswer
What do you mean by tractable and Intractable problems? Explain with reference to TM. [5]
A problem is said to be tractable if it can be solved within reasonable time and space constraints. More formally, a problem is tractable if there exists an algorithm whose complexity (time and space) grows no more rapidly than a polynom...