Final Exam - Fall 2023-Solution TOA
Final Exam - Fall 2023-Solution TOA
Final Exam - Fall 2023-Solution TOA
3 1 8 12 2 10 12 4 8 12 10 14 24
Question 1:
a) If L1, L2 and L3 are Context free languages and L4 = L1 Ո (L2 U L3). What kind of language will
be L4. (RL, CFL or non-CFL) Explain briefly [3 Marks]
Non CFL
L2 U L3= CFL
L1 Ո (L2 U L3)= Non CFL
b) True/ False Context free languages are closed under difference. [1 Marks]
False
L = {ai bj ci d(i+j) : i, j ≥ 0}
Question 2:
Minimal DFA
a) Tell whether the following grammar is ambiguous. How? Give justification [2+2 = 4 Marks]
S 0S1 |0S11 |∧
Ambiguous
Justification: two LMD OR 2 RMD from same string WITH EXAMPLE
CFG:
S → < table > R0 </table > S | < table > R0 </table >
R0 → < tr > C0 </tr > R1 | < tr > C0 </tr >
R1 → < tr > C1 </tr > R2 | < tr > C1 </tr >
R2 → < tr > C1 </tr > R0 | < tr > C1 </tr >
C0 → < td > Num </td > C0 | < td > Num </td >
C1 → < td > Num </td > C1 | < td > Num </td >
C1 → < td > Alpha </td > C1 | < td > Alpha </td >
Num → 0|1|2|3|4|5|6|7|8|9|0
Alpha → a|b| ... |z|A|B ... |Z
Question 4:
a) Suppose you have a single tape Turing machine (TM) that is infinite from both ends. The current
head (pointer) is at # (in the start of TM). Dry run the TM on next page and give the content of the
tape after running it (When TM halts). Also mention the location of the head [8.5+1.5 = 10
Marks]
Input String:
. . . ∆ ∆ # ∆ 1 0 ∆ ∆ ∆ . . .
Sample Input:
Tape1 ∆ 1 1 1 1 1 ∆
Tape2 ∆ 1 1 1 ∆ ∆ ∆
Tape3 ∆ ∆ ∆ ∆ ∆ ∆ ∆
Tape4 ∆ ∆ ∆ ∆ ∆ ∆ ∆
Sample Output:
Tape1 ∆ 1 1 1 1 1 ∆
Tape2 ∆ 1 1 1 ∆ ∆ ∆
Tape3 ∆ 1 1 ∆ ∆ ∆ ∆
Tape4 ∆ 1 ∆ ∆ ∆ ∆ ∆
Turing Machine