0% ont trouvé ce document utile (0 vote)
393 vues35 pages

DSA Stack Notes PDF

Hsisoenskenenen

Transféré par

lakhurathod855
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF ou lisez en ligne sur Scribd
0% ont trouvé ce document utile (0 vote)
393 vues35 pages

DSA Stack Notes PDF

Hsisoenskenenen

Transféré par

lakhurathod855
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF ou lisez en ligne sur Scribd
— Shack } ~ He Tnbedsction : — ch_is an ordered Collechon of elements, ~ here Clements ave stored in eee in fivet | Pop = | ae element i Paped ‘S_poped = —— at [ Repesentotion ob Shea =) here Ore hoo ways —ia_tihieh Stach #8 ¥ go “an fe aol ney preset ~~) Statice Stach C_By Using Array) —___> — Dynamic _stacs_C Ey —Using linked tet_list.) . ta “a 8 Om ely ago. =) Stabic_Stocs_is implemented Py_using array. > 4 Ipe__indering — of_anny.—i8-doné_by_ Using a, 1 Operations Bn Static “Stach: —t) _(reate. Stah'e 8 ___+Tb_Create_a_Stahic_$lack_we_use following Shige — |4¢ define __ it y MAX yp i ypedef Shuct_ Sstac_—— | 2 int_data (max1_5 | int top > Wsstaas Tohalige the Sate ‘Clack - “Ip_infili UNotion - [ yt ssEeopty, - a is ose to. “thesia _whether_the Shack 1s_empty tt N ee empty it tetuins 4 else LE yeturos _D th eck whether Stack 18 @mphy—or nof— | we vse following funchion+ E (Tsk istnp staat eae) tif (9s top =2=1) | Yeturn 15 _ else i _treturo 05 A t YW jefolL [Ri pse to_chech whether_the Stack ss | Full_or net: Tf the Stack is fall then it return s_4_ Tele. “otherwise it returns O- — To Check whether the Stock is Fall or not — | we use Follousing funchon: tt isl lasstacs ¥Sg) __if (95 > np == Max =4) ——_|__‘etuin_4 5, _ else ——_., __Tlorn_05 _ gone : ; i __ PusH _ Tt is used toi iogert_ “an agement. in athe stack g_at_the topmost _ ___ =| The element _is_inserte Position = — Before inating _on_elément_w we need to t0cremen Op. nih eS A ier tanemeniing the inp the new element _| ia ~__/gtayed__t His fasion ———<$<——____ = She Function tn insert an_elementis 9S follow, = SStack__*ss_s_int_ fum)——____> { $8 — top ++i 5 SS 4 ota Css>top) enum; (ey eoe Tie ere ena Seer ~ From Se es eae Be ie — = ge aa = eames [ fanein: Stack we use followin. i ink_fop_CSstnek_ oss) Tums > da {ss Bi Speck top}; = —q euro i. a ale aE big “osed_to_return the to t “Th tecdiienersiee ap _most “element “the return tre top _mos: “element we pse —_— ©, Rsllowing + aa ~ | ink peels Csstach #8) im ; | fala ada teste | — (0) Display = This tse disglay_the Sack or top to battara — ~Moid display (sstacs_ ss) int i, fa > top 22-4) ae Stat stach_is_empty"); ' fouls ssatop 3 is=o5i--) int 4d" $sg data fis [deine Max 146 Ltypedef Shuct Nope is int data ; | Sktuct Node * next ; hy lias — Th ~intiatze_the_stack_yye_create_objeet_of Non 108 Top and intinlize it to Avi | NODE * top = Nuts {i & Pusu =,Ta_fdd_on clement 0 the Shack we use Pus — —peratin "Nove PusH (Nove _» ToP) [Noor = Newnode; A Senate = CNoDE *) mattoc (Size of (Nope Dds Prot Ct Enter data of Newnode:"); 7 | Seane ('y.d"_, + Newrode — data); Newnode > next = NOI i€ C Top == NOLL) “Top: Newnades else £ de? next = Top 5 _______ “Toe = Newnode; return ( Top) —@, Por 4 Mp remove an element from stack we vse Por’) _ Function” Jt ig _vemove the top mast element Fram stack None _* Pop ( Nope + Top) Nop * @ 5 if C Tops = Nut) ——L Princ" Stack is empty"), else if ( Top > next _==NULL) Free ( Top)s == rer ¢to_chech whether the Stack se ‘S_empt ny - = t Someone unction mn Void istmpty (none >” te a. f a iP (Top = Now) | _PrimtC' stack ig ®mpty’ Met else 1 i PrnkeC* Shack is Not_empty") | @Jisfull 1) eg a et La 8 welts i | mernory at runtime: i _ ORS pil display the topmost Clement from_the ips he ngnan lent at oe Fong Peek CN x == NUM) ‘Punth ("Stack Under Flowo")s ge Poth (" 7-4" 5 Top» data); fod || Nope + es TT ie ctop == Now ; on Puntec" shark underftor "25 ______— LT ete Pry i peop, ; Co oa NLL) eta a3" Pada, Pa next): { Rea * P= P> next 9 Pl! at t - oferond 3 Application_of Stack 7 OF Expression Conversinn a. a ~Stack_is use to tonvert -t_€xpression fy Pa Form te fo__annther form _ ~~ __=lExpression__can_be pf 9. types . Soe _——litfiet_teoe) : ————fiddafs_tas ey —_———™ iid Postfix (o.0+) Se -Expiession__tvaluation a ebe_use_to_C¥aluate ink ali, Drop aluaheo a \ ftom oN mm ~n¢ » \\\\\ tring_(Suntax) Parsing ae = Staesis_use_by Comp! jx_to chee the @ fo check the Gynt £ expres ession_—before anslating it ty 4 ious_lever as ey cae Ql String__veverser i 1 Sa *—teverse_o Shing os it Polltue 7 “7. a opening and closi a cs wo: racking ‘ fp use_th track the the_execution_of Of Hee Program yin the Backward direction from. the -Luneal_shats ag _|Lanother_Corm_ Vaing Stack: There_ore 8 -types of fx a bel Brn Tepe pe funetron Call _ Shack i8 Mare Mheep ecord of al v4 P— Getive Funchi on r— Subroutines | Fate ee Exptession__can be Convert from ¢ _One_to_Bmn: pression depending _ _ 3 jibe tne location of of cperator Macing— Le _| € Operands, . ne Ih ri aie “Uinown_ae rT tg tab | *+abe is | (i Inf S ~~" Tnfix__Ea.pression, the operator is locate between She operands - Eg- Arb , (atbec iN Post fix In Postfix Fspetion_thenperatir_ia Ineatesciter _} _the__operands fg _- abt abet * wabect — fr is also _Ynown_ar Reverse Polish represen baton Sth se". Convent the following _infix_expression ta 27st, expression sing snes. pate) ete) operate» sf ‘operator € +1 Pushed fo ace c{-teesant_¢ {added to festfix.| from cack ond added to Posttin Ae+ MNened_to shack hes here a [Inf shing | —rput_] stack | fictinn —__[Posttaae oa [operator = fished fee tharacte, st to_shack icasedaCeco)| = y —_ ary © ‘operand_D Peco L__fatdea per bic Odded to fosthic futhed to stoo) — tS - _ aerator = Bped |. p82 Le operand “from stack and - ni SPREE SR cof * The fbstfn_expession_of_theguen infix exp ee ‘operand Caddes | PB2¢ [LET |operat * rpede 848~C+ to Postfix. }——— | operator ~ pushed —to_stack | — “TET opevall aie [nees0 to Postfix [To loperata = apes iB €#D= |_ond_added _— laperates + Pushed _| to_stack, |__| sperand_® added} to_ Posts | for tack #90 Le tual te sta LL operain + Popes | Ba as (athe _fooning expression form nf 4} LY opsana a 4 Palin Be pressi —— tier alow | A eeeeehFfFfreirnc - ls | 7 (asb Goorpec __fublo.tb)* Ce $d) ——| | Tag —_—»-s0the —_# 40b-* =e 5] Legere = pute) stab BA |e ston | A 7 -r vent the —Feltaauing —infx_epressio 3) Loperaed ec adtes | de ~~ erpuession — sing Sta. a 21 sr cutput stacn. { SS i - 9) Cnt) fe) Sperates - ia | de- js nae aa poped ond fated (Sn pee | be_tunput thing is step 4 Reverse the_gisen—anfis_eapressinn [or cape Sepa ae te ieee easing ta Ee Ateeas sate 1 Reverse —_linput|_stach Petoo. | Gutput— a= il Pushed to stock " Shag a =s “Shing Ee a 3 i = Sting ste |b (3 tpeand_b added] de-b y i SAT] te tatp stacey ; Tec — t petatar_2_push a stock operates) puch | _tn_stack. a 7 io oe age ipexatn + Reges c—4 HY fim Stack_tnd : TY Hitced tn Sulput I Shing ~~ Sep 8: eserse the — output Shing tothees ger lepers A. oe apes ae pusnes o “| ths tac a Valve oF a | ort fie - | faa pastes ¢ : |__| tn stack r Ty —|eyershene > i ; al Is feveeras > Z cn teges. fetes Irom sacs “Wilue af ce Hig used. Istoe Stack | optiond | persed 2 seta . tO So att He Fyaluanion ef [efx _eepression Bis 63k { —— _ = [| puxes 1 sare 0 funtuate the fallawing fhefis_eapressian. eel= |_____— + — = Lf 4 o_ll¢ 7 owe Fofe = main his as — | des stats tt everte_the_guen_fhefix_espression- DC = BRS Yeutise expression using Siac Fagen + < | Rerformsd oe 2 pene operate tit ened oA insta} “Lt a ot ay 2 Je C98) fon —| Top react era [Patt foped + -fBigned ton Fit poped 4 asigee to 2 | zPash (42138) TWh Ci staatempy _— Tie tusntisd, > PankCx ats Meds 6 i : : Bushtxe) fume Poros] Ta Ty] 2 [Reto | Pah cH 1 } Liat n at Tp Lluhte(istacherntyal] n axe foped pra ope fam_Siart_ta — 2) initstock trae stat rey — Durie GS) i — st i t —~ - T =~ Crear s fant 4) A a pe BH Be Fee rar aan = first = ae nae it ondes atten OF Morgen, Tiara elements, line Hace ee done Sracine it which 86380 ond delenan —tperaton—10hE “plifes_and tig ends 7 Hlement Ss _ spcenich ol vear 74 OM Semen” ate Anteted fern frontend. Fore are four Types oF Geves suchas —@ [ineox _Queve___ © Greular_Quene 8 Lee: Guewe = /R_fineat__Quene is. a finemn_ddato_shutture_in__ ———_Nobith elements —are_ourarged inserted cnd_deteted) — ie -Senenia trans — aticlise —______4 pack inianze _Queue_we te Rollowing Funchye itit type of Queue, ements dxe inserted | — ft S97 Front 7 +H ——— i gm tear ond deleted from frent peray -Queut. con ke iteglomectat in fue ene Oueve ky ong nay) — es bye Gacuel by Utieg Leked Let) Yoga boone yoBgane Queue it implemented ty Usea_dveay Cig men mainte insertion ars deieton Tonton _ Revneed we iMteger vanables futh ae es ee ee eee ae —— itreate a Stake Gueue we use fulowing Wed inn (scare = 66) eee (iS Dyeame 4p ianatize_ Dynarric Queue feetien to tak Peat _ond Year 2 aout ee nRTl Fp adatalse shots —— pond delebon Order. ce f= = = ge Heron —poate_—voramies Sacha — = Ts foot aed reat = ipetthen 00 Dupome Queue ————~—] a 4p._mannlaie_sacerne ¢ 7 ature Chat ss16a —_—— | ligfatt Inserting an-elemere —p ch re ae Oars Gacen— se {incton ee Fyoore_ueuete—usefolosing— Tar date —_____—_——— 9 aaa ee eae snece— —————— iat ee AY OGuese 5 EE nt t= Eaten Dauere “front. *rears—— 1 Seon: *_, Ane una TE nemnte nents Se — reer be See pie oe to Uisplag all the elements hem Front Zien ——— - nM Stabe trealan Cueto Guewe———_— Jena ala Gotue —— © freuen gr Gueut —all_nedes (elements) {es - nas Notes ds Carcatar last node ig tenSte Vecate — ———— Thorn ko the fast node Se, 1G care — Stade Ghanian ae we | Sena Queue s6 a6 alled a8 tpg ghucture— — | atten 0g = ~— “Greats ue eotain a tablechen = Ghich_qhtiss—iosethen Cf date eo of Cueue— ang delenen ef or—beng of Cusue —_____ L Tinta Gusve Can be sepectnted sa sags ot dova bods ant Rent 20» [beac » — : Sfanc Caesar Curse —Cby— using — Syrenc Gerslan Queue Coy 08.03 line ate Creator Coc = — ang Grease Cueve ig implemented by sag snag —aim_the _Terge_e_te fall __— = eter Cieeulor Que Scher — 0 5 Tinstting on stement in Circular Cueue Hird ad Ceteuewec@)—___ LL seen asa ——— LG > veo + (0 year 24 A _MAR Eee date (ee read = Sams nk mums hum = tir = dvalCe = hents Ce phent Ue phe nk +42 Mens Faure (nuns ~ poate 1 sel res 7 “ehaeture— caegenteg—an— Clement ae Beta on emer dapame tisetan tance 2nert acon lor — 1 ars _we vee folowing 0° Fuachon. ~ § teguee it “addO0gueneO tI 2 i Mtonode = (OCGueue*) ralloe CHaeeF Ocoseueds eee The —imnplementeAGeewtas Queue _weore Taina te —tireutar_linted fist — —— ——— ~Tperannes of Dy namicCireutas— Guewe Pant O-Enter data tobe inserted“) Bent (17.4%, tnewnsde data): 7 Tewnode =? Next =newonades— He Crear +2) So antianze —_—__ =a in pinaiae —Oynamie Crealax Curve tle peei 10 inshalize trent ond tear —to_ Nout *Tpewnede -* next = fronts year anext + fawnodes “year = Neisnade 5—— —_@istmpry $$$ “o check weather dynamie Circles Guede “enpty.-or not we ose Following functions Le : 5 i ies “used —to_disptay £ be io fee — LgGean treats Now — i AOR an C Dea UeHe ia Frys — element — “element from 060 (rdl2at > rhent data, fe Now De Queue is Teepty')5 Pe fronts—— Piyte Co=anext_[ = oak) — cs cendins ie De ulm ee | Jatt the lorgest_eemens con Eee = Ci at nha ee Eien forge jority Quewe— Fen ouree ey cee Ta calecion ot Aeneas], oobly bed, Guewe ee etang® in bly raded_Cueue. a o By tovels ue Cieguey vin order» election a te Queue aren jwo ends Sethe cthat remove te emt open the penty Siok riot [eements fpssigeed bo it — am 9 ao 7 =a ‘element of nigh processed et Stement—swith leer —_Pricnity —_ “T Before a Taf _two_elemen! _ ~_ tre Processing pede = ype ot Prion there are two 19 bi Mrcending — Pract Moser Th. Descending —Priouty —Gasue —— “Pscending — Priouity.. Queue tS ing. fipnty lueue + the elemen fed orbitaweaily — Oo ‘nly the Smanest_ element £20 —be_remene Fiegt- and Further Processing 14 done —_i0— the _same—way—in—the—| | cending order segome forts then fing foe ‘added: gat ————— fie norenal_ queue it Tyear_is use _only— ue it Con 14-4, a WP egerton 00 Ae ge aiitypes of Degue ese einer ove te tees of Oeque Bie fami freae onda 8 ) Input rest be jeque Z ae ee f Thput_reavered degue pee sang rabies " £ + se panlie® {Ino resteted dene pit anatiae deque 2 ee ie unieh alawt. sosernen, O01 2 Bho. an te dete we werd yy water eh = deg latin. deletion frum, tat, We OMe sgt A ext ot em ad oe op eshetn! dein ee nd sagan vesneted degue.» allow woety —— oy bY eine SNe in te ising ae ey a gn nea SE i aetna ear ts t 4 pu? chece whemne, me degue a} Gaygut vesncted deque deletion Only ot » ite ute SF deque whieh atiour = A dea ip but lw a ner hoe we Bede, ib Called as bulgut Festet et full_or net | deque fea oe ungur restered deaur, Gilow. deleten. jasert F Fire O Fthly ov une end. that end_con bo jElte_obd on ‘element at the beginning tees freer 01-8 Fs “Deque z iqaertLost © 1 eterneer ac We @nd OF Oegur. 5) ideteref at ae ced to vernove the fr element 4. Introduction 4 Data shucture and Algathen raise ~~ Wdeletetast —____— fru _uted to remove [iaicetaeron term data Shucture is_usea to descnbe the way in which data is etzved ord the “deem algouthn is vse te dige desente [the way in whatich dota is process sata “Srechive “00d.” Biosthmlae [interrelated - —Zto develop _a_Prograr of an ctlgersthen ——- Tye need. to Qelect “ao appropriate data — Shutture Yhat algorithar- Therefor (rogram it represented as — [Program = Algorithm + Data = fiuewe 14 Used Whereas_we— want —on,, The. Qroup of object _in £20 Manner..__ "9 Tignes in _use—ia_thefollowing- Bon Stone $$$. ~ 3) @uewe —4_psedin. ob Scheduling by ~~ operating System —————

Vous aimerez peut-être aussi