0% found this document useful (0 votes)
21 views21 pages

Atcd Tut-2 Answers

Sentinels are special characters added to the beginning and end of input strings when using the Boyer-Moore string searching algorithm. This allows the algorithm to handle strings of any length in a linear buffer, without needing to know the length of the input string ahead of time. By adding sentinels to bookend the input string, the algorithm treats the entire linear buffer as if it were circular. This means it does not need to check for end of input conditions, allowing it to skip ahead as far as possible on each mismatch. When a potential match is found, the sentinels ensure the entire input string has been considered before reporting a true match. In summary: 1. Sentinels are added to

Uploaded by

Keerthana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views21 pages

Atcd Tut-2 Answers

Sentinels are special characters added to the beginning and end of input strings when using the Boyer-Moore string searching algorithm. This allows the algorithm to handle strings of any length in a linear buffer, without needing to know the length of the input string ahead of time. By adding sentinels to bookend the input string, the algorithm treats the entire linear buffer as if it were circular. This means it does not need to check for end of input conditions, allowing it to skip ahead as far as possible on each mismatch. When a potential match is found, the sentinels ensure the entire input string has been considered before reporting a true match. In summary: 1. Sentinels are added to

Uploaded by

Keerthana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

ATE

ATCD-Tut2
M2
)Drition n eEi rE is a sting that an ba ormod acpvdiyj ti

4 ae=, Ihon a s a gequlo ezpressia

Diorquoge ¢ au stunqs of o's ond i's tha hays add


utmbr

L= , ol, o10101, IL,1OUL1OL,-t


RE O*Io* CI0*I0*)
Dianquag d al stnn gs o's and 's ttat Aos ataost
rs'pain censecufuo os
L={ 10ol 00, OO1oTOI, ||OTOO,-

strirgs o's and l's that Aoru

LtO, ol, O10, lO101, I|0O0,


DATE

rd toTninals

L:oD|2, 0 122, Oo0T22.

SAB
A ’OALS
B ’ 2Be

S’x/Y
X>axb/ax a
y’ab bY/ b
) L: ab- mz=3
lambn-3

L: faao, aaaab aaaaabb, aaaa aabbb - --t


S ’ aaaA
A ’ aAb|
Aah/a.

Stinq-oaabab.
LMD Produdian apdad
S> AbB S’AbB
S’aA bB A’aA
00AbB AaA
2000.bB A0
»000.ba B. B’aB
9000babB
000bab B’

RMD

’Abaß
Abab8 B>bB
’Abab B
’0Abob A’aA
0aA ab A>aA
2000bab

Panse re2CLMD)

.05 tu Shng daabab ras


khe
. obtain he qamma to gerenate
tocloing danguag
Btats and
S’ ¬|asb| bsa<5s sesing
ends sith seme
9: abba, baab
G= (v,T, P.S)
Gis 4 ule
A context free Gammas
whe Vis etaf vtabler /oom teirals

Tis et of t i n a l a
ket of todution.
Pis

P: £
S Elasb| bSa ss
S is tat synbol.

S-’ asb |a.


G= (vTP,S

T=fa b3

S is stant ynbol.
iii) Palindrome tiing
S Ea< b asa bsb
G: (Y.T.Ps)

P: SE
S alb
S ’ asalbsb3
s is the tant symbot
wrile the egulan
fine eglar enfreion
folloeingarguagai
ehe

Regulan cafenion (& E) =Ca +b))


(Catb Catb)Cat b)
by odd number

Regela enteion C&.£) =


Coo)* Cu)1
net
ending in
all cings
hebathing ab oen I:{a, b3
cafreien CR E) :
Regula tba+ bb)
(a+b (aa
iv) h = Janbn m+n is een ?
eafreion (RE) =
Regla b(b*
Caay* Cbb)* + alaa*
Regula eatuon CRE)=
CbE)Cot6) Cb tE)
aaeaa*
Regular exfreion that we ae
eeneon langage
The eular
clesiae is bullt& on n alfhhabet
about to af ymboe :
h o Kinda
that contans ohteh we ecee
tecial symbols to they
ef mening ohen
fhartiular crelon. The ymbols
attach
vegulan +
e , U,E,C), * , and
contains the ymbol
S,wshih t i l e mateh gaint
tn aphabet
that gelar epreions
Jegula langog
funfing lenma tor
State
Proe ihat the folceing anguagu is net
gela. lemma forgla languag
The fuunhing is a egula dangag thr:

