0% found this document useful (0 votes)
523 views3 pages

2025 Mock Exam Questions Answers

The document outlines a mock examination for a computer science course, focusing on topics such as Turing machines, finite automata, context-free grammars, and pushdown automata. It includes various questions that require designing automata, constructing grammars, and analyzing languages, along with solutions for some of the problems. The exam consists of 13 questions worth a total of 60 marks.

Uploaded by

Naga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
523 views3 pages

2025 Mock Exam Questions Answers

The document outlines a mock examination for a computer science course, focusing on topics such as Turing machines, finite automata, context-free grammars, and pushdown automata. It includes various questions that require designing automata, constructing grammars, and analyzing languages, along with solutions for some of the problems. The exam consists of 13 questions worth a total of 60 marks.

Uploaded by

Naga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CO1108 Mock Examination

Questions and Solutions

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

3. For any string α let αrev denote the reversal of α, so that:

λrev = λ, (a1 a2 . . . an−1 an )rev = an an−1 . . . a2 a1 for n > 0.

Construct a deterministic pushdown automaton accepting the language


{αzαrev : α ∈ {x, y}∗ }. [8 marks]
You could also be shown a PDA and asked what language it accepts. Or, you could be shown
an un nished diagram of a PDA and asked to nish it.
Solution The PDA is given below.

1
4. Construct a context-free grammar G such that [4 marks]

L(G) = {xn aym : n, m ∈ N, n ⩽ m ⩽ 3n}.

Is the grammar G ambiguous? Justify your answer. [4 marks]


You could be asked to write down leftmost or rightmost derivation of a string generated by
a CFG.
Solution The following grammar accepts G.
S → x S y | x S yy | x S yyy | a

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).)

5. Let G be the context-free grammar (N, Σ, P, S) where

N = {S, T,U}, Σ = {a, b, c, x, y}

and P is the set of productions

{S → xT | yU, T → aT b | c, U → bUa2 | c}.

(i) What is L(G)? Justify your answer. [4 marks]


(ii) Construct a pushdown automaton M such that L(M) = L(G) using conversion of CFG
to PDA method from Chapter 7. [6 marks]
(iii) Produce a leftmost derivation for ybbcaaaa. [2 marks]
Solution
(i)
L(G) = {xan cbn | n ⩾ 0} ∪ {ybn ca2n | n ⩾ 0}

(ii) The PDA is given below:

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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy