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

Stack Notes

The document discusses the concept of stacks in data structures, emphasizing the Last In First Out (LIFO) principle. It outlines basic operations such as PUSH and POP, along with their algorithms. Additionally, it touches on notation and evaluation methods for expressions using stacks.

Uploaded by

swastikghosh3110
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 views10 pages

Stack Notes

The document discusses the concept of stacks in data structures, emphasizing the Last In First Out (LIFO) principle. It outlines basic operations such as PUSH and POP, along with their algorithms. Additionally, it touches on notation and evaluation methods for expressions using stacks.

Uploaded by

swastikghosh3110
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/ 10

Momitasl.

STACK
A stack iu u onded e t cth th,teststion tiat elemet
added aud daletd tsm ont ud of tho liat
tomed top of stck wil be t
eluut
Ju stack laat addd
stack s callad LIFO
om te stack

Staeh
Basie opurains to tte
POSH addig
stack

A te he

ne' eleueut eau he


tttu

Caled S TA CK
Lo Lattow ot t

eleets

Tof -0/Top NÜLL!.


ALGhoRITHMS
G)
PUSH (STACK T0P, MAX STK, TEH)
Prat ovERFLO W aud yetuy
MAXSTK,

set TOP: TP ITEM.ruaneut tiy iuhh a


P]
Set STACK CTo we,
4)Retwn

Void

geteut)
3eiF (o).

Seaut(y.d Chiu);'
top =top+I;
3

POP Te pro ees ot deletit


Gpsratio wo e l u t
Stack u called pOP
slecreueutd bt ttis
to tack nterd
tack a d t pop
tthe eouito
usit to tach wndunfleo
ALGORITH M
PoP stack To ITEM)
W,
ttn Prnt i UNDERELO

Set 1TEM > STACK TToP1


3) 3et TOp ToP- I

(4) Retun
iut tau
o)
phutt ( Tae Stack io einpty *);

Stack Ctop],'
top - top -

Notatiqns uoruttey, bett


qpnato

)Pretn wotaion
hee opnato
aolsw wotati,
s alo ealled
t i wotatiow
Mattiettieaui Jan LukesiLeg
+ AB

wotattów oiosenseotalo.
St
AB + MHT 4

cedeuce

Expoieuál, opuato
Adsd Sub
()

Palish motaibn

The witing
Palh notetton
middl
laxieA uto 3
Pellah motn
PoUsh notatn
Prafis

2 opinnd

wn.asnitan befan

p nsten.

operanda )
Pasty cam

palsh notetien
payi at b c
to
atbc
K+ (y*x -(0/yu)* t)* s to posti

2
wvwtt*- s

9.

)//-b)
onithmaic npenon thvalvin
eonslantspeHond
e Pashngato n.
At l34 c)* (o E) FJI 6

ABC+ D£ + F k t G/t

^F/
(A +6) a c/D

At (BH¢0 - (DyE4F*)KH
EF^)*Ga)t
2 At (Be* - (D

/G*-H+ *)
At (Bc* DEF
ABe*BEe^/G* - H * t
2

Algontiu authiae npras

add "
suto sack,aud

eack eleuet
add it ta P
euesterad
eft paeuthe cis ii
stack
opnator aitquatana'd ;taui!
Repeately pop ion stacki aud add to
higlr pra cadauce ttaou
(b) Add to stack
| End, stuctw
a
paneutu, tthn

to Peach
Rapeateoly pop trom Staik aid add
opanator ctil a aft ponauthaig i Ducnutad.
Lend
Eit

Algorattu for evaluatisw postta srprissass


Add a rugat pareuthesis) at the eud P
Siaw p trom lett to nigut aud hapeat atep3 aud 4
torr eeh eliueit P wntil te
partauttesis is eutoutiud

opoutor
a) Rumoe. ta. two top eleuet of
STACK, whes

c) place ue niösult o ) back ousTACK


Set vaueeual t ti top eluieut
(4y

| 2
14 J6 12 1P

SLannd $TACk
A A
A
3) ( A
(+( AB
4B
(+(*
(+(*
(+(
3) (+(-C ABC D
(t(-(
) (+(-C/
(+(-(/4
DEF /
A BC

Is)
(+(
(+(
(8)
(+Ac)
A t L6c tA Bc
(a+8) /ce-) -tag]/Ec

Inana enr motaion


wing algnitm
(A+e)^c-(o*E)/F
olp A8 te1 DE *F/

AB-bE
(6)

,2 + 2. 4 |-)
Scauwed STACK

2 . S 6,2
t
40
12 40, 2
40,|2, 4
4
40 3

34

3 )
2

2, (2
3
3

You might also like