009 Stack & Queue
009 Stack & Queue
T mplate
temp late <typenam T
T
S+ack S
i n eart data Sthactues
2 4 iSO DT
Recur Sie tpe deuta Sto.
) LTAO CLo in iost Out)
OPecotions >
JmsenHON Pus
Detetiom PoP
toP
PCcess top ele
Si2 Qf Hacu Si ze
To hecu iMed isEmp
Tm b l Stack CSTL)
incude LStaCu>
Ldoatq- type Name ol S t a t
Stac
Page No.
&ue ves
)Lineart dota Stra
2 FIFO Cinstin fiest Ouk)
dd elomemt engveUe
péMOVe elmeE dequeu
fraonH(
2etSi2el)
sEmply2
In bui E n e !
imclude <qveue
PUsh fron+O empyO
POP C Sieec)
PUsh
) +hen
motc un
eS +hen Pop
Courn domwaMd
OR peldm fODe
Date
Page No.
2 Re verse a Stack
2 3 4TS )
. Re vecSe
queue Cint> impu
8taCk int> hepen
inpuE
input.
hlpee
Oseul oR NOt
i Ne mot enCounten +hem PUSh
eveuythng imto Stack
ASten enCoontern JUS+ Pop UP tho allment
Upho N2 geF ( and ont maintain
(Coo e0 Il Coun:1) netorm
OR nefomm adSe
Page No.
5 Sock SPan
the mimum mo Ot
Com se culivo dauy8 (Stanting forn today)
Sorr which Stoc Waa e Ss Hham
today'S Pmc
6o 100 0 80 120
C 2 31 4L 28|)
Laet ang=i+l
Qlse
anS = i- St topt)
A+ RoutPUsh the? mto the S4aK
ans
Psh
S4 enp PUsh
mot empt
id bp Pop (i11)
else top 3 > PUsh
tOP moSt
Rotomm CoUnt
(4C22
G = C2
Ornd
C
CoumEt)
thod's the anS