Professional Documents
Culture Documents
methawsm
e , onganise
a
dlatastnucure detnu be
A oberaions
iat can
with Alh
md aen data alomg
on the
data.
eciemtly pertormad
elemens a e
0nganised
in wrich
A data s t u u l i u
caled inean dota Atuctiou
Jna sequence a pile
struiuore
which
data
A Stack a limum
Rimgs nemove
elememh om
hew
elemenh o
W e add
One end omly [ ToP]
Last In - Finst-Out Jprincáple
ol sLIFO L
PUSH
Isationelunenth is calld
n called Por
Deetianelumenth
usH
new
elment at thu Top o the
PoSH adds a
an tinsetionm openatiam
Stack. I sack until t is l l
elemenh o a
can add
t l shack Hels
*he
elumant to a
add
T u i n g lo
an
in an 'ovenflow exahiom
PoP
PoP openation nmoves the p most elemank oa
Stack. L a delotion operakiom
Fadse
2Find te owtput
a)result : 0
n umbenlist [to,20, 30
number List. append (40)
sult =ult t numurlist pop)
Tesautt: Tunlt t humbeslist. opt)
40
30 30
2 2
Drsult 0 + 40 40
sult 7
ult 40+ 30 70
Oukput
anhwe appnd (T) T
answe. append ('A') TA
arsuen. append ('M')
TAM
Ch amwel fop O
ch M
Otkput ouput +
=
Duput M
ch owwwe popt ) A
MA
h amwa popt) T
MAT
Owput- Oultntsch
Pint ("Reulk - ", alp)
Somple qmestions
elenmenkh in a ist- Tsaversing
Movima twowgh
tuk
an element na ist -
Imapectimg,
StackK
eXomle o
-
am
ile o Jooks
Appliakons o sha
convovion
Intix
6 potix
Reverse oa Atnimg
Evaluabiom Postix
4 Matchung. Paranus
STACK ACD B
delshd
R b
PopGop (STAC K) dolel ACD
B
C Pop (sTRck) ACDM
Ci) Push (STACK, M)
A delhd
(t) PoP(sTACK) M
Final stach.
Suppase a STAck s alloted 6 memoy Lotontions
andl intiall SrACK is emp (Top=o)
Give e owtput o the gollowing prar
Segment.
Output:
b 6
Psh CsTReK, a)
Pwah (STA CK, +)
Push (STReK, bt2)
Push ( S TACK, a+ b)
Push (STAK, 1o)
wtile (Top > o)
Element = STACK. Yopt)
Paint (elemenk)