You are on page 1of 7

mlin

Assicnmert2 SCHOLAR
Lhtts attes Malehing? Explain ive
algosrtmm
APottesn motching is the psoc@ss ot chekin

cwhethes a speciic Sequence of chotiacters


tokens
data eists amanq aivern dato
Reolas prcqomminq laquaqes make use of equlax
Cxpsessions fos poiiesn matchng-
otesn matching ts usad in, dertitinq matchino
pottesm ox ubstihinq matehina potiesn t
anc-thes token Sequence.
-Ih eee aloo»tthvms ase aso Krouon as Shsinq
Eo Seoxcrinq aaosithmS

Naive Alopsithm steps


Sep-L:Place the seaich potean at beginning *
inpuut sesmq.
Step-2: Libalige i-£isst chaxactes of qven et,\
-Fisst chayacte of potesm.
Step-3: Compase both and J, ¥ mohch.move oth i
ocnd to ece cho-zacex
Step 4:Nou qot Step-3 epeat for all potem
Chasacss
Step-5: iod j doesnot madeh
then movej to
Deqinrimg f pelem,i to the Seond

Chozaces of iven todt. Now gdto step-3


epeatil porern macoh ox t xeached end.
xplain inset a nade at begn a d delete a node at
in double Inked tis
end opeations
A)Tnceta node e begio
Ceate a neuwn cde stoe the
value m dato.
Step-1:
ield ond NULL m pevious e l d ot rewnade
Yeurode-sdata- value;
mewmade-previous NUL;
Step-2:T head-=NOLL, make mewnade as fis st
mode woith acsiqninq NULL in nesdt Pield, ond
makehead os neLs node.
meuwmode-ned-NULL o
head = neLonede,

Step-3: Else close head addess in he nezt fied


of neLonode And make as «st naa
YOLencde m e c t -head
head-pev=meLwnode
head Tesnode;
Step-t Dsplay Nods is insextedat legiming

Delcte aede a end ot lst


Step-1:Check uhetes hst ts 'Emphy?
head==NOLL)
Step-2 iE is Emphy,then displayList 1s
Empty!l Delston is not poasible and
teminate the fuenion
Step-3:T t 1S not emph then, define a nede
Poites temp and mitialize oith head
Stap-: check uohethes let has ony one Node-
teempPeicus and bemp-neE bath ae

