0% found this document useful (0 votes)
8 views24 pages

DS Assignment 05

Uploaded by

Ayush Gunge
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)
8 views24 pages

DS Assignment 05

Uploaded by

Ayush Gunge
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/ 24

Date

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 )

ind isful (sTACK


Page No, shrikant
Date:

Csap Spe -1)

S> iten 9 up 1=Val


hodntf Cn Vdue Pushed 11 ")

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

Pash CkS Vall

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

pde SAnuck Hock nede


hode SAo NULL
nod Hop NULL
Pago to, nrwart
y723 Data

Void Push )
void Pop
void display 2

node t qet node ()

node demp
iemp malloc C8i2e O (nade))
Cnode )
pxintE C In Enteg Dale2
GcanE d lempdosle)
mp nexf NULL
Yetuy demps

VOLd pu&h Cngde ewnOck)

aode emp
(new node NULL)

Dint Cn STACK IS OVERPLOW 1


retun

IECSton NULL)

gto Enewunode
Mewnode

else

temp tord
L723
Piage No Shrikont
Date 1

,,hile Lemp 9 Nent NULL)


mpemp neNt
Jemp2 EY Enewrode
ap newAade

CIn Doda
paindE C*In
Pushed Taio stocle. ,
void Op C)_

node emp
(Hep NULLD

dempStay
i Sta e = NULL)

Dintf( \n lemend D0eed i d


ta0dua
Sfor NULL
ree Ctep)
tnNULL

whe (emp ? neNa p

emps demp net


Page No.
Shrikant
Date /
Ly723

emp nexd NULL


porintECn Elkemendapp.ediS
Pappedisd
ud"'
tap dota)

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

nclude tdio bh)


include Shingh
Include stdlih h
deline MAx 20

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))

Pash Cst C)i


Fori-0 shalen Cstn)H)

antnti Cn Reverte SnAcs)


PuHs Csts

Moid Pugh chc tem)

CHep Max-1)

osindfOn sTACK ONEREO ),


retuTY

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 -

7evenp ne qlven nUMber he b rg


2 AP to me ndoHon sto
dnami inmp kimendotlon
Sta-ie_Ond

include stdio h
(stdhbh)
E inclv de

Struef nade

ind dode
8truet ngde ret

Noid (zeode trud node )


vnld_disploystauct node +)
void Reyeze sdruct node )
vold Delee (gtzuct node*

int maun

8 truct node stor NULL


reo StCt
ndf n Thrt Seuuene
e_gf Co ntent
Pege Ho shrkent
ate

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 :

id Revense stoUC nude A


Stod)
ctouct ncde emp prey
F StortE NUL

xintE I n Stack does no


exit11
clte P C to) exF= NULL

Oxindt n Srok node Stodk vey er sol


inqSr dlE fkotn e
elsei (Cstot)>neNct nerdz NULL)

gtor Cto.\ nened


Stoot) end nendNUL
Pago No.
Dato 1
Shrikant

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

lemp nerd prey


peytemp
Hemp 3togtL
t a e(Stayt)>next

emp nexd prev


(Stoo+) neMt emp

Stoxt)
Void Dk ply (truct_node

Pstat NULL)

intf Sd 3tot dote


Display Sto ed

vold Creae gtruct nade * Gta


int num l
etee
Fige Ne Shrikant
Cate 1

Cn Endey ength
o ist
zindf

Scani C ' d num) list )


Cox ie num 0 -)
emp (Struc de )malloc (sine of
Aempdadai
C sto ENULL)

Stood emp
CShen ent =NULl,
else

mp nett Stas
sto em

VOld Dele fe CSHmuct Nude gtot

struc ngde demo


whie C* gto NULL)

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

i Cst kop -1)

yetum TRUE

else

xeAm ALSE

OdPush in nu m)

F Cis full c D

prind n_STACK ULL |

else

st.ast too +1) num


Stddp t

nt Pop t

indf \ n STACK Emot )


Page No. shrikant
723 Date:

else

StAop st top-
Tetuyn s t a LSt He pt

Void D isp lo ()

iF CiS Empty 0

int tmo Pop C2


bisplay Co
Arint s d emp
Push CHemo)_

YOLd TnS BodHom nt 1em)

Push Citrn)
else

nt-oe = Pop
ns BaHem (iem)
Push Ca p
L723 Page No.
Date
shrikant-

Naid Leverse (

iF CiS Empt C2)

intop Poo C

Ins tam hep

ind gesize c)

Tetumst. op

a mn ) _

int tiolise cst)


Push CO
Push (2)
Pugh C3)
Push 4)
Aush (S)
Drinf(n Oziginal Stask")
Displey C
Reverse c
prtnt nReverse SBack2
Dise lay
Date:
4723

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

int istul sTAck *S)

return Stop SI2E D

In is Em pty C STACk *S)

etun le p: D

yod ush (STACk* S chon ch

scoda [Soo sch


723 Page No. Shrikenty
ate

cho Pop SIAck *s

Yetuon Cs dalt
sop--)
chos Pcek (STAck S)

int in ltCchax chD


Switch ch)

Oose C etuxn O
CoSe
Yetun
Case
Case yetuyn 1
Case YetURn
Cose etuTn
Coge A etusn 3,

moln C

VOid Co nvest Cchog C cha C)


c has in fix t20)Oost x [201
pintEIn Eaier Tnfir Expressitn
12-3

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)_

Case c Push (k s ch)


bred
CtL3e
CCL Se

CoLSe A
Cege

CoSe
oe A
while (list Empty (s)k
CPrioi CPeek a-S)
CPrioi Cch)))
23

pAat Cix L Pao CLsS


Push CkS ch)

Cse Cuhile (Cch4: Pap CUS))1er

postEix Litt chi


bxeauk'

de fault post iy Liat:ch

Chile CisEmpty Ces )_


eOst FixLita Pop (ks)

pOetEix Io

NAP o eNaluode eOstEX epresSlan

nclude conidn)
Aelude
deire DAAX 20
4723
Page No.
Date: I
Shrikant

Intisopemades Ccha Ch)

l ch =a'-lche '
i f Cch=E
ch 11ch := N)

etusn
3
else
E
x e t u n O_

vaid moun Cveid)

hox postElx MaxJ


Int a l i
Chor h
int i a tops0
Flacd val Stack LMAX val d vala,es
closca C
PrindfCn EnteK a Po gtEiy Expressien"
aCnF ( 4_past Fix)i
Lwhile (che_postCix Ci 1=lo)

f CisOoemalen Cch) )

Valo val Stack L-tooJ


yal Nal- &tak Aep
Swth Cch)
I shrikant
Page No.
Date

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

yal- siack Lt0pi= vess

else

val sta oktop=ch-4g

prinaf Cln Voluec o Is posifix


Nal-Sta ck To1)
aech C2

You might also like