0% found this document useful (0 votes)
10 views9 pages

Prinapla: OP Eakon Stack

The document describes algorithms for stack operations and the Tower of Hanoi problem. It provides pseudocode for push, pop, and flush operations on a stack. It also scans a stack to evaluate a postfix expression and outlines the recursive steps to solve the Tower of Hanoi problem by moving disks from one rod to another according to the rules of the puzzle.

Uploaded by

Shahah Baabab
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)
10 views9 pages

Prinapla: OP Eakon Stack

The document describes algorithms for stack operations and the Tower of Hanoi problem. It provides pseudocode for push, pop, and flush operations on a stack. It also scans a stack to evaluate a postfix expression and outlines the recursive steps to solve the Tower of Hanoi problem by moving disks from one rod to another according to the rules of the puzzle.

Uploaded by

Shahah Baabab
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/ 9

FAGE NO.

DATE

Stack
A_stack_ua a ineak data Akustke
Ohich ud 2uSed in(LTF
o) lastTn frst Out
Prinapla
OP eakon Stack
Push cPveakicn
21 Pop_chiratim
Rush Opeakian
acheck Baforeush a mes Zmtack
OusefloL9 Condin _memoy-
Algotithim of flush Operalioni
Shp1 Begin
Sep2 9 T6P:N=
thin
Pinttack us olueflouS"

Steb3 eid
else
Skpu TopE TObtl

S4cpS Kead a Nanidblu_(s) Topao

SHb6 Tob datals) Top -


t5O

S exit
O
DATE
: PAGEO.
CATE

Hgotithim fop Ohoration A BC


CtC
C C+C-C AbCx
ABCD
eb1 begen (O CtC-c ABcKD
(tC-/
Sep-2 Tp- (t BCDEE
ABCDE
then ABCK DEF
Pid 'stack is Undvplow " Ctc ABC*DE FT/
15.
Shtp-3 Lrit (+(-* ABC0EFT|
elsa
(+C- *
ABC*DE
Sh- PoPLTo C+ ABCx DEFT/(n*
Ct ABc 0EFT/G *
Top Top 20 H1 ABC FDEEI/G* =H
ABCADEFI/G* -iKY
.
ap 6 6id.
Tapn to Patfir rasfasmaion
Applicakion tack:
A t Bx C- (Di E) *a) *rr) .

Th to Posixk cns fotmotionUSing Stack.


SNo SCann Stack Eapsussien-
Q At L6*CLDLE NE) *G)*H

A
S.NO Scanns Stack 2
Ct A
CtC A
C C
AB
2 A A B CtC
CtC* AB
B A
Ct ABC
C CtC
C+C A C+C ABC *
5 B
CtC AB C+C-C ABc*
CtC
AB LtC-C ABC*D
C CtCK AB
DATE
FACE C
CATE

12 E
CtCC
CAC-C.I ABCKO QTVUWP

TV_ Po
13
C+C

CtC- AcxDe
ABCD6
TUU OPON
QTUUW PO^lJK
IS tC-
Ct
C+ A
ABcDE
ABCADEKa
DEl 9 (tt QrvUwJPOA L/ EN
QrVUwPoN *Z/ Nm.
Ct*
ABcDEl
ABCX DElG 2
tt*
+t- aTVU PoE/LK NME
22. Ct
23 - +=
_Cttf QTUu0 Po A*lENM HLK
SpK t LM*N f (O AP) * w|U/v
*r 2r QTVU Pa^ *LENME LKt-t
+0
So t T * VIU|w *) P/\ oc +N* M-LtK)
, ft-+KLXMNe // * AOP U yTO.
SNO SCannLA Stank-
GMaluation o hkeassiom.

21 3 +9

(t
T 3
V
Ctx
Ct
(+ TUU 2+35

TUUY
Ctl/ Aruu 3
2 5
12 Ct |/* TUUW
5-9-4
15 Ct*/Jl)
PAGE NO
DATE:
TE

skps-
4. A
B

To uger 0f Hanoi=
Sk-6

A
Stes18egin
n numba 0f_disk.
SHp2 Guven
SkpI Skb3MOus disk z_hom A

Steb4Moul disk 2 Lom A 8


Skp5| MOu disk 3fkom
A B :. C
&hbG||Moua disk 1 Asm. A
St|mQuLe diak 3 om 8 A
Skp2 Stprs|MAu dsk Rem B
Shb 9 moL &sak 3 em A
nboeit
A

Gn Thue Totocrs A, B,c n n o disk withu.


the.
sh-3 |duouasinq Sigeblatu on ToDer A, ATMa
game s t o maue allths dak pempous
A o Toud C using Toae B
A 3
ules o Caame
3kp . A aatime only One olisR_ Can be re mbus..
to Another tousk
Pom one tootr
PAGEENO FAGE NC
DATE DATE I

ink st
Ruls 2Kakge dk can ba plaud on Smalluz d:
ink ist singt
Staic 9mjplammtalion o ackk Daubly
Circula

A stack is a dineas aay oinlin Vasiak,


TO ohich cordain thu docaton O hi to Node
Nodu-
elmand in tha kack. Ond Maz staka indkath
Stack tha Condition top uodabla Null
deftne_ stack Status Undi Plota CuOflo
Singly link-List
Condion Algotihim for nserion in a

Ryanamio Rebkuscntaion
kacki= Skp-1 Begin

I-2 Pex Stad


56 50

3 nea.nods int*) matloc Singo (int))

- Reac ayalluadata o

-5neo nod* daka

neco nada hR r

gtand neungdle

Et
7 Per loo2020o
eLanOcla
Stant
PAGE NO
DATE FAGE1O.
DATE I

50 200 hco nodds


lt Q nada om encl nala-
Start Ptr 300

S&p-i Bagim.-
Jnsod A_Noc nding Link kist atlp-2 Pt arck
ahip 3Lihilu (Pt ink= s Nuu)
Pt,Ptn ink
Atah1 Bagim ahb-4ohel Ptr linke=Ptr)
Atp 2P6r ad Pta Pty ink.
ap3 uhiu LPty link== NulL) Ptr link AtrTink