Statemunt: JR trings fotlos


det ' ' containn het f
conditens.ergth af the'x
khe
atleane ´n
|xl n

Jewl< n
uvs
DATE

M2 6). Pumpiing lema statemonti


kot K is a geqular language. w
wis aa stnnq which
bolongs to d dnd lwfth
Let n is the Ùumping lsnma Canstant,than.
) can be brofah bto o=42 Such ttat

Than We cah Scy LiS a

Q5sume is a requla language


ot w= 000
Lit n b2 a pumpin (amma onitant and

Lot K=o, Kyz= TZ: 00 GL

K:3, Xu2 = 000DOE L


0s o a valurs o k ykz L,Lis mst agLas
BATE

Nw

K2, y'

aSsaNu L1513 Qa1eqular language


et w aaaa

Nou) breaf 0mto3 parts, sUch ha


Caa 2
aaaaaa We
at such Iyz 3-pnts
: , into w
beaf Now
Kanguage a1pln not Lis
aaeL aaaa
aaaE L klxu'2
ya
aaaa W
als
DATE

242- aagaaaEL
da aa daa
( Define CFG- Waite a cq sa

qT,R,s)
shee, S is the stat Symbol
V be tibiit bet of valable Ta,b
teminoal
be qinte set o

S’ as b] b8a)e

’absab (sbsa)
abbsaab Cssb)
Abb aatb Cse)

4C,T,P, s)
Vs,,8,c,D
Preut te

C ’aCble
D
S’asb)B
8>bee

ASatee

vi) L-RuuoF\weoto
4ine CFG- Ruigo a Cortoct ree

B b'A

S0091

iid BalNed faseottses

S is he Stat synkot

S0001e
Non- talindieroe

() Corhid he Df

in) i e au
the tansiti'on dinsham the atove DFO and
(V
1) Cnsider the qronr :
E’E+EE-E
E’E*EE/E
E(E)

the left knost derivatin and parce free hr the sting (ntb *)
()Obtgin
tght wt derivetin and pare tree fir the Ghing (a+6) *
(t) 0btoin ahe
Gi0) Ched nbig uous
Ans
() (aib)c

(a%)*c
1) Write an tnite aytam ata hr the llswiny reguar expeain.
() (a b) * ob (aab) r

)Nrit regular definikens fr the allwng langungu.


) All sing st lowercaue letters that cantain fhe fve
veweb i order

I’ [b.d, f-hj-np-tiv-)
)Al ring ci lower coue leskers in hhidh letes
areaN Idng lexicoqraphic orctr
a6cd'"gh'i.. . r'y'

) Al srig ot as and bi hat do not (antain the ubequene abb


L’ (ab)*aob i aba +ban ibbat bab t aan bbb) (arb)
Caplain hoo
sentinels e hondled Ubigg bl?
he n g loenes in the
sore
us tomine
lefseoding
task he Sobe POy on be
Tkib task is made dicolt he fet that e en hove to
’ he hezt lesene
lot one o% moe chehoctes brohd
on te sone wo hoe the oght lexoeoneweve sen The end an
’ Fon in stance, toe connot be
we sa a chaado that is not a ledee o dpt,
identifo ontl fa td. Thus , we shall
ond Beese is vot past he leseme
-beo tere thot hordles boge lookokeod,
introdure a tao
tine token to phores chaoctos
’Becouse the omout
chooctn tot out le phereed doy
ond the laye npbo
the compilaton olagge souNe Phgpan, spocalzed bfoing
tchniguks hoe'bean duedopel dere'the amot
irpit chanatos,
owhad eguined to prores a srglebes
impostont sheme in voloes ta hst ae atoratey
>An
neladd, os ygdd nPgune,
M* C**2 eaf

