United International University (UIU)
Dept. of Computer Science & Engineering (CSE)
Final Exam Summer 2024
CSE 2233/CSI 233: Theory of Computation/Theory of Computing
Total Marks: 50 Duration: 2 Hours
Answer all questions. Figures are in the right-hand margin indicates full marks.
Any examinee found adopting unfair means will be expelled from the trimester / program as per UIU
disciplinary rules.
1. Consider the following Context-free grammars (CFG) and answer according to it: 5*2
a) S → DBC With the help of Top-Down Parse Trees, find-out
B → 0B1 | 0B | 1B | if the grammar is Ambiguous or not for the string:
C → aCb | aC | Bb | b “a01aa0bbb”:
D → bD | D | Ba
b) SWITCH → switch ( EXPR ) : CASE With the help of leftmost derivation derive the
CASE → case EXPR : STMT CASE | DF following string:
DF → df : STMT “switch (5): case 1: a+b case 2: a++ df: a*b”
STMT → a+b | a++ | a*b | a/b | a%b| a | b
EXPR → INT | CHAR
INT → 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
CHAR → a | b| c| d | e
2. Design CFGs that generate the following languages: 3*4
a) L = { an b2m cn | n, m 1 }
b) L is a language where every string is a palindrome of odd length over the alphabets {a,b}.
c) L is a language of Roman number systems where I = 1, V = 5, X = 10, L = 50. (e.g. I, IV, VII.
XLIX representing numbers 1,4,7, 49 respectively)
*You only need to consider up to the 50th number.
d) L = {pn qm ro sx | n = 2m, x = 2o, n, x 0}
3. Convert the following grammars into Chomsky Normal Form (CNF): 4*2
a) S → BAC | B
B → 0B1 | 01
A → aAb |
C → Bc
b) S → ABA
A → aA |
B → bBc |
Page 1 of 2
4. Draw the Push Down Automata (PDA) for the following languages: 5*2
a) L = { xn y3m z2m vn | n 1}
b) i j k m
L = { p q r s | i==k or m j+2, i, j, k, m 1 }
5. Draw a Turing Machine for the following language and show the Tape Traversal to validate the 5*2
given input:
L = { x2i yj zi w3j | i, j ≥ 1 }
Input String: xxxxyyzzwwwwww
Page 2 of 2