You are on page 1of 5

Quskioms om Datahuces

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

*Trpingto delh a elumunt rm an emty stack


sults an exaption calad urdenklow.
NCERT Exnise ( 52)
TRUE 0r fALSE
Stat Tue

i a unnar data skuelune


Stack False
Falst
LIFO nule
not follow
b)Stack dos ondi hon
reslt nlo undunllow
POSH optratiom may

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

Prirt ('Reult =", Tuult) Remult -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)

Ontnt: Rerult MAT

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)

SURE SHOT 3 mank. X has a Jist conkaining lo

mke gers. Crrate dehtnedunehons o


Mser
9dd
numbeTs to list
Travevse he ist and push pa

Pop and duplay the contemk o stack .

CoMMoN LO&IC: all hc) X = []


N= 12,19, 30, 40, 7, 13] for a in N
da PusH (s, N): a %2 0:
S. append (N) PusH (X,a)
whw True
du PoP(s):
i S!=[]:
relunn S.Pop) Print (PoP (x),tnd ="")
else
reluwm None
SURE SHOT (3 manks) Ditionany model
D
Azu:18 Anuag: 20, 'Bimd: 15
Wra we
duinad nchiorn to
a)Push the name o student whese 04e aakr
than 18 into slack
b op and dis play content o slack
ueaio
Common logic (RoT al saudnela Xx [[ 1
D 'Arul:1ë, 'Aura' 20,
de PusH (S, N): in D:
er a

S.append (n) D[a]> 18


PuSH I X, aj
de Pop (s):
while True
s []:
Trebuwn S. popt) x! ):
else Pint POP(x),end *)
Teon Neme

You might also like