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

PAGENO.

DATE

0.Nha ae the applicas ons oSiacks? EXplain ahy_of


three appuicaions ofStalKs. Alr0 Show the use
sutlble exdmple
Stacks in those applicadions usn
and algovYthms WhereVer necessar
which we
Lftns: Statk is a ype o4 datd Stuctux in
Cqh ehter an Toie v ddta
-
om one ehd ohly
al$0 called
his enterin and tieving o data is
Push and Pop Opexdtion ih Stalk
and
Thert drl humb er of aPPlieafions of StaCk

Some O4hem are explctinebeJow:

i Catkatking
DacKtadeKin9 IS a recursive algodthm which is Used

or solwïng the ORimizaBtÍon paoum


Solution o a
0tder t0nthe optimized
S0, In
ith Batkfvatkíng, we have 40 ind each
Paoltm
Possíble Solufioh o the Probltm), dotsh't
and evert
maHer it "t is Cavrelt 0X hot

n Batk}satKingwhile 1nding the evea Possible


of
pooblem, we Stort the solukidn use
Solutjon of a dna that
PyobltM ih Std(k
Paeviously Calculated
blems
SOMToh' t0 Solve tht pcoming po
PAGE NO.:
DATE

ndudStdi0.h>
tonint muJtiplyNumberyfnt h)
nt main)
int h;
Poind Ent4r a Po i tive integ ed, "
Sanlool",n)_ multPlyumbosss(h)_
Painti"Factovial of %u", n
etun 0;

ong int+ multiplyNumbers(int h)


(h>:1
reyn n'mulTptyAumbrslh-1):
ese
re uan 1;
PAGE NO.
DATE:

Function Ca
progrdmming, whtnevyer you mdke a cqi rom
Ont ution to tht anotherunttion. The dddyetf of
tht Caning unction 9eS S}ored in the Stalk

$0, whth the caltd UnCFfon Gets tevmindtHd. The


PToraM Contao move back to the Caging unction
wIth the help of the Cladyt whch wd tovda in
the Statk,
So, Stak plays the main yole whan it Con to cAing
aunCtionorh 0thruntion

Push
TOP
uNari
POP
PAGE NO.
oATE

) S t ing AeveTsel.
S i n TAVAYsalu is anothr amdz|nt
aPPlicaion 0_Stdtk, Hert on by on e each chayatter
the StaCk 9 in serttal into tht Stdtk.
So, the irst cha>dtHr o tht Stauk Oh the
boHom 0f the Statk dnd tht 1dt thdratt of
Hht String ii on the top Gthe Stdtk
AHY_peYfyming the pop OpAratton in StdLK,
We_gef he Sint in_tv{rit drdR3

idde <Stdio.h>
indude Stzing.h
e i n e max 100
int top Stack Lmax];

Noid Push(char x)
PushInseot-ing Elkment ih
Statk)OPezdtion
ltopE Max-1)
inHC*sta tk overftow),
else
Stack[tttop]=x;_
void pop)
1/ pop CRemovint eltment from Stack)
Pointo", Stack[iapJ)

hain)
char Str[]"si ldhka
int 1en Stylens)
int i;

or(i=0:i«jen:it1)
PushlstoCÍ);
or(1-0;1zlen;i+)
POPL)

You might also like