Sei sulla pagina 1di 11

# Theoretical Computer Science

Tutorial I
1) Design FSM for testing divisibility by 5 for decimal numbers.
2) Design FSM to check whether given unary number is divisible by 3 or

## not. Hint: ={a} (3)10={aaa} (5)10={aaaaa} Length of string = value of

number.
3) Design DFA for the following language over alphabet ={a,b}

## a) String that should contain 3 consecutive bs.

b) Strings in which occurrence of every a is preceded by the
occurrence of b.
c) String which contain a at every even position in the String.
d)

f)

## g) String does not contain any occurrence of three consecutive bs .

h) String starts with three consecutive as.
i)

## Theoretical Computer Science

Tutorial II
1) Determine an NFA accepting the language

## a) L1={x|x {a,b,c}* and x contains the pattern abac}

b) L2={a* U b*}
2) Determine NFA with three states that accepts language {ab, abc}*
3) Find the equivalent DFA from given NFA whose transition function is
as follows.
a
b
q0
{q0,q1}
q1
{q1,q2}
*q2
4) Consider following - NFA.

a
b
c
p
{p}
{q}
{r}
Q
{p}
{q}
{r}
*r
{q}
{r}
{p}
a. Compute the -closure of each state.
b. Give all the strings of length three or less accepted by the
automaton.
c. Convert the automaton to DFA.
5) Repeat above exercise for the following NFA.
a
b
c
p
{q , r}
{q}
{r}
Q
{p}
{r}
{p,q}
*r
6) Convert to DFA the following NFA

a.
p
q
r
*s
b.

0
{p,q}
{r}
{s}
{s}

1
{p}
{r}
{s}

p
q
r
*s
*t

0
{p,q}
{r,s}
{p,r}
-

1
{p}
{t}
{t}
-

5) Minimize the following DFA, where q0 is the start state and q3 & q5 are
final states.
q0
q1
q2
*q3
q4
*q5

A
q1
q0
q1
q5
q3
q5

b
q3
q3
q4
q5
q3
q5

## Theoretical Computer Science

Tutorial III
1) Find the equivalent Minimum state DFA from given DFA whose
transition function is as follows.
0
1
q0
q1
q2
q1
q3
q4
q2
q5
q6
q3
q3
q4
q4
q5
q6
*q5
q3
q4
q6
q5
q6
q7
q4
q5
2) Design Moore machine to generate 1s complement of given binary
number.
3) Design Moore machine for ={0,1,2}, print the residue modulo 5 of
input treated as a ternary number.
4) Construct Moore machine which adds binary numbers.
5) Design a Mealy machine that scans sequence of inputs of 0 and 1
and generates output A if the input string terminates in 00, output B
if the string terminates in 11 and output C otherwise.
6) Construct equivalent Moore machine.
q0
q1
q2

0
q0
q1
q1

output
n
y
n

1
q1
q2
q2

output
n
n
y

## 7) Construct given Moore machine to mealy machine.

0
1

p
p
q
0
q
p
r
0
r
p
r
1
8) Design Moore and Mealy machine that will read sequence made up
of letters a,e,i,o,u and will give same output as that of character
except when i followed by e will change to u.

## 10) Design Moore machine that will convert every occurrence of

substring 121 to 122 over ={0,1,2}.
11) Design Mealy machine to add two binary numbers of equal length.
={(0,0),(0,1),(1,0),(1,1)} ={0,1}

## Theoretical Computer Science

Tutorial IV
1) Write regular expressions for the following languages.
a) L={uvu|u,v = {a,b}* and |u|=2}
b) Strings containing even number of zeros. ={0,1}
c) String not containing two consecutive bs.
d) String not containing two consecutive 0s & string ends with 1.
e) Strings that do not contain two consecutive as nor bs ={a,b}
f) String starts with abb and ends with bbb.
g) String not containing three consecutive bs.
h) String not containing three consecutive as or bs.
i) Strings that have almost three as defined over ={a,b,c}
j) String of length 2, ={0,1}
k) String contains each symbol at least once ={a,b,c}
l) Strings with almost one occurrence of two consecutive zeros.
={0,1}
m) Intersection of (a+b)*a and b(a+b)*
n) L={a^n| n is divisible by 2 or 3 or 5}
o) L={a^n b^m | m>=3, n>=4}
2) Construct minimized DFA for R = (0 + 1)* 10 + ((00)* (11)*)*

