0% found this document useful (0 votes)
14 views6 pages

Vaibhav Jha

Uploaded by

sekharpaswan2001
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)
14 views6 pages

Vaibhav Jha

Uploaded by

sekharpaswan2001
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/ 6

Paao

FRoBLEM TATEMENT
WAP to EValuste a stfix Expreio
A NA LYSIs The ostfix natation is used
alaebric eapr erjonb 7he eapreson uoeitFen in
orepreenl
Postfi
fixform coa eunluted farker compeSes to
matatior RoenAReris is notreauires
n bestfix.
Irkt : st 231*L9-
Outut: -4
Explonahon
cam it's a ruumber,So busk if o stocl. Stzcl
C0ntains '2'
Scam 3, cppin
meu cotuins' 23' (from bottom to fop)

Scan L, poin mwmber Purk F e a e ,


oa

Strck n a t h co nbairs23'
tuuo operonds
Scan*, it's a n obeab Poþ
S r c abpln dhe
ghe Oprptor
@
31
obesondb

We puna dhere 3tea


ukich eults in 3
Sfock a u becar 23
Stock The
C m P E a r P o p truus o peOnds
. Sca , it's
m 3bok, app dhetob erotos
fo scan, ue
7here asene mae elamerts
shaek
Yeon dhe top eemen peam dhe s h c l
Ckich is the oney elmontleht in
e

Trp sStr-r(oo 200+2/S+9+"


Output : 7 S?
Po202
C-Code
i n clrde Kstdio. h>
inc c lude Ksthring. h
Inelude ckabe.hy
t include StALib.S
Struet Stock

to
wsiomad copae

Sta uat Stoak * cvete Stoek Cunsigeas coa

seTu Stocl*stock =
Cstru Stock)ma0lnc
C6ine (sst stac));
iCStoca) ekum Nu LL

Stoek> top = -

-Copa - copoci a
Stek (i mallelsoel
Caulpod * ae a '*));

ifC! s tock cssan Rusunm NULL


yeusu tock

iSEm (rut Stoek* stoel)

eusU sech top -l;


chan peek(sfrue gt aclstoe
Po03
*
ckos
Chao
po
pop ( r u s Stuc gdoc)
S
C i s Eme(s4eca))
Cstack > top--3
ewn tece -> cooay

yeuun

s t r e Stoe *
stec, ches op)
voipwk(

stue cwa Ct+ stoeA tol- o p

e l u o . b s f i x Cehar es)
(strden (eop);
gtaele evesde Stoel
Sthruet Stuel
tusun-1;
it C stoel)
Ci1 +1)
Sor Ci o i ep

Cisit Ceati1
PunaSuck, eaCi (o');

elno
a 0 0 1= pop( stocL}
infval2 Poe (sttck),

Switeh Ces Ci1)


bresl
sfucl,vak2 +
Val 1);
t' pul( )i brenk
v a l 2 - v a l 1); break
Cune (tuck,
>u bYese
VoN2- Vo L);
( stoe
Core

Ce*
pwl
etaell, Val
2/val a); byen
/ ' : pwak
(
Ca
Po
usurr pop( stocl);

main C)
cha e e C3- (r2319-"
", euaude Po
PTitf E posix enaluslon/. Ceap);
e u m O;

Reru
Pof euotustton : -4
T 231+9
Op Posefix euoltio-4

oLam Stseme
inC to implamert S tac
Wite a Pros 3 m
emd,
win
wina St Likes it(Inud
De0o e ers),
ANALYSIS
impe ment a S tock data structwe wia
We have to
itin implemantakon ehs faek
nked t . Linked
baie Staok opeaotios
murN Suppor
SAsucture

iKePuh pep, pek cna isEma


moke it VULz
4.Declace headPointer elata.
Cnd

Ke aiven
ade wiK
Crete a eu
l as NULL
dhe nen made =
make
Ano S to be te
(Becawne dh
new made Oi
l a t no le)
3. the hend node is NULL CEmpls LindedLie
moke the neu maae o dhe head.
4. 3 dhe heod ade is no ul, (Zlas
aloceody hos s0 me cloment),

Sind dh a t nolo nos

make dhe Kost naks e as dh meuu

cole
inc lude <sflio.k>
inalude <stAlib. k)
Struct nade

i n lata
Struetnode n e a i

Voil oddLart ( Strutnrde **


hend, i ndval)
Stawt medereNole malloc (sie estruet
male))
e u Node dada = val
nen Node NULL
nea

f l*heos JVULL)
hens = meuNole;

strel nade *ost Nole


hesd
While (latNole>neol =NULL)

LortNodl = lork Nole -> n e t

naNola > me= meuNole;


Po
VoiPriL (3{zueTo*h end)

sRTu made Aempe handy


while ( templ- NULLD

prif (67 A", tem >Ada);


e sem mest

r i ( 6 NULL\n

Styue mede heod= NULL;


wdd Lo (Ehead, 1o);
2o)
Cvdd LON (E heod,

boidList(hea)

e n Oy

Re
020>10>
o u u , B0 Tob elamand is Bob

20>loS
O Top eQmeis2o.

You might also like