# SCJ3203/SCK3253: Theory of Computer Science Assignment 2 This is an individual assignment.

Due date: 16th April, 2011
1. For each type of language in the Chomsky Hierarchy listed below, describe the form of rules that the grammar can have, give example of the rules; and state the simplest automaton/machine that can recognize the language: a. b. c. d. Type 0 – unrestricted grammar Type 1 – context sensitive grammar Type 2 – context free grammar Type 3 – unrestricted grammar

2. Consider the following regular grammar G: S bA A aC bB B bA C aD D aC a. Design a finite automaton to accept the language as described by grammar G. b. Give a regular expression for the language. 3. Let G2 be the grammar: S → Ac A aAb | λ a. b. c. Derive a number of valid strings starting with string of shortest length. Stop when you can figure up the pattern of the strings. Draw the derivation tree for strings derived in 2a. Give a regular expression for the language.

4. Let M be the PDA defined by: Q = {q0, q1} Σ = {a, b, c} Г = {A, B} F = { q2} Start state is q0 δ(q0, a, λ) = {[q0, A]} δ(q0, b, AAA) = {[q1, λ]} δ(q1, b, AAA) = {[q1, λ]} δ(q1, c, λ) = {[q2, λ]}

a. Give the state diagram of M. b. Trace all computations of strings aabc, aaabbc, aaaabbc in M. c. Describe the language accepted by M. d. Give a regular expression for the language. 1

5. Write the definition of the machine PDA that accept L(G2).m > 0} 6. Give the state diagram of the PDA. { anban | n ≥ 0} b. b. B. b. L Trace the computation for the input string abcab. c. R q2. b. c. 7. 8. 2 . Trace the string abaacbc and state whether it is accepted or rejected. Build a PDA to accept the following languages: a. d. Let G2 be the GNF grammar: S  aABA | aBB A  bA | b B  cB | c a. L q1. R q1 q2 a. B. { anbmcn+m | n. Design a Turing machine M for the language above. b. a. a. c} expressed by (a+b)*aac(a+b+c)* a. L c q2. Give the state diagram of M. c. Describe the result of a computation in M. d. Let M be the Turing Machine defined by δ B a b q0 q1. Give a regular expression for the language. Write the transition function for M. Trace the first six transitions of the computation for the input string abab. c. L is a language over alphabet {a. R q1. R q2. q1. Trace the string abcaacb and state whether it is accepted or rejected. b. b.