NOLL)
step-5: T tt s TRUE, Een assiqmNULL +
head and delete temp and tesminate
Fesem the unection-(Stine Empty
ist cordtEionD
Step-: TE E is FALSE Then KeeP moving
mp uril iE eaches Lo last n
He st
nts emp mext is caual to NUL
Gtep-t-Assiqm uULL to
tempspeiousret
and deste temp

Difesentiate Stnele Linked ist and Cisaulaas


Lnkad ist fos opesaitions Tncert at ed ard
deste at a spedtic positio
AnSFo Lnsesting at end:
To Sinele tinkedHist
The majn stfoene beuen the srole-Lmke list
Ound Ciulas inkel ListE is thot the lat node
does not point to any ode m a sirgy liske lst,
so tts link pat contains a NuL value
Te Siea
Fox sLL
OVERFLOW
WBHte
Step-: fphs -NULL,
step-2Set NELONade =pts
Step-3: pts=ptsNex
Step- New-NOdedata=Val
Step-5 NewNade SNEXE=NULL
Step-6 Set pts = head

Step-+:Repeat step 8 while ptr>net!=NuLL


Step 8: set pty =pbsnecb
Step-9 Set pts-3next -rkwNee
CLL
Step- :C3eote mew nede,
meuw Node-shsuct Nede")mallocsige.cREtauct Nei
heuwNodedoto-Voluej
neuo Nadesnext =NOLL
Step-2:check hesthex he l i e Empty os ret
tall= =NOLL

Step-3 If ist 1s Emphy,assion nenode addes to


Eail ad
tail-neto Node
toil>net=newNede
Step:I sts roLetrpy,then tn the neusNad@-sret
ste toi nect addoss and make reuo node
last node usth-tot
as

meuode nexet=tail-next;
tolnect aneONode
tosl=neuwNode;
Step-5: Displa vatue tot 1s insexled in cLL
SLL o Delete at aPostiador Fosion.
step-Check nethes tre lfst is erpb noE
nead -- NULL
Step-2 * Set temp -=heod
Step-3. Set 1 =oo
Sep-t: Repeoct the steps 5 to 3 util the
Sotisfied Step-is
kep-5:templ -temp
tep-6 temp-temp->nede
Step-7: IF bamp-NOLL Node is Tet
Stp-3T =t* pesert-E ND
END OF LOOP
shep-: Templ nezt tevwmp-snet
sbep-l0: Reee henp
step-11: BND
cu fos delete at a foxliculas Pasilion
Step- mitialze hoo nale pohste c-P,
Step-2: Gseote a. vouriable that sesves as countex
6xable as k
Step-3: Set the Value of del to posH

Step-: Repeat Step S uontil k doecnot equa del


tn Be loop
Shep-5 eMake q-p n d p=pnet
Step-6 Lncxement the vakue ot K
Step-+: Make n e t of 9 enua o net of p
n e x c t = pamec

noce xeie ed to b the node


step-8De.ete t e
pomteP
dittexences betusen Stock arnd ueuLe
te
Queue
Stack is also
s an oxdesed list of |DLIKe stack, Sueue
DStack an oxdesed list of elemets
Similas dato type of Similax dota pes

LIFo(last in 6Lieiue is FIFofist in


2)stock is
Fisst Out)stu cbuxe
Fisst Ocssuctuse
is
3Rshl Function is uced Lo 3Once anelemert
insested into Queueall
Insest Ymeuw elemernts into
the elements inserted
Shock Pepe) isuse Both befoxe must
be emo Ved
nsexlon ond xemovoul ase to s e m o v e mew eemen
allowed ot onlu ere end
oF stock Callad lop often
fenetion 1sused
Ruonction peek
Popt ts used
o Lo e u m value of
bemove an element Psom
stelement without
Stock.
dequcnq mt
i t e an algoxithm to plement pactix axpression
Trt T T T
caluabion
Abe
Dile zeodig the expesson som l e t to siqht, push
elemet h e stock,if tE is on opeand

2Pop the u o Opevonds som stock, he elemerst


is an Operotos and then vaJuahe it
Push back the esut d evaluaton.Repeat Tt
end of the expEOSSlon
Alqostm:
DCceete a stak to stose opevands (ow values
2Scon the qiven expsession and do the
follousinq
Seve Sconned element
a elemert is a
num bes puch it irto stack
elemert 1s cpesatos, pop Opexands-o8
a

Opexatos fsom stack-Evaluate t e cpesodtos


ond push the xesutt back to
stack
BAhen eqsession 1S ended, the numbex in stock is
t e Pnal ansuey

6Lhat is a mazn9 problem? Explain uith an esape


An Computes Science, uwe con Solve mage come Sm9
Osay mdexes os the mage mabix
host, ue genesote he Cosesparding matsiz of t e me
White sepsesents bathe asea where we can -savel
dnd is sepsesented b1-Gray Sepsesents the oxea
wnese Loe connot go and is xepxeserdby
,o,0,o
S,o,1
o,1,0,0
above Should
tleoally be
Fos he oiven m a the path
to emd.
to qo fsom beqimning
qood is Sequsel to
To solve mage psoblem, the poosam
whee 1 sepeents
9enesate h e follow inq mabrix,
Scusce t o
the o path token t o bsave) Pon
destinartion

S,o,o
910,o

called Be Backbsackino
T61S uses an oppoach
used to
1s an alaotamic techrique
Aosi bin-Tt
to buld o

Secursively solve peblems by taing


is selves one
Solutiom ncsementally-The pboq sam
step oE a i m e
check 1 a
poth and aloays keep
a
le ollbuw a.
be
destinaion Ts eoched. es, a esutt uill
No, it will backack to exploxe other
Sebuned-IP
paths
matix to stose yous selution
) Fivsty,Gseate a
zesoes end Shoud be of
TE shouwd Cotain all
Some sige as maze matsix

2Make a ecussive al JEh position in matix


iniolge mage motix
Soluton motsix
From tutnation
postion ts invalid, retum
asLin Solution motx
LOEhexwise mask position
andG,i-)-
Recursvely call r position 1+4,i), GdtD, G-,3)

You might also like