bame Size , ond N is Usally the size


adsk block.
> Pointo lexeme Bginnosks he heainnig the coosent lexene
chose extent oe atnpg tb detoasre.
’ Pointe boucd Stons ahebd ont:l pattesn match is
cxoc
made oill be (oveoed in the balone o hi
’ As as we heves ned to look so
brg lexene that he sum
he asod the kreme 's engh pls
he distone we baa ohad is ghere thon M,we shall eo
must check , ear
Sertinels descoibed, oe Ore o
scheme as moved !!
> we UBe the hot we hove not 9eload the othe
dnce Vound mut also
oe do, then wa to0 testsione is e
s! e we moke chasacter
chaotn neod, detesmine ohat
’ Thus each one to con tombine
and bonch). we chooocs
nd nultog cwnsent
ead Che latto my be a tst he at de erd
he bule test orth the sentnel chasote
hold a hat cornot be pot
we exterd each bull b chasote
The Specid
Sent: nel is a choractes
is the
o nou n choice
ore prgrom, tind
e
mc
lestmepi
Figuver Setnels t the ond eadh lb-fle !
otans its Vbe as a make b the end
> Nae that e thon at the erd
the entse înput. Any eo that appes othes
on and.
meons that tht the input is at
Cnsigned nn bes ord RE GP
I4). wmte the tronstran dtagon on on

ws?
medrate slep tn the ondructon alezitel anolyaa
uta As on fnto floochosts , colled "toonstto
oe frst on vert patesns into yfaed

-n
Jagpas
In ths Secton, ae dhe canrs onfhm ngulantres
-n
colecton nades on cincles , calledl
hove a
’ Tronstion diogams epreserts
States. Each stote a torditian bot could ocas dgy
inpat lokin on o kxeme that
the proess scorng the
motches one sevend gatons.state he tronsilion
core dineced prom Ohe
tb ongte.
Is. Exglam the ole te lexial onalyaen!
slator As be fndt thate a tonpl he mn tik the lexil ondyr
is to nead bo input chah clens the Sooe moporn gup -em ak
lxemts,and pradoce as alpt a agwe tkens o eoch osene
in to Socace phogom.

token
lexical to smte
Pan Ben
Analyae
get vext TGken
onigtis

Talile
> The Rl lexal arolgien is to read the inpt dhrhalens te
toNe mapom goup beo into lexima ond medute te ort put a
R9uene bkos och leima in the soe progaon,
’ The intenadton is implemented hoving he onoe als e kedl
ovag using tho functon Co|l got hect tokeh . commord CouBes
lexi cal analyzen ta sead choaces faon ts npet ontil t
lept idented. net lexima ond produce f th the nest tolke

’ The leri eal ovolgze qoot he Cornples th ot sead tho Kococe


phogorn it m pameostain ot tasd beside Jded foat
on lenigo .1bst task is tging ho
ate
tomnent lines ond'akte
Spoces ge(and is obes Chtactos fat 3epanatd the tokeo in
9 last ask code melated Obo 9
oith te so ce pmgrom.
SStonnif -Sconnitj onit simpk proes hat conot eguise
tokeninaton of on inpt sah as dolet on oamats ete.
i) tcal ahalysis is o mose
to tokens om the ctqut af the sonno.
ASgned neumbe

(49)
selst:en Chunkn, la:d 2elot onnumbo,
volue) lzvl yde)

RELOP:

Ordtins Coelap ,eot).

Token

Token atuan taken= hew Caelap):


while C)
Switek Cstates)
( e < ) statenents LTs
else i Cc=') statement oT:
else Cc-s) statemest Case bT etnt ();
else fal C): adToken -staibde -GhT ;
Case LT aetamn (adtTobens
c hewchan);
Cc)
sAate LE
NE
else i Ce (s)latt
else netünn token otabute r
em Coe thon table)

You might also like