Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

THEORY OF AUTOMATA

[Assignment]

Name Roll #
Ahtasham B-17834

University of South Asia, Lahore


Q#5: Write a code in any language to design simple Finite Automata.by using switch
statement. [10pt]

Typedef enum{
START_STATE,
STATE0,
STATE1,
FINAL_STATE } OfaState ;
Bool recognize DFA (std ::String inputString){
// this function will return true if it finds this
//the given String has aab as a SubString
OfaState currentState = START_STATE;
For(int i=0; i=<inputString length(); i++){
Switch (currentState ){
Case start_state;
{
Case a; Current State = STATE0 continue;
Case b ; currentstate = START_STATE;
Default: cout<<<invalid character <<end; continue;
Return false;
}
Case STATE;
}
Case a current state= STATE: continue;
}
}
}
Q# 1 prove by pumping lema.

L = { am bn | m, n 1}.
Assume l is regular
Let we assume q,r be the number from the pumping lema. And q =4 and r =4 from the given
language . so
W= aqbr
Wn
We must specify it by pumping lemma. W=xyz where as y 0 , xyz L
aaaabbb

so here
x = aa
y = aa
z= bbbb
xy2z = a6b4 = aaaaaabbbb is not in the language.
Q#3: Construct null NFA a*b* [(a*b*+ b*/a+ ]
2. aa.[(aa + ab + ba + bb)* /a*bba+b].bb

You might also like