Partial preview of the text
Download STACK (data structure) and more Schemes and Mind Maps Data Structures and Algorithms in PDF only on Docsity!
NS ST nn Eee Sub, Code:...--.60- e Topus ‘Stack bala Ss tecure brew MOC Ly 1 Guteoures: i Stack Dela Steutchwe on stack fs a ireané oalea | Stour Hat follows LIFO ( Last i Frost Ou: ) | scented Tete Podnciple, the last elament Gers bee | Ptost fo be paped oul. Th means bott and oleleHion operations Cxcemplé DVD Box je) fins er HEL | push o> Pol | Tor c | 8 eb oP A | Lipo PRefndple ee een Se ty New elements ane olusays pusheol on tOP. Ly Removal (POP) also happens culy pow the top . : Lo This ensures a struct potcle, ? Last tu —> Finstouh. Types of stock *- Up Fixed Size stack }. ee A fixed size stack dus poxedefived capacity, — Puce it veces put, no moste Cleinents can be | added ( plas comes over pis.) le Stak Ps euply aud we toy fo veruove ne element, FF carues Uuderfilorws >) > a ae ee _ 2 Sci ites nase ope | e cw CTyptcctlly Tueplernerect wast a stebic astray, Picea tere xy | Exaupe 7 Declodring Qa stack of siz€ to Lesing Lt ceeneay, — Ly wae size S lack _ | - P ana size stad cas grew aud steuuls | automatically as needed . be af the stacks ts Pull, the capacity expands ollowes mose elements . i> As elemtuts ove grenoved, mowolhey usage Car shedulk as well, be treprblewmerded Lesiteg . — Lerted list > grouss | shedules potter lly a8 Dynastic Pecay -» hesizes abldometically, Ge wesen taller S tack ter C. The stack can be nepneseufed as a stauchwx thot Contains a fixed- Size ara gn 0 udtdch stomes -the olala of the stack ancl an Index pointer, uddch s used +6 dock the top elenient of +e stack. Shuck stack ¢ tYyPe AA C max_ size]; tub 4p 5 5 The initial value of He top shoulel be -4 Heprosenting thal shee Ane cuscren Hy no elements tu the shack . Max size of dle slack can be clefiined as Per ouby pequinements fo a War c OU wd 4 ak pes tema feevig Ny shack +. % ‘TOR 60 TAR Tarelicafs S be postin, ef S& meat . t@ lask \ SCC beef [30 }e— pop * Puse :- SH MEALS Taser y aay elermercct Talo the Steyet 4 Exanmysle ~ iL “1Reforre Pusny (AO) Apes, PUSHC40 5 2. 30 K— TP kon ToD 20 36 {to : 20 oO © yet Poo fhe * POP t- Pop mean sem oving the top elemer f Steck . oP “Bef one. POP Aftex P 4e aq TOP 30 ie __—- ‘To[? Qo 20 25 10 Bice orm = Trsent PoP ~~ “Delete Operiatfeu ‘- Page No usect Jo cee the top> elermect usithoud fox ena }PEE IK PEEK fs | gre moving th. Exaumple , 5Oke— TOP uo [se] af Per poom PEE RC) ten gelhon BO | The Go is not semoved. | Stack Overplowe- “yshen L0e tou +0 insert am elemed Suto a Stack 4tiath is alnencly po, et is called stads Ouerplore . | fom example ‘- | / Suppose. +e maximum sizeis 2. ' | | Bo [<— TOP BD [te J | Operation - = Pus C40) us couse - | | Stack, pvenplous | | i | | ta? Hall i. | Tatttahly oP =~-4 it means the stack fs empby . Exampde /- FOP = —4£ | aftes, ie PUSH C10) TOP= O Dbrso Sth Pinas Brel SN Algooitlor FOom PUSH 3- Push ( STACK, TTEM ) Step t t- Check, ushether stack Ps Full - step 2'- if Top = Max-t, cle Overflow ". Display “ Ste encnease TOP by 4. Step 3 '- Otheusse Step 41. Stone ITEM al eTAck CTOP I Step S!- step. In simple WwoHds !- en PERS Page Non. @ Finst check uobether thee is space, Va space is available, incnease 4eP and wsext the peud element aby . step i '- check speller stack Ts em| Step 2 i- ef WoP==L , Display * ectack Under Loue step 3 i- Cinersise stone STACK steps t- Decnease OP byt. Steps tH Rebun TTEM: in simple uoonels f- FR af es, nemove -+the top element - met check iohethen the stack contains an element, ss (6) Stack Using men i 10] > NULL T TOP Nene tre ToP points to the first node . Tnsention and olelefion ane penformed from ae beginning of je Luked List . Push $- A new node ce. aelded af the beginning: a~pp 37077 3° > 20-70 ; — “Tor “aT a ee Pere ‘ Po ee Postfix 2 tnpix —> Paefix ' i 4 Pathentheses mateliing | 5. Unde OPeatien ie Prowsen TBack Bullen ® Memory be contiguous : ge available . need not te