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