DS Assignment 05
DS Assignment 05
Page No.
-shrkant
793
Assignment Na S
Steck
SET A
shadic implementaHon_g
APAP impemeh
Siack o n leqens lHh FollUIn Aenakin
La Tntialhe (O
06) Push O
) Pa0
ca) iemphy
Ice ic full
disphy c
inlude stdioh
inchudesdlibh
pedefStnuc
inttapi
int ilemLsfze
STAc
void Tniialise s1AC s )
nd iScmpi C1ACK )
retuxn CS0p== -
in POn STACk y )
eturn /a
Moun
8TACl S
in ch Vol
Tnialise (KS 2,
da
Page No. shrikant
Dato:
mint f l n d Push
intE ( In Pop 5
pacindEn 3. " )
pantEn Entcx chaice
SCant C .d"kch)'-
Stuilchch)
case Push
(s))
iE Cis full
FULL..11 ")
oindf CIn STACL
tlse
),
pmintf ( h Eotex Vodve
ocealk
Cose 2 Pop
Ciceph cs))
PrindE nSTHK Empty )
elae
vePap CS)
rinie(o Tiem Poppel:d val
Ln3
Page No. Shrikent
Date
breeak
Cose 3 xi to
3 hile Cch!c3)
implermer
WAP Ho Damic mple.menlaliob
sAack
Stack in deqe h ollouwing of
(a) Tnilialize () operalfon
Ch) Push ()_
C) Pop
d) isemphy )
() is ful )
CE) displos )
perk C)
t alude Stdiahy
inelude Stb.h)
3trUct Stotk
int daa
StruckStatk neat
Void Push )
void Pop
void display 2
node demp
iemp malloc C8i2e O (nade))
Cnode )
pxintE C In Enteg Dale2
GcanE d lempdosle)
mp nexf NULL
Yetuy demps
aode emp
(new node NULL)
IECSton NULL)
gto Enewunode
Mewnode
else
temp tord
L723
Piage No Shrikont
Date 1
CIn Doda
paindE C*In
Pushed Taio stocle. ,
void Op C)_
node emp
(Hep NULLD
dempStay
i Sta e = NULL)
ree Ctep2
aptemp
nld bisplay C
nade demp
NULL_
F Cto p
Empiy
paind£Cn STACK
else
emp StantL
C In Elemends in the steck:"1),
pint
printE ( p 3 d " emp deden
uhie emp o p)_
em temp nez
datt 3dHemn dake )
Oho m-enu C)
hoy h
LT3 Shrikant
Gate
clasc C2
clo
priniE
c Inln 4*** MENU 4)
C In 2 Push ;
p r i n i
;
ozintf
CIn Pop
3.
puintf CIn Disgloy"
gvintE
pvintf
CIn 4 Exit )
porintEC" 1 n
bintf_ chalce ")
chec)
cheQet
yn Ch
UOid maun C)
choc h
nade rew gde
che menu C)
SLkeh Cch)
Cose 1 ush
nownGde = aetnode C)
Push Cnewro de)
brseale
Co.3e2 Pop
popC)
oreak
Data
y723
se 3 Pisplasy
Disple O
breauk
Lase IExit
eit(0)
whie Cch 4)
3ET 8
A toreverse +he given
t c a n d dnamic
sng
bsing
usin0
implemendefon OK
i n dop 1
Chog 3tack C MAX)
choy PaD C2
Void Push Cehor
int mcun C)
75
Pege No Shrikanfy
Dete
choy Str no
UnSigned int
pintfC
gets Csts))
CHep Max-1)
ok T+ too= lAeM
cher Poo C)
Page No, - ortt
Ly729 Date
iECtop 1)
STAck UN DER
ritf 1 n
yetu Stadk h o p -
include stdio h
(stdhbh)
E inclv de
Struef nade
ind dode
8truet ngde ret
int maun
Display Stay:)'
pisplt
pinHFCnn Inve
Invex ing
*hecondenis a Ahe
RevenseCstod
ewindf C n
stock:)_
he Coniends in
YeveSo \n 1 sdedk afHer
pisplay Stord)
Dele le Stoc :
ol8e
Preye StogdH
emp S t o d) n a t -
et
stand C Stog pe
p e y - next=NrLL
nee NUL)
CC Stond)
uhie
Stoxt)
Void Dk ply (truct_node
Pstat NULL)
Cn Endey ength
o ist
zindf
Stood emp
CShen ent =NULl,
else
mp nett Stas
sto em
emp staor j
stond= (tSta rex
Evte (Aemp)
Page No. Shrikant
Date 1
SEL:C
verse the gBacK by USing ecUTS
AlAP to ye
Function
include stdio-h)
define SI2E1
d e Fine T RUE
fine PALSE
define O0
StruCf8tacK
nt dep
l n t alLs12E,
st
vold tnitialise c
St.te =-
nt isFull
1f (st.top SZE-1)
retirn Rut
els e
retun FALSE
L723 Page No. Shrikant
Date
fnt i Empty C
yetum TRUE
else
xeAm ALSE
OdPush in nu m)
F Cis full c D
else
nt Pop t
else
StAop st top-
Tetuyn s t a LSt He pt
Void D isp lo ()
iF CiS Empty 0
Push Citrn)
else
nt-oe = Pop
ns BaHem (iem)
Push Ca p
L723 Page No.
Date
shrikant-
Naid Leverse (
intop Poo C
ind gesize c)
Tetumst. op
a mn ) _
i a E i y e z p r e s S i c n
Convest
2 AP o
pa3tEiX expre3sion
nclude stdio-h
define SI2E 20
pedeE strycE
int tep
Chor detaST2E)
tSTACk
CSTACK S )
yoid initiolise
etun le p: D
Yetuon Cs dalt
sop--)
chos Pcek (STAck S)
Oose C etuxn O
CoSe
Yetun
Case
Case yetuyn 1
Case YetURn
Cose etuTn
Coge A etusn 3,
moln C
SConfC19 in Eic
ConvextCinix Post Fiz/
ep1esslo 1gn
pxintE Cla Pag tEi
pastEin 9
Oste
yold Canver t chox
ia Lic L2O1cho
int i
Chc ch Chi
STACK S
0ks
laltialis e ie'\d A
fos Cisg InEix
chs io fiz i )
S i tch ch)_
CoLSe A
Cege
CoSe
oe A
while (list Empty (s)k
CPrioi CPeek a-S)
CPrioi Cch)))
23
pOetEix Io
nclude conidn)
Aelude
deire DAAX 20
4723
Page No.
Date: I
Shrikant
l ch =a'-lche '
i f Cch=E
ch 11ch := N)
etusn
3
else
E
x e t u n O_
f CisOoemalen Cch) )
CaSe
NeS=NOA
b reak
NOl A Jal
Case
yes Nol Valn
bYeak
CaSe Ye Va Volo
Oeak,
Case yes= Val vola
break
CLS e A ye pow (vol val2)
bYe ak
else