## 3) Construct minimized DFA for R= 10 + (0 + 11) 0* 1

4) Describe language given by DFA
0
1
*q0
q4
q1
q1
q3
q2
q2
q3
q1
q3
q3
q3
q4
q0
q3
5) Describe language given by FA
0
1
*q0
q0,q2
q1
q1
q3
q4
q2
q4
q3
q3,q4
q3,q4
q4
-

## Theoretical Computer Science

Tutorial V
1) Explain Pumping Lemma with the help of a diagram to prove that
given language is not a regular language.
2) Check if the following language is regular or not by using pumping

lemma.
a)

L={0i1j| i>j}

b)

L={0m1n| gcd(m,n)=1}

c)

L={02n| n>=1}

d)

L={02n+1| n>=0}

e)

L={axbmcn | n, x>=3}

f)

L={ an | n>=0}

g)

L={ww | w {a,b}*}

h)

L = {x | x is palindrome, x {0,1}*}

i)

## L= equal number of 0s and 1s anywhere.

j)

L={ ap | p is prime}

## Theoretical Computer Science

Tutorial VI
1) Show that the following grammar is ambiguous.

S -> aB | ab
A->aAB | a
B -> ABb | b
2) Describe the language generated by the following grammar.

S -> aaSb
S -> A
A -> Cd
3) Eliminate e-productions from G, where G is consisting of following
productions.

## a) S -> aSa | bSb | e

b) A->aBb | bBa
B -> aB | bB | e
4) Eliminate unit-productions from CFG, where P is given by

S -> Aa | B
A-> a | bc | B
B -> A | bb
5) Consider CFG, G = (VN , , P, S) where VN ={ S,A,B }

= {0,1} and
P={
S -> A11B | 11A | B | 11
A -> 0
B -> BB }
Remove useless symbols from it.
6) Construct CFG without null production from the one which is given
below

S -> a | Ab | aBa
A -> b | ^
B -> b | A

Tutorial VII

## 1) Write the short notes on closure properties of CFL.

2) Prove that the language is not CFL :
L={am bm cn | m<=n<=2m}
3) Prove that the language is not CFL :
L={am bn | n<=m<=2n}
4) Convert to CNF:
S -> ABC
A -> a | b
B -> Bb | bb
C -> aC | CC | ba
5) Convert the following grammar to GNF:
S -> ABA
A -> aA | ^
B -> Bb | ^
6) Write a short note on decision algorithm.

## Theoretical Computer Science

Tutorial VIII
1) Design a turing machine for recognition of binary Palindrome.

n n n

## 3) Design a turing machine that recognize the language L= {a b c |

n>=1}
4) Design Turing machine that recognize the language L= { x |

na(x)=nb(x) }
={a,b}
5) Construct PDA for the following Language.
L = { Om1nOm+n |m,n >= 1}
6) Define PDA and construct PDA for the grammar
E ->E+E | E-E | (E) | id

## Theoretical Computer Science

Experiments
EXPT 1 : Program to check that if an entered string, given pattern is
accepted by DFA.
EXPT 2 : Program to check that if an entered string, given pattern is
accepted by NFA.
EXPT 3 : Program that inputs a regular language and checks that if
an entered string, belongs to that language.
EXPT 4 : Program to implement Turing machine.

## Theoretical Computer Science

Assignments
Assignment 1 :
1. Explain different applications of Theory of Computer Science,
Automata, Turing machines, Push Down Automata.
2. Define and differentiate between DFA and NFA.
3. Distinguish between Mealy and Moore machine.
Assignment2 :
1. What is regular expression? Draw NFA diagram for them with emoves.
2. Explain Chomsky hierarchy for classifying grammars.
3. Explain Myhill Nerode Theorem.