2025 Mock Exam Questions Answers
2025 Mock Exam Questions Answers
1. Around six to seven small questions mainly about Alan Turing and Alonso Church, PDA and
Turing machine transition notation, class of languages including regular, context-free and
Turing acceptable and recursive languages. Either true or false, or choice of several options,
very much as in Class Test 1 and Class Test 2. [10 marks]
2. Design a complete deterministic nite automaton that accepts the set of all strings in {a, b}∗
that end with an a. Hint: you may start with designing an NFA and then make it deterministic
and complete. [8 marks]
Solution The NFA and the derived DFA are respectively drawn below:
λ
a
a
s0 s1 s2
b
λ
b a
s0 , s1 a s0 , s1 , s2
1
4. Construct a context-free grammar G such that [4 marks]
Yes, it is ambiguous. There are two di erent parse trees or two di erent leftmost derivations
for xxayyy,
First derivation: rst choosing the rst rule and then the second rule we ger S → xSy →
xxSyyy → xxayyy;
Second derivation: use the second rule rst, then use the rst rule: S → xSyy → xxSyyy →
xxayyy.
In the actual examination, it is best to show ambiguity by providing two di erent parse trees
of a single string (as above).)
2
No it is not ambiguous. If the string starts with x, then S → xT applies, while if it
starts with y, then S → yU applies. While parsing using T , if the next symbol is a, then
T → aT b applies, while if the next symbol is c, T → s applies. While parsing using U ,
if the next symbol is b, then U → bTa3 applies, while if the next symbol is c, U → s
applies.
6. Given the alphabet Σ = {a, b}, produce a deterministic Turing machine that accepts all strings
α such that |α|a = 2|α|b , where |α|a and |α|b denote the number of a's and b's in α, respec-
tively. [14 marks]
Solution
Overall, there will be 13 questions presented randomly, and you can obtain 60 marks in total for
correct answers.