Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
17 views
31 pages
Unit III Stack and Queue - Watermark
None Ok
Uploaded by
Pratik Bangar
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Unit = III Stack and queue_watermark For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
17 views
31 pages
Unit III Stack and Queue - Watermark
None Ok
Uploaded by
Pratik Bangar
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Unit = III Stack and queue_watermark For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 31
Search
Fullscreen
[oki whot¥s doto glaucure? collect/store the dalo » llowonise the data Qcess the data. manupwate the data . = Slack is lagi in first out Clio) os peveh tn lash Our Cato) P gt is an ‘ovderj let of the cope bye of clemenis. i = A stock fe a Mnear [Pot wheve all inseatchio n and I| deletion ove permiled only anyone end of the lfo+ rWhen elements ave added. to gtack i grows at one end_similavly when elements are deleted From oa ~ Slack Th stwick alaione end- Figure shows, expand and Shreenking of Stack Tope ED ~Iniialy ‘elack % emply I 3 if f’ ‘ ie ] Toure patel eee ‘| tep= =! I rr figure of insexion, OF (1213 Im Slack. | Poe ZX POP. 2 | vops2 mwatco 2 [Toes [topo + 0 - Bere ; mos p Vrain Top: 7! = === @ scanned with OKEN Scanner7e avarioble Lop point to% [Bet ; : - *|Operalion on a slacks- al 4. TriVal’se CD - Plake a slack empty 2. Empiy ©) - To determing if a stock js empty or) 19. mot T 3. Fall C) - To determine wlack % full ormot la Push ()- TF ctack fm mol fall then push a new | alement al the top of the stack Cstmile +o Insert tn a list) S-popC) - If Stack fe not empty then pop the element from it Slack, Csimilor to dalee from a list) Write structure from slack using avray é Fone dimensional avray conbe used to volb clemenia of 0 Slack : t Anothee variable “op? 5 used to kept Mock of He index of the top moét element - a, , Tap —> Stack qrows from left te maa) x : ‘ @ scanned with OKEN Scanner=A stack a8 Moy be define a8 Followss _ type def stuck stack int data Cmax); ‘int bop; % stack 5 j— — - Here initfobly top issotd to —\ X -A stack with top as —! % an empty okack CF When the value of Lop becomes. mox -1 after sewes OF inseaxction tts Full afters “push” opesakion top= top +) Cstack growing) 3 ‘ | motion top =bop~1 Cétack sirenking) funchon push.to implement Stack using array write the push and pop FuncHon stack wating, array | [Pht max = & [int stack Eman] Ob Top = =I is Fuh) [it ae "GE Ctop = = mon 1) | wekun True 5 ase 4 : | Tern False 3 Push Cpoia) @ scanned with OKEN Scanner|| { | Top= Topt! | | shock fr6pJ = Dota | 1 4 os + | ase. i f | Lesantiow 2) ——— | is empty C) : ic . T TE C16 $u 07) : ; [ | Vf CTop= =~!) ! eretuin True) ee eg WS oa tt ee | medurn False ’> 4 ! pop a Lint Data if Clfsempiy ) Data = Stack CTop) | Top=Top-} a ese q | | | | “underflow” 4 : 4 [Herve top variable fust pointin A stack: g§iothe atop of the @ scanned with OKEN Scanner_cHere adr fe abstract data bypen A stack is an odes ligt ubith the aeslichton thob Linseas tion ond deletfon can be perform af only one tend of Hhe I?6t called Ehe bop- ane mo Push equivalent Eo and tneert Pop equivalent to d al eting the most ¥ecentally fnoert element A pop onan empty | Stack 6 consider to be an errow a Push operation | of a stock thats. a full is an,coneides bo bean error Structure uged from Stack.) | | j type def struct stack ins data Cmax )s ind tap 3 “GOA gtdlcke ? r Stack data S\ruclure fe very usefalie; , F few of Ths Uses are given bdow. Le @ scanned with OKEN Scanner| 2” Ex pression evaluation J 3 Passing ! 4- Simulogton of Tecurtion — 7 function cell —_—_—_ | = There ave three populay method of vepwesentah, OF an expression O) rnirix ~X+Yy (operator bet” opevand ) ] 5 PrerPK— ry. C operator befose-operand). ©) postPfx - 24+ Coperoto x oFtet, operand’) EIntix expression ave evaluate ler bo righ} bub Operator procedance must be Loken into aceount - For. €.g.- C+ Y*Z -Hete yond z wil be mulliplying fives and itwil beadded x j for eg. +S#32 Find an operator Prom Bight hI and perform the operation ; A Operate is multiply therefore o%2 0% multiplying, the Second operator is + fhevefow oe V @ scanned with OKEN Scannerfind the isl opevoer from the lett to vignt 1n_Fixst operatoy is and thetigee Band - — rExpression becomes S6* the second o is 4 Sond = uh eR axe added Yherefove expession Bagh es ai. Given 6 53+gH + @ scanned with OKEN Scannerposifix expression show all step -eme uate Follow’ Fxg iT exolwal followin cs10 , dzis eg Sec? “i abectd-e+ @heve a-S 64 >| step Expression etack ere be Crd=e + ¥ c+ ae c+d-et +d-et att, The value oF postfix expressfan ie 2) @ scanned with OKEN Scanner| Evaluate the Follawing postPix ex preesion using stack 6234-382] 4 H2S 34 ) step | Expression Stack | uy © G2D4-3Rt KASH LW 7 | p22, 2AX-BBUAstHWBRL | 4 Ye] i | [IPs [ a4- ary k2day +A 4 38014 kK 2534 = te} s — 88214 agay i 3 | | I we fa te 6 S821 +H 0$34 | ai 1 —) 7 Brute 7gda+ | a g U+HWS st | ic | [ | ls {re odo + | fH Yo TR 8+ | 3 | nen u * 23+ i | tS ha 2st we 1} SiS ts 3y y @ scanned with OKEN Scanner16 END — The value of postfix expression is Sa Evaluation of prefix expressions- The ~ preFin eRpression is e @ scanned with OKEN Scanner(B® C+DRE -ARC Expyession | outpuk- RIB RCT DREAAC | + — | IBEX C+D RE-AKG A 4 d- [eax CHDK E-ARG DLA [ae [eR CrpR EAR ee | | | / Ss CMD £-Ak&k C AB [¢- [SDREARE [ABC + : 7. DRE-ARG + [eR 8: KEAR C | ABC ¥ TD 3: Bana | [Rack XID bs Eee Inno R WIDE Ak C [ABC%% [De t* | #C [Rocka [Dere® fm | = . ARC ee DEtE Tas “RECEA IDE + @ scanned with OKEN Scanneri tr aabe Cos Fave wall Ae = tb% Cold$ a) jh Nulb> a [3- [ beer Say 1b { ex a Ce * Celd gayle yt aw j= 1 teid say Tb <= ab € | clagayle = + abe Taboo REC — ah §_asavre RUT late Sadi FCI abe a i (orb SECS abel | " 7b ARETE abcda” Tabeda +kCIS) @ scanned with OKEN Scanneroutput. cae “expressioo + stack - a No oS. SS ee eee i %3 ‘ li pokcoa i ——_| ___—__7___[abedod [6 Pose _ +/ abcda$ | is - = abedadl® 6+) ~ | Thesefore Intix bo posttix exp¥ession 18 abcda gx b+/ @ Identity the expression ae convert tin inte Temaining to form - : [ i. ab Poe a FeSh mheve $ - exponed at — | Forix expre S100 o- | = (CA+B) *c -Cd- oe) Feet Oxpression +- : 2¢ 2 fk +PRC-DErea. + at aR | | > | 2. “AieF CEE InFix expressian Be [7 = A-Bieewag 6) Posthix expressiarr:~ : | | ag cpeg*/- — ad @ scanned with OKEN Scanner| Gloe the followin and preFly. pax blo xd-ele | | Di Case yiCrd) = 7 Dhato+cyd Q infix exprescion Find thety Postfix | ng_missing expession inthe ible ! i i akblc xd-eif §_ Torin [bretix | Post tix 1 [core xO Ter) Jestpero/eF Tascawee +] | =o oeesnestesendictlc cs 8 AERKC AAKHC AB CEE | fl | / | PACO+C)-EIF | -HA+BC/EF ABC +e EFI — | | | prefix expression — ~* 1% abcd ler Post Fix expreasion - abac id ¥eFle— WV} Carb) Co+dy eee pREIX Expression- Htastcd | PostFi x exptession - abtcd +] ae —_ @ scanned with OKEN ScannerFdentify he expression 0 Form + oe zo aktblexd-elFf _ KWN/ Prefix expression = a —#/* ler 7 4 Postfix expres G ¥cldeeF [- beAktep [tabtcd : || postFix_expression= ! HB Abt cdt/ @ scanned with OKEN Scanner+9 Convert the given infix expression (O$ 6) ¥ C-d/g ry stack Lin pestBx axp* Sa “_|__ Expression _ | $b)¥c-dd | &)% C-d © d* ¢-d/d * C-d/d Cdk ey —— : q ee > i) a d a Empty -1 Empty Empty @ scanned with OKEN Scannert | | Convett Fhe given anfir expression to Besifix | expression CAB -Cc#D)) [Céx®) IGx expression ghack oud pur areal rs: aT c Empty { [a - RIE ONGD Cf a [= |[B-Cc¥ Dy) 1CE+F hi C*¥ A | 3 |-Cceo) ETE) Wo an re EREN LST ae 7 CRDICEFE) | = CBE 8 |) CesFY | -C ABR C 43% |D)) Ce+F.) [=Ck ABEC | lo" | yy] ere): [=ca AB¥CD 4 ne | ces =C¥)___Tpakep B. (Ce+t) een a [Cet Y Emplg aeKCD=* @ scanned with OKEN ScannerABECD -%e | Ke is. €+F) Ka ABCD -¥ | 16 +F) IC ABx GD -¥ E {| | f) C+ ABRCD-KE 18 J LiC+ ABK CD -¥ EF | 19 Empha C+) ABA CD-*EF 20 | empty GS AG* CD-a EF +] | { zt éemply femphy PBKCD- ees] | | { | | | | | a @ scanned with OKEN Scanner—_—. : post fx expreSston shy step In tobulag Fotm Q 4 Evaluate the following the, stack after, each” posthx expresolen POR+wGTI- gwen Pee 4° Gpreesion ___* ff | tes ye tote pepevsrl- @ scanned with OKEN Scanner@ scanned with OKEN Scanner3 r Comet Tha gen infix expression _4o posi, — ass ee rte a on apmesion __|_Stack ouput - fp no [ a To lenee)-Ce a) et) | _Emetg [emery a 2. [Ak )=Ce-D)IETP) | 6 Empry ie 3. [ eb) (ed) (E+ AC A a G_ |B) - Ce-S) 1 CeREY | C# A a ts y= (e-oy]Cetr) | ox Ab a & | -teayetes?y 0) —_ c ¥ (CD vICere) =— ~ ERS, SEES) -¢ ABe Ts a5 tet a 5 10 | D)/ Cetr) Zee ot [ W DMCe+t) ae ED 2 ou @ scanned with OKEN Scanner: T Worle a short net on tail yecuts! tall tecurifon be yveFen, at on? the last ine : -Tain recurtion con. aecurfon call bo “gem ent pe - This moihin, smal call Harsh ~ Pecarcive @ scanned with OKEN ScannerWhok te the queve Aspectoh point of et Where items are insested os one | | end.) end the yate end and deae From the other end(he xo tr ~ Queuete Working Piabt in Fri} ouk CRE Fo) arate an Fron® Reas IdUorioUs Features of operating 8yetem ove imple mented Oo using a queue: J. Bheduling of proceseos: Ctounded vobro T algorithm ) | 5 ; de Spoling Cho maintain a GUEUS Job to be prented) P B.A queue oF client procese walitng te vecieud service From the server, process - 2 Various application Gor twang ustag non-lineoe date, 1 [great Fite traveller Glvucture Tee oF graph req ved ave Queue af “Simulatlon ofa real HPe problem with the purpose oF | understanding dis behaviour. - | @ scanned with OKEN ScannerT Jomriival rake gg Bevurce time =< %. No oF Service counter @ | Nome types of queue explain any one 1 deloi] of 0.) Caplan is Implemenialion using any one methog~ Ty pes of queues _ : LSimple queue: Pireoerquenet theala 2. plovity queue 3- double ended queue oR. L A-erseq Tineat queue and Circulok queue an avsay sepresentabion of queue Yequireds 3 entitia, a+ An ory johold queue element 6A A variable to hold the Index oF the Front element - © P variable 40 hold index of the tater | element . . # define max 30 typede? Struck quest | jot dota Prox]5 [| int Front, tea% 5 | J queue y | — Se eee ir 4 @ scanned with OKEN ScannerFront hee veav= -1 Front = -1 . Max= 6 —fi queue con be sepresented bya linked etruchise of elements each element ie ctored ina node memory aro. fot a node conbe aquired during guntme thro) the cFunctlon © mattoe™ | ‘ + | Front TOE | clinked sepresentasion of aqueucs, | 4 A gueue can be declared a8 Follouis 5 - | typeder ehruct node | £ [ int datas ' i Struct Node ¥ news to ‘nodes ; i y pedet Struck @ @ scanned with OKEN Scanner—vwhere data- slore queue element next — store the address oF next node holding the next element of O Quey giruchire Queue CO) has two Feld € R- Addresor the vare node fea F ~ Addvecs of the Front node ij {-$— ‘ § it oF as We — a : { = A Front roo ~—t Fre . C estolus of the Queue atte: further. ingerclion of 9s ° Sepplain the gueve implementatoo using any one g e method 5 F F fA oat seer operation on a queue includes 4) Eni ializec ) ~ Tnitialiae. a queue by gitting — yo __the value of sear and pront yws0 2-) @ scanned with OKEN ScannerInsert and dement at the wore end Lo a oF the queue syd queued < delebe the Front element and wvitlen thesame- aT ‘itken |__| |S emply ed & Tb elev Prue C1) The queue.létmpk and yeturas alse Co) if thequeue s a Dot empiy. . t 7 | | 5) Pull CD 8- rb veh written Tue i) iF the queue | is Full ond wiithen false co) iF the queue fs not rau. 6] print 5 printing of o Queue - Wrile a ¢ theert FINE 4wo imple ment queue using a array , |= function enqueue C) = =< Blgorithm. for ingearchen ina queue [ 4 Tseng. in.on empty queweg- - = R= “data Tel: X53 KX isthe element to be insext both Rand F will point to onl yslement oF the queue) @ 10 SS inserting | in non ae queues: “ke Ral 3 data fey (oy @ scanned with OKEN ScannerJWrieashort Note on circulot Queue of mame Hi OF queues enplain ony one in derail: Etheve t one polenttal problem with Tmplemenlaigs GF O queue using Simple array fhe queue mo beappear tobe Full a although there may. be som, Hest fn he queue a to 2 OW ge index _ £ pig! Z | Hs 4 [ Front vey i OA»? 3 4 <—index Front reat, -In Pause queue (6 Pall alls ht 7 | Go U9 Seahton Cand Loe - APter the insearton of Sel Shown 10 HS agp ement in the array as and Feo - i Qik Full F APtet the jwo euccesalue, deletion 2 eeu $F ‘ el, @ scanned with OKEN ScannerSauannE eens ~ Queue in FF | gure ig full these is no empty Gpace a head of va%e. a Oy ~The simple solution 16 thar whenever, rave gats to | the end of the orsay 8 atound to the begeining TOW the, aTea oY asray cap through of a8 acivcle VU) the first position Follows the, loot element | oy \ POS Sears 2\" . eCisculay artae -In acivculay avray ao Queue ‘is Found some were around the circle in consilatve positions - gont 4 { co \\' / asi SSO oe 13 7] Gonce ptiol ure te i ‘ i ee @ scanned with OKEN ScannerF Petorily queue ® an orde Niet oF homog eneous | clemeht ina normal quede JBeTUICe 18 provi ding first In Firsk out - o Fn Q priority queue gesvice (s not Provide in a basic of first come Firs! SeTVICe but raul that priowly base urgency of need’ ~An element with Figh ee prouby proceed befote with the lower priority . - Elements with gome prlovtty ave : OCR e e *Fiveh come First gevice? a meted ox { De rina que A f fiq of 0 mie | : LeU | l Cicue } @ scanned with OKEN Scanner[slack 1s Fisst in lagt uk Queue \sthe First ouk land last in five? our which | je. b7s} in fitet ow lis enter last will be velvived | whichis entey hive [fiver wil be setoice Rivet | rStack 1% lineay dalogixuctuse | Quaelscalingay data which ‘ig follow lagtin fivsh sisucluyeé Which +8 out « fisshin First out- FGlackis suitable: fox reciessiue = Queue canbe used fox fund? non Tecuresi ve Fun ° [_ \ike BFS | [Insertion ond ddeHonore possible - Tngeattion and aie al through one end and Stock- #hevore and ddelionat [the frors end in a quale - T LN] [ for’ e.g; ‘books in Vbsavy = teg-Ginema ticket counter EB v | 07 OUS .FickeF counter- ae @ scanned with OKEN Scanner
You might also like
Stacks: Definition
PDF
No ratings yet
Stacks: Definition
60 pages
Data Structure Unit 2
PDF
No ratings yet
Data Structure Unit 2
77 pages
Lect 8-Stack ADT
PDF
No ratings yet
Lect 8-Stack ADT
20 pages
Data Structure and Algorithms PPT
PDF
No ratings yet
Data Structure and Algorithms PPT
45 pages
Unit 3 Stacks and Queue
PDF
No ratings yet
Unit 3 Stacks and Queue
50 pages
Lect. 5 Arithmatic Expression
PDF
No ratings yet
Lect. 5 Arithmatic Expression
49 pages
6 Dsa
PDF
No ratings yet
6 Dsa
130 pages
My Stack Queue
PDF
No ratings yet
My Stack Queue
99 pages
Chap-7 Data Structure NCERT
PDF
No ratings yet
Chap-7 Data Structure NCERT
3 pages
Unit-5 - Stack
PDF
No ratings yet
Unit-5 - Stack
85 pages
Unit 5 Fds 2023
PDF
No ratings yet
Unit 5 Fds 2023
99 pages
Stack and Queue
PDF
No ratings yet
Stack and Queue
72 pages
Unit Ii (DS)
PDF
No ratings yet
Unit Ii (DS)
141 pages
DSA Chapter 4
PDF
No ratings yet
DSA Chapter 4
48 pages
Stack and Recursion
PDF
No ratings yet
Stack and Recursion
47 pages
CHAPTER 4 STACKS New
PDF
No ratings yet
CHAPTER 4 STACKS New
55 pages
Ch-3 Stack Notes-1
PDF
No ratings yet
Ch-3 Stack Notes-1
27 pages
Unit V Tree - Watermark
PDF
No ratings yet
Unit V Tree - Watermark
69 pages
CH4 Stack and Queue Last Edited
PDF
No ratings yet
CH4 Stack and Queue Last Edited
61 pages
CSE 2001 - Data Structures and Algorithms: Stack
PDF
No ratings yet
CSE 2001 - Data Structures and Algorithms: Stack
22 pages
Data Structure Using C Hand Written Notes
PDF
No ratings yet
Data Structure Using C Hand Written Notes
70 pages
Infix To Postfix Conversion
PDF
No ratings yet
Infix To Postfix Conversion
60 pages
SE E&TC DS Unit6 D.F.raka Watermark
PDF
No ratings yet
SE E&TC DS Unit6 D.F.raka Watermark
46 pages
Data Structure & Algorithm CS-102: Click To Edit Master Subtitle Style
PDF
No ratings yet
Data Structure & Algorithm CS-102: Click To Edit Master Subtitle Style
38 pages
Lec Stack
PDF
No ratings yet
Lec Stack
28 pages
Lecture 4
PDF
No ratings yet
Lecture 4
35 pages
DSA Unit 2 Stack
PDF
No ratings yet
DSA Unit 2 Stack
37 pages
Dsa CH 4 Stacks Application
PDF
No ratings yet
Dsa CH 4 Stacks Application
32 pages
Data Structure & Algorithm: Stack
PDF
No ratings yet
Data Structure & Algorithm: Stack
37 pages
Online Class 15-Infix, Prefins, Postfix
PDF
No ratings yet
Online Class 15-Infix, Prefins, Postfix
62 pages
Ds-Unit-2-Expressions Conversion
PDF
No ratings yet
Ds-Unit-2-Expressions Conversion
18 pages
Dsu CHP.3 Stack
PDF
No ratings yet
Dsu CHP.3 Stack
43 pages
Unit 2a Stacks
PDF
No ratings yet
Unit 2a Stacks
15 pages
Unit 4 Stack and Queues
PDF
No ratings yet
Unit 4 Stack and Queues
79 pages
Ds 5stacks
PDF
No ratings yet
Ds 5stacks
31 pages
Stack
PDF
No ratings yet
Stack
48 pages
Stacks
PDF
No ratings yet
Stacks
34 pages
122AX051 Sujeet D DS Lab Exp 1-5
PDF
No ratings yet
122AX051 Sujeet D DS Lab Exp 1-5
25 pages
2020-10-05 Infix, Prefix and Postfix
PDF
No ratings yet
2020-10-05 Infix, Prefix and Postfix
21 pages
FDS Unit5.1
PDF
No ratings yet
FDS Unit5.1
25 pages
Lecture 09 - Applications of Stacks
PDF
No ratings yet
Lecture 09 - Applications of Stacks
27 pages
Unit IV Linkedlist - Watermark
PDF
No ratings yet
Unit IV Linkedlist - Watermark
19 pages
Exp 3
PDF
No ratings yet
Exp 3
5 pages
DSNotes M2
PDF
No ratings yet
DSNotes M2
18 pages
Applications of Stack
PDF
No ratings yet
Applications of Stack
45 pages
Data Structure & Algorithm CS-102
PDF
No ratings yet
Data Structure & Algorithm CS-102
38 pages
Data Structures 2
PDF
No ratings yet
Data Structures 2
17 pages
Exp 4
PDF
No ratings yet
Exp 4
6 pages
Data Structure & Algorithms: Dr. Manmath Narayan Sahoo Dept. of CSE, NIT Rourkela
PDF
No ratings yet
Data Structure & Algorithms: Dr. Manmath Narayan Sahoo Dept. of CSE, NIT Rourkela
33 pages
Representation of Arithmetic Expression and Postfix Notation
PDF
No ratings yet
Representation of Arithmetic Expression and Postfix Notation
41 pages
Stack: Er. Harpreet Kaur Harpreet - Cse@northwest - Ac.in
PDF
No ratings yet
Stack: Er. Harpreet Kaur Harpreet - Cse@northwest - Ac.in
32 pages
Stack Application
PDF
No ratings yet
Stack Application
4 pages
Data Structure & Algorithm CS-102: Ashok K Turuk
PDF
No ratings yet
Data Structure & Algorithm CS-102: Ashok K Turuk
38 pages
Chapter 9 (Data Structure - II) - 1
PDF
No ratings yet
Chapter 9 (Data Structure - II) - 1
7 pages
A280854636 - 21482 - 7 - 2018 - Ds 5-Stacks
PDF
No ratings yet
A280854636 - 21482 - 7 - 2018 - Ds 5-Stacks
27 pages
02DS 1
PDF
No ratings yet
02DS 1
22 pages
2 - Infixtopostfix
PDF
No ratings yet
2 - Infixtopostfix
7 pages
Ds 5-Stacks
PDF
No ratings yet
Ds 5-Stacks
26 pages
Kfs Document
PDF
No ratings yet
Kfs Document
2 pages
Lecture 12 Polish Notation PDF
PDF
No ratings yet
Lecture 12 Polish Notation PDF
36 pages
Data Structures & Algorithms: Stacks
PDF
No ratings yet
Data Structures & Algorithms: Stacks
7 pages
Stackshh
PDF
No ratings yet
Stackshh
8 pages