Pty Ptrlink

Sbrb-nusneds zlint x) malloc (size qlint))_ a Mda umPosition l200)


db bRaad a aluo nalL50)
th nuenoda _daka *val(s0) Lgim
tu nuenod? link A7link Abb 2 PtYgtad
bh-2Pt7 ink nuAnalo Ahb3 1shile Pti z link= = 200
Ptr Ptm link
Atp-9Eit
Per Ptn 7 ink
Dolh a mds romdliny inkk>
Otb
O- t2Jink -Ptn.
Brgim ob-2 Et
b-2 r Stat ink
un ositon (20a):-
4goaithmo
y gtad Ptr.
200 Ptr 300
Start 50 PtTL
u so d l
PAGE NO:
DATE CE
TE

stp- Bcgen Insut nodu act end


PtntSBarct
Ptra Stad
Ahb- 1whilu CPta link|= =200 Bagin
Ptn f s l i n k Ptr3Bad
Ptr2ink
whi LPtT Jink | == Nul) Pt
At 5Ltr Ptx4Link _ünt))
Khp6nusaod (int) malloc (Sizcoimt)) NusAodss lint *) malla 3ig
tb Riad a Valu val (30) Wbb 5Riad a Valu Ual()
bb6nusocu data s v a l )
Nuznad1Jnk *PtYL2ink
atp teuenode link 4 Ptr2 nuuenoda Puw-An2
xlih 10PtvTinknuEnak utnada
th9 pto2 ink
Ahp- Erit

ouby Cnk liot


siktaladink diat
Abh-1 Brgun
r 3tat 5l0lo ko s 300 5
300
5o
Ap-3 neonod =Linmalior (sige Cint)J nonoda.
Stact
Aah-y Riacl a yaluu \lu)
Nundu data=valll) Shp1- Bagarn
Kbps usnod ink t p t Aip2|Ptz, Ptr2 stad
Ptr Pr snusnoda Aurnods= lint *)malloc lsize q_nt))
Atb Jtantnumds Raad a valus Val (1)
bb-9 uunod u at Ahb5 nusnocl uta eval C)
eit whib (LP7 ink i = Ptr2)
Atp-D Ptr Pt r lnk
Stp- Ptr unk
nocdu
3nuanode unk Ptra
up
Skp 9 tat reusnoct
Sh 10Ezt
AGE NO

OATE CATE

900 300 Repreeventakion u u s


niwnoda Usin day
Qusingduink-1iat
Hom txPLr

Skeb1 Bgin. ) Reax (Chserion)


At 2 Ptza Ptz ad r o r d[elakion

nwnade (int *) malloc (size ot (int)_ D|usina


Attp5 Ruad a val (90
nLanoclu9 data ual(RO)
naonolu GnkPtru ink
RR 2max-
Ptr unk - nonook
A
dtp 9 Etit
2 |Using

Head Node is tha fist nodu nk Lst List

oSimbuNocle dnq Muadu_noda u baca Coalxi


the diarnca omblariby ina_Lormplaziy
in simpls omoclu th daka_paut w 1 uN but
n o d u dataþamt t Sqskm 0s
in headu_
|Called System nool doest not toe alu Rest Aug
BigoLO)
Sau- otal no nodo

Mazim

min Tim0

Consad
hi hega
humuaha_kam
A

Paa omplo
acor Sum Natival no
Commad -1 ind Sum (ind n) -2x1 2
Oatayk
(3 Commint -L inti Sumco 2X0 2 20.
Vania bl L foe h u=li--J2*| -2
Corstard Sume Sumti
ehunSum
2t 2 t2

+21

est Aug wA
JU) 0IS) 0(h)

You might also like