Download as pdf
Download as pdf
You are on page 1of 100
We Arrays = C Q) sdorxeel entinuswoly av memory. G) acrewsing elemento’ io eoay. (Yordom accer) | ee, totals a eweeel eral ; I AltJ= 004i 1 andor sharks int, ase= [© 0 a t byte A(t = (oo + (2-1), Uf index shorts a tits 1. CaS) Ati = (242) + 60 , index fet Lbylo de dud tie wth Aase to not: i ing “Chvent ov aa given ,conatitar. ib siting oe ACE) = (U1)42 too, ip sdee stants : with 1. (i) most eee language ay stares woth 0 becare sero eles chonks toil, 0. 9-dinwrsioral, arays + Rows major orcler> 1 gale coor [02 Jos] tofu i2je]20[arjory... 2/0 oF 2 © SS © eg On tL 1a Row 1 Loos 2 Row 3 2] 10 GI) #2 23 ane site 3[ 30 3y 32 3% ©. for A300) =(@x4) +1) +100 ' oe ee tes A GIGS =[(C-0) «+ (1) ¥ 20+ - Baw fer inde doting 3 > 0041S = 118 Pry. ae ; “J “FeeIg] « (Coen) je start Bort, for induc deg ajoy ordery 4 8p 9115) | o2]12 [22] 3: AtItJ= (tay) +2) x2 + 190 = 1 Av Genera d mre a sa Alef] Gye )ti) +s + Base ® Btrary Adiesst qf 2-dimenrtonal, eee: Rew pa oreler + Loo Col oa: (mx) = 4 (ug: Genspust bane : « by Bhs otc 04 G

we) A (2g) (Cem) td) * 5 + Base 2(Gxotjrijr tte ae ane. L | Colum 1OUr | 7 bab pafomance , ; re Manas He out ech bogie aay and Gy U dow iy Un time tr. r9W. 1 mapor order» writ te clonntr m1 column) : ng ord ncceting ip dow by test te in , as i : ‘ j 4 One A: oan ay fie gy Wears RUO Boot :100 addres of Cement BCUJCj] =2 AAAS +] + 84 [owe] OIsjtit sy Wit j +84 (A) jt ut 84 (evoy > ATIGI=(ENis +7) + 100 > ISi-Is #j-1 +100 > ISL EPH IY Ana. (eMo] ACLICII= (G-+10+8 31) #100 ) > Of-10F-1 + (00 > Omit Amy. (Co) Ms wel slord in amays A and B serpectively Eady amay con be ored ether in RMO ex CMO Lin contiguows movory location. Te Lrmw comple- aly of an algo. to compute MxM, wt be 1 @) Bot Y A id tH RMO, ond Bb in CMO ® Bot both ow & PMO. ) © hey " i. ti Moe ee toe ee Now, Hr time cond of snp ation to conpule Mx ee ee M, wl be bit iP ® ib th Reo, and Bin in (MO. po) tewe chanaen fr Goflamerbatien ,dur te age re : ee mG lnginge « Precedence and Assoctativety : O th-4 bt rept Ostet — tS, hyp), eeeop | ght & Eft 6 £/h Lips ey at q ee " ¢ iy n Ge ore Preedit ; “aa ee be y o Acaenseyy » a a v \ ” I n | dL iy ” er s ae cs tights to ot We +2,-=,#2,/2,%2,92,n-, le, wy Ke 2 = ) We bo abght otnteu> > E> Character ste 2) nol) fod ond Adspertlo frow Plate b platform and amplarertation to cnptrventosion. esing Eran by addon i footin Shan by nome. a0 Hy yoo wid vo scces te eddrws em F you ost he name. Pooten vw o verialkl, whidy suppose to contain Gu add. of some other Veeiable ot some offer Frey syddem has lerathy ov cove bity and f addres ty suey. The pewter sire aloo depends or Bere wf bao. | of 42bt poster, Zoe in aloo 32 ie 64 bio poenter, sire w aloo 64. vepasentati on, nt tp; p> Jb, The re of Rr booker ty uiduPerctent type 6 Che Prositer ao AS ae Some ree rN f | The '¥ i known ao darefecanch ox indi section opexnttion: OF oe we He name of th actable, we Band thoide . I | be uot cdlclrors of vartahle, we stand outsce. If we we 1 & Be poditer, we dard aside Gf te menosy eden ) Chow value dored- ; . | $, be wank fo acu a variahl wide g vertable cel | a Porter, thay ce doutd always wre the *. Pe ae 1-5; « | ah ty = buy > 100 |, pete ("tha"); 25 ae, Prot ("oa"); > 100 (abet. of») | pote 8", 1), 08 4 ("bd?, xy), 75 r°4,0" Ly); —> !900 | — vot { (act ¥p, at 49) i £ peqr : ei 2; g at b2O) | ? ely : ak main () { . fOUh); prt La ha e's 6; | gebuw 0; : 3 1 2. w2 Oot A902 , oT nain () { vid Sexap (ent u, zi y) § 1 ob o,b; ik temp - | they temp = v7 4 3 sep (a,b) LEY 7 Re a eo | how, Ipcal parameter veluoy, folk Hg: aes, seonffoed. net matin ()§ se > Sao ; ONE b; thon iB a : FP top, @Poirkery ond fnays © Ok . ant a5]; 00 DE eo ee ee ] (eee Le ate) atiy al2J at aly] 1co oz = N06 108 NOTE: The away nase doer nd have moor ‘poce atincated «4 & ost other resentaction, of addiscet v Feces fost prcertation/addrer avitindiic #49)" = a(2] Gowraliat atLe= a 0d fer aoe wt), wm tin cere. eee suppose ‘a? in hi care And we odd W 'o” Gan wk ae you to ith atomrert Pom ty ctask prak . : | | ! : } : ! » ¥(ap)e a BJ J i i i i Awd by Placing “¥’ in front of ate, #243) Wh moons wet GUL | be maice th addiey By @#) = Lots) , Kewte Noe : ee eet i thy type t ate become du pending mr te Lyfe ¢ the inownent i appropriately (He addes) xp; Output = 100 Bemis; ” (06 (p); > 100 . pid-atd= als) i ; pet Pi. (Pp); a 106 ees ald + (pts)> ale peag | ] | ee Sant ; pt ~| Baste Arflerences bles a4+4 be ee Gat and poénten. Q=p. a NOTE | eka we fe Ov avsay 4d a func: , we pas the Hacking addres and thet doting add. will be Faken by a Podter jin fhe called function. oe peoikey cpecetions: 0) asstgnneng of peentexo of the Same tofe ee ah XP XY; ae ¥p, eC); Petia ay ee a Netege Wpecadiog iv required. RR ie ‘ye yy xv ¥CP o ak Fp; p> (tele; @ adding ov sabRarcking a pecker and an inl. |. P-l P pH pir @ wbbrading oh yon oie: ee ehh fame any, © Ot ae wt ad ubbraction io urd bo rs Foe, $ (ps4) ; cue 3 parol He Pky nadg tan a, he Neve: Be conc add, mattifly ov divide poirtero ex do bff shot, right - heft . W) assigning or Comparing to "3040. (we we ‘ute at ©) Zuw ko ¥ exon cose tidy meund whenever ae | aw yw fo tek whether oa poate i valid ov nok, 7 bk Joly LR wher Wb i © o nol - : @ Character poate and ionet “oki aut tonatiasd Cher a() = “weKinnanyu", Ie w awn asvoy of chazackees. char ¥p> “mokin ”, Meth character i cued 4 defoe a ay i to | ule Rm] a [af yfule ats) 2a ° | Oe? SS Li are) {co MOcEee nyu \e | pled # Gt) = of) i ea Se ety, Manat: In an array, We Con modify the tatng value present bub ve ceonat modify He kat value , fey cose of Pe ote Np Oey vadaae ta memory lucodion in daring combant. We eeu acces thr locabion uk nok change it. become at in Penge erotenb 4: Podithy scopy k to < ; vetd shy ‘char ¥S, char Kt iS att) Jf ) ! } ! } } } J J a i ’ ; i I ) The string ae | area | GAT tohat deen Be feu fing ven of C program prod, char ef) = “Gartcéou”, Char ¥p> C7 pratt ("hs", pt poI-pled); (a) Gatedon (b) Feo won won 7 cg prt "6" pI 7 —> GATE rot poof ("tbs” , Pel); —> ateaon pitt C's", py); > 961 Pes he" piel <> TE20u © Ul U2 2 UY ABC D EP mitt 5 6 ee .. p+ blo) - pty —> 2011 pry pea “June sett bent anotion &9. oxacters shi ‘o pret CLA”, prof (“soi”) + abate rob outpul > aovy i for | tconskank of the od Nove: tohwuver we talk aboub a satng thou wll be a nell Character and twhinewer ee lay to freak ih wtny bs se pant? tll prt OU th nell characker Hing ficon coherover you have given | We GF cat tlt be ofp prinked by fettowing f Program? Pioclards atctio.h) ink main () oe alt] > “world”, Ok £,) 7 for (iz0; jrSr LG roel J- aly)» paatf CEs ln", a); Bs va tae @) dlrow Pre pe © dled (a) 070 & > etiyeeete) (ole [+ Talay) AS we know, He pastf for Katng cwombarh pret tat i How, | stato in bring, HherPore null cbt of | Piva af boaters > 4. char pie be { "mi", “sovindsa”, “rovindsobabu”} wor [P44 Gite Viele] N eee p ale tou SCREENS org prentf ("os", x rome 1) 7 => savindra ee) ko 100 (to |-> oe freee eee 7) alee NOTE = now iW an array few, nol a Potrtex : writs nome [2] (7). uo # (newer) +7 —> whaber Diff. bfx vraltidtmaional array and powtevr / b howe, diffecent Wr r0ws which mean co ty orden 4 acces ‘a’ Zn ea et we can dhax assay (303) = $ave", “ravenden”, "govindrebobu’y Dim 0 multi dimuvoionol an, 2D array 1 alt cole should ke of he some sG& wheth you wre the space ox rok, But in Cae OF AD¥ay of pron, we Rene te spo Sokur ty equal to the fatal sie of array. Put iv away of pedkers, He tobal poee taken b equal to tho wo. f OWS and the space Loken, each x00 flu amount of Monon required for pries Th podten ow por t take echo spose. | ai) Munsory wileation a lus in array of pecker Chan in muelk dimonratonal aways (iv) Accessing ee arsay f peste @ easter Compouwd to the array. v) the representation of both axe diferent. eee) Pete ene Neral fune (int ats) ee ae et ll Since iv 0 poirfer wx need not foecify thy ave of it (at « CT) ant b(s] + Bet) eae, © we need not peify the no. of eleowensto /r010s in an aray me (ak #0) 4- Rimenston fan ALO TAY fe 2s =dinrenstonal a gray fom bb) bEsT6I; 0 fc; aime OT ia ne above,"a! Da potter Hat points to on aay f of 6 elemento. (We coov aloo declaxr it a, i | foe (art (xa) 06d) Noo, i at (60) (0) > | ant vals); | Ow, a! in ow com & aw nt, (0° bb an arra 6 | array of ¢ clumunts (astegers) chovints which ac all Ce i Te | Pe alee. ao ("SCT am of some S| precedence. teq7 a gee igh Prcecdanca Gi) 660! becomes a. power. GW) ‘a’ becomes anv array Questions av Poateu t poater and ana potter NOTE A= ¥ ptt i aarp? th above i Nala oa Ratt b ft asiociadivcy. @) a2 HEP); 7 az 4p az atl —@) ae +hrf) @e ae 2 ¥0;% 0.) main) { , t. int a(J= £10, 20,30,40, $0, 60} 5 ™ 2. ink ypCl= fa,adt, a42,a43,aty, ats} + 3. ink ¥4pp = py | 4 ph4+; > 102 © pant (“ha td ha” ¢ ae ~f209) 0. ap ep, 1 prontf (“Ed hh Ga", tH sph; 2006), oz Gp. py. «Pete 8h LE. EBD 1 +44*¥ pp; > UY), f te eal eh Ld, dl” G.GB.em ere Now to ge te als, aB)=x pl) =x@r3) = stata) 2a (ppt) +k hb 2 30 9. pp —p = 204-209 S : —, *pp-a > 2-100 *hp -a = gots ze ees, Pate. Ebb = Yo F ph-p > 298-200 "bpp = 2oy- 260 a : 24 2 Q 2 *Pp-o > 104-100 : thp-a 2 [06 -100 . Pb ee 4X bb = yy 2 oe © Pociten ty fouctionn> — Genaxte. Potrter v ink zine ( i, at) void ¥(egp) (veed +, vette) —c wnt (#fP) (ib, int’); kn # sum(Enk x , at ¥) — (7) fhe smi gb: (votd x (werd x, ve #)) runny —{ip NOTE > The amay nome itself can ach an te pooter fo an Similorby, He fusction rene iReelP ack ar te poriber fo fonction. oO ig ri fesckion pewter thet take 2 ved peatew a yp and ret a veid pointer (ii) Sam ww a function Ret) reawenr a void + and taker 2 paramuterd of void. 6 Sore: how we dy pecart a. pecker to another podter, tere wud be ‘no infowuch.on log. Te addres will net increase bud renrorn He sone. | Suppoe we poi ty a chexocker and foke te addren of the pointer and pul ib in te Mlegn poster, thy adda in going be of tere cbt. Thorefore, info . dull ma te o- Only thing to that, fe you do net Hypecart Compiler might wool 0 problem ee @) hac a age} foxgy iv declorads [Jes of v to & pointer fo pointer to choractor Aaytab) (2) | daytal in declared 9 & foter to an array of [3 integers. 6 CHFPISO); Hpecing ) Se ee 7 daylay | Gi) ink Fdoytob (3) [Aoybob iv dsdaxed- dowtab © ayy array of 13 akequo which axe Powter to sakeners. MT. W) voed #eoupl) ff tomb iw declared comp o function (hich io releorning o power fe void. :Y) cha Choomp)O) I temp io drelored, comp in a pooter to a function which rckwoo a choreter @ chor (K(XFO)CTIO I PO io eckered | f ip a fanchion which rekew a pouiter fh an array of | powtern bo furctian which vw ee a characker char FO BO .. ee : i ttt Th | Se #0 | : a a ! j ) | dey bab | } (i) chor (¥(+ 0) 00) C5) Ff C3) io declared- f © aw array of 5 poster to funciona reliventng printers t Oma of 5 characters. eTelelefe] (4 ¢ f, “3 cleJe] (ele TeleT<] Be it vauckucea § traders on poping of ctvanto Mal cf difeant dodo by per —S - suck f * Tha Huck oe onl neh, 1% aE 2 and ead sbucture chax C7 ‘@ hor % and o wurde re ae uy.27 ) mowlex : rs Db the memper shuater. , ' | | tes u & aa dud 4 © duh i, aie : toud Lt Gx con alo write tie — aba | chor ¢ 7 7 3; vouch Ob 1,4, 27 |] * Prgtializng a Arructwu_cirectly , UL Mire inane Meek douctoss ® Cran Cxansple ow Strretcures, 1 ATOYS and poster > i strach node f , ak by ; peda; le) (ep). v = a © Jk rena —> are oo) peater. Tn in ee most on i the Priclow aw dynam . ee es ak ae | Dar Nae, arene: an gek te hs co whence we wank t access AE tae wx hare 4p go fhrough, porter only. &p).0 = por MOTE: Rud node fore (drudi node np, crack neck. n2); Hore, func i» a fonction, thigh aiita king 2 acgu ments that ex fructus of ype node . The Bp hcdeow, fen i | ce a Rouckue f Whe node Busfore, wepying o fogal sperodion ov shuckuw. } iH you Pe lus eatin send the odin frudwe becaw, ib 0 gei fe take a lit d Pg Tuk send th frintew to tu skruckwu. I ol MTEs Hine, WE can aceem L’ Gn y Baas ai, bub we | | i | 8. grad nod f wh T7 ud FC; 18; Rruct wode a(x), +p; tt bf2]e f 40,40} ; p= Lalo); a0). =O; afij.r 220; alol.czb; Operation fects | : i @u ttf) > 17 —> fig\t,tod)p @ x12 (pr>1, — [io], [lel p @ t2 KP >c, Eske x2

Ott y (Ox, (> 40 @) «2 &p—>d) + +7 Bon Gi) 1 = ¥* p44 >c; fBd)n @ self refecntial douctaxer ah 0; dtc ex Fink; P vefeuner inside te Lructue oes pointing f nu Aouctue Ast Fee, $o, s refountial structwren aro cued in order te build — oe dete kroctures , like, Uinked (i and Lreey, yuck ex abc; | fice, a dreckue in cwated where Me ital value peaker io a forrb age valuen - $0, of we by b we th | pectur wxthoudl, asnigning it tb value. ot might ead fo a Limp. Ths uy segnuntation fault. | | Te value in the petiter wranybe oot of bound of the ) muvcry teddess shaw and oe may fay to accen Ke addrow which w not there Sega. 1@ alloc Thee ane 2 Rypeo ca memory allocations > @) Kabitc allocation: Bir th, memory well bo allocated before tunning thy program. () doy naamnine allocation : chem coll — wherever yor. call Che oy tem cal which in provided by tu OS, ie 86 w ee f provide you ttt ne. of by oO. Ww HO of word - pb wor cow Areelly call th am pr mit socuce Bk &va bt sage te | do i in, C kibows hoo provide. wetion whch would Call tk cyskenn call ace. i oe ~ ky ngloy, 4 | pr ae ba tty Ba ees ote | Poally will brow whol in th packcular at han b be cated far te paick euler Os. a ee tt pee function calt—+ brary fonctions, Such a2 a taller, run in thy wmr mode, white System cal > thay sen in the ey then modo. Ato catled ay kemal mod MOU af your ie hao to fe platfom @dspendent ‘eal iL you donk want fo mole any anunrptions about thy sie f ary Aad Actor, dun tk bv peter te ane thy operator 3 eg. sie (ak) ~ mablec (steeaf (Eek) malloc declarations , ink p= lat #) malloc (sirebf Cont)) ; wore: you donk nord oy vewory job pee tt og. toe, feels , Charnwex you ark fox a mason wey malllec , the mallec ee fat hy Ome Sun, Se rope premio ny.4 pray wihed for 4 bytes , sy tenn, call ip raat by ie malloc for 24 byteo, ig io browne th system calla thot would be made wil », ort ES AeVAele A %, worden manag tha, malloc welt create a linked (ag. Supfoose, molloc hao 4 blocks, lf fewer) it Li pul she _ Le modlech dem thor lb Pee ee i ce ts fa diste. ater cok. eh Me ayohers in the blocks. is i callud font fob Oe poten hin técb in Re merwaot ordix of adileon space pe eh, Whenwer Le poe up, maxging them in eaoter. 8 Malloc and ruckus + ig. duck rok fT CT Beate o fouctine ftyfe node uty anh L; malloc. shuct node x0; [-? souct node ap= (struct node) NOTE? Incase, Me memory sha does tet Lave fice spact whee, a will coll the Of and Of will allocate free thoce f mollec.-In care , he a. memory spact, 4 then, molloc reli ‘ } : ) saline (nerf (sbruet node); oe | ACn) f WwW (nro) £ 1 pawl ted) - bO-D)i Te ee stobh sequb red, ; Alv)> ntl stack awe sequel ved for w elemento. 2 O(n) + Space. oupluedy Ta) = C+ T (a1) 40) f (nro)¢ Play <—prusf (EA", n=); AC) An Oy 3 3 Note; We braver tie tree fron top fo down and uf ‘te vaght- 6 ae ©) ESS hn, calls aw made win 4(3)>A(2)> AC) Alo). Marinune no. of stach ebuuent = pty of the tree. Tree con be ured for stall a buts for laxge prog hp beter t we stack. a(n) ¢ Hf (nr0) f PECs); ent) PEC); 3 nn ew nanaass =. - ra A) ae (nro) £ AQ) e)) AQ) Atm); PF); At) =P) AL) A(x) p(t) ACO A(n-1); f= dle) tu) KO) FO) PCV) ALC) AG) PCC) Ale) AE) PLC) MLE A ahaeh ours O/p: 1213121 eo 6m Ae) 54a. i eat ot th cantina rofl ve nee dauckuas which an lf we ruck will have & ene yy Bee | fat] hrud node { iT Fila ches Aeboy dhuch note #Uink ; oe) 3; food ] ] : : } ; 3 3 a , Mote: 0 deushoren/ se Ch canle anda. Suckion dal, 3 which 1p not possible in care of ontoys. | a a will 3 a : < Mocs ee inked Wt then with be a pointer head whit be cented uti duck nos eval; 2 sequoxtiol acces 6 memory, ie, aso ee + But in ou) wowvric aceets ta posible: tardiguoud mem. allne,; LL diynanie mim. allocation ic ange fr oy clement in tenked Sst a Kine | Cons ewes { NOTE > Got my paxtioslax clumenk no_ oe Going i, et fost clement no in odes O(n) 3 Search and linked (6k w way going ty 6(») Fesaka awry io fab asaa heee Ora to ordered’, bina seat Co be pied. ; 0 70) 4o © eo “Ely LET yo w 50 30 d i ‘ streets re *Py aaa p= head —> lenk > lnk > 90 { { ‘ (Ci ex tt) lend) = pj > 30 Output = & Read —> tenk 2 p— kink, <> 40 PEC Le”, Rag > Unk oko @ Froucsing 4 fife Uinked teh > NOTE: Bante spucations om. tL j ® Trow. ‘ a ®) ee e ® % © ; Fe i then sir tag oS ruck nocle { : : A ahi © head ie ais ; shet—uorte—f E Bhreuck noble #49 be head « tohile (4! nat) £ : erty: pointer, CREWE boa) | he k > lonks s § Bo WOTE > woke (€!= Muu) = while (£). Never frovere ening Ae head a0 Ge Wild be abe 4 , am Sravesal bub ab Uw end of Re halal become NUL ond Ue endire Data Gill be lost. $0, & in bether t take O Lemporary variable. @ Inerking an clement > Befor we umorty, we nud fo cronte Ho element. And we tan | cxeohe penein or a node waing Boru ctowus « gy. Kaul node f ink oy Fauck, node ¢tinl; an 7 sud weds tn (taut rede) alc (Asef oud nl) %” tt <—e1 [15] haa [Bo] wer © Sraerting in the = | ) ! ! | : } y } a ) J 3 a : f ‘ 2 Nea pe) i ; nus —> link = head; —O 7 had = nour; —0) aa (¥8] fend 1 3 3 3 a G@) troerting at the endi- e fru node +b eked ofan whch CEB. jut ee (BI) 4245 Unb; Klink 2 news —) mew —> lnk = NULL 1 © = whib (t+ bind @) Inoercti any node / iy betwen’ struck node xb head while (£1 12%) t= t> link, nw > Gn = t > lnk; ~@ Klik = nw; -© @ Peliting anv element + NOTE © You net only have fo dalete We clement bub also free up be space - You should clays check whether he vole of the htad in valid or not ie, at i potntin fo a lnlced tot adds thot i valid ard ret NULL. Ff you axe tayung to Aolede a rode thot har noth inh thin head will panto NULL and Y you by 6 Belote o Link of someting the tha , A well give you j wuntalion fault . © thy foo 8 egy } “node *E= head 5 1 head = head -> lenk ; (ie Lindon + i ) heads Had Rould not fe NUL, tare should fe chlegab. 1 node fend > link Should, nob be Wut, thee should be 2 nod adex to delete the Leginni nod. ee fefoming ddebion ae we Soulld W %} bead == wu) [FP] bead ,i0, no nodes | retum 5 | (i) y Choad ~> bink => note) { re | ) foce (head) ; head = NULL; head | @ 1G and (7) should be checked prior ts (al) ‘® deleting fe lok rodte- i 2 , | ; dick node Xa Mads TP} ofay + 3 Rl 2 ONE (t-> Gink,! = NULL) %0 * © rs : bt fink, —O (0 je] t S ; free (4 ind) ; —@ L tolint= fun, —@ a (i) delotr middle Fs 3 shouck node ¥L- heads Saga while (£—> kink >i !=9) (70) & Le hols —o Be) at Foruch rok ¥rews t> links —H Bo link = b> link lank; [blink = new shinks —6 free (new'); —@ NOTE > To delete a node, Sopp ont node before He node f he eke hed, w directly deleting ty node where we dhep dificult ond we will kaw & ebavene in onic acces thy previous rode. In a dinkech Lh, ue connot ge backward. Teron , always sop aw rode lodto ae Ge noce & be eee dt 0. trad node £ CEEEETRT | int vals é hrud rode xnert 5 i 45 vet rearrange (Rauch node Hit) § | * sory moc Ph, 445 A) 1,2,3,4,5,6,F | dk Lemp; LF2,1,4,3,6,5,4 | ap (tet {teak > nox) [aleoak 2 O13, 5 4 Fe : vehuan; (DH) 9, 3,4, 5, 6,7)1 p= Ws 4 = lst exh; woke (4) { toup = pov povel= qrvals Jove ekemp ; peqe nuk qe PU p> next +0; j ges 4 t y 3 ¢ s ae Pe bab wsk RRO 7h + Qutpub > 2143657 Arita struck iin wshicly data ‘in indected semoved, from by sone sécle- 7% follows foe sub manner AU hr ofpecationn eccux duck | Application of stack ae W Recaaston- @ Infiv to | porfer Comeuton. @) poostng: :@) es ie ®) a @) editor. rea whey AE were: J i tumentiattion can be lore in only 2 conus + @) Avsays : dinked —Lesk , any dota stauctare Ir Core ripe > impluvertation in fasker - hen we cannoly predict M2, WE Con Jo with i menor allocation and thouckunen. Advantage to, we con shrink the dita cruckue Bot Aicadvantage io, tt Laker more times ie jlinked list, for imp ementation fox. stack, whether you we linked EX ov array , Loker the Same tome Or comobant dtme- Opexosionn on ack + G) PUSY— ino element into tad. @ pop = dette [rovove clement, fiom stack eg. @) PUSH cpexatiqn : int stack (Mary; Shack [t+4op]] = item j unk hop -1; y, Word push (int ite) § ec} | | | ; ) | } ; : ’ : i ; : i : @ Por eperation® sok pop cp CL = oe printf (andeyflow"); yetuur -l5 3 elie 1 ints Lemp = shack (hop Ig; ire Tere Consp le t 20(1) ation fempy } ee 2h implementation of stack = struct node f ee ee ae ee ae we Push Ck ag is na nod px (suc nods *) malse (cof (but sd = WOU) £7 chucking whether mevory in pe ne ty os malltbe”) ; //no are i Sept eee HET Her fash), a Ge (ae Lt) eee Se feu. pore item = head =>; pekead 5 fend = head -> link; “ eee free(PDs Men ai daa i © Quowey Ets stack, queue iv aloo trcax dota structare. In Kock, we tnyrt and Aclete Hs element from fhe sone, sede, bub ir quo, ee savert thy element fiom one ede and remove fom Ge othe aole. IL fellows fort an font out (Piro). Too operations in queue. oO Engue — tsaecting element ® Dequent — dtleting eleorent, Jn queue, boty age Bee and dequeue eco tn Sone Airection : be € f-frouk A ir pas ie Thexsfene wtf ain a fe op Poovey a, ac ww kft. uf pats oe Creular representation hh ts Bs wails Doge ca make une CONN 2 A NOTE > Wharwyer queue oo enfoly, tf Gelb Print to Hs seme lpcatian' ee, cece. oe. [i ae ae engerue (item) { Ain dequaue (') f year = (reart!) mod N35 z (Proxt= = e rea) { ' 4 (front == > year) { poof CGurur io enupty" ”); Pet (Moun Dft")4) peta -1 | i} (veav= 20) } weave n-ly che { sont = Front () mode W5 weary = vear~l5 ite = AI [fronts return; fi } xetam stems lve { ue g Ceca) = hems vetuan; } t 5 Condi tion for co Bebcoean 6: and (veaw +) mod n #2 frond oe Sgt OTe: We lea a grein he queue in ordor distinguish andexftor condlibicer - If we fu & nV ak we Wilh rot hk abl ‘f diskingeutch « “G5 ee queue OF capocc by (n-0) clavrento io . ay shee inde Crete rebectively. Te cadlitn Bs es ~ wae to fl Geart) mod n <2 foont : gph PY front = 2z AY Ov 1eaY= = front FA eealon finked list io cored t» repraent o quo. A variate “b? in wred ty aces Oe qua. Te which node thauld. ‘p’ pat tf sud thet, both te sPorations erguuny and dequew ean be fefemed sn cenctoul, Aime! i : : 2 (phe 2 | F Reay node (6) Pront nod (©) nots powthle (@) nede neck t eae pv ak pevited by WAY rod , foot. ont SL” } 7} sp) trea —— foot Degqueue a sees ond Aequeus in covfod Wash op 8 fons pounukation cov be obtained the o/h Un the cane endn) woing a Rack a hat ths fp iv the equine, 1,2,3,4,5 jh that ord? 2 O34 502 0F754,5,2,1 @) HS, 23,4 (6,4, 3,112 cp 4 ah 4 a ve yy a Page] wes 2X ey x @MeewPwReeweaeaePre* NOTE > Pago ri queue ina quae in cli ov eloment ova record dn “Ge queue GC Rave a key ond any elemont Mo lack hey e mow hoy (depends cotother & wae ‘prrity er max poiority and wil be dolotry ie Be order of tho, pros Troecticy Con be in any Onder t %, in orclor perfor sich Actelion , be well oa ers in ordi of thor priosly f fo debted. (a) token a proxy queue wed to implement shock the leat eleven’ should har Ho kad a (fx min , priority ) fo be Arde : 0A pro aty que ‘8 in wed to Dnplunend a shack ‘6’ ) hak store characte. PUSHCC) i» snblomented ay : Troext (8,¢, whew kb appropriate oleger key chosen | by the implementation PoP kn finpleowented a De ereM IW(8) for a oe of PUSH opecations, the key chose an in | (a) Non- docrearing Osdler @) ona order ©) strictly incnaring onder. LAF drictly decreasing onder: Wl 'D be 0 shack of sre nal sharting with the tack, sappoe ve pus te fort 'n node renee equance and then Peyfom ‘»' bop operations. Assume of te ruck operotion. Pox ml, dufiu Oe ea.) q pom te the elapse fron and & fushny) to be ep opercdion Grat removes (m! front 5. The | ay PY — eee Tl-ytx+ytKxty ia ty Fox L eluvert, -OX49¥+Y fot 2 dlantaktol for 0 eliarento = Let2y+Y4Y Met eee ! ies but “s by Le Ppirer > fow nv cluvunto, poner y 2 poo ie ~1 21x Soria | na pera iz Zi = 260) 2 (H-aXF LODE . 2 AOE TEUnADI FY oh ey ay “ibe ’ 3 stack -tife = (n-1) aX (m4) ny $ hy w = (nxt (-)YtY 2 @-DU+Y) + 2 nCxty)—(xty) #¥ o 2 wtetey n(Kty) x And. Ob inplwented, untag toe docks S endl San give dino (8,) t push (S,,%) 5 _ eee pie w-doerts ; (Kn) - dates * X= pop(sids Xe pucten Y= Pop push (SL) X) 5 What is hy wlatiouohs 3 bw Ge shove vrantabler% X= pop ($2)> _heTe: @ TH queue operation ating shack, gee we male we of 1 Kock . abedef Gn ®e At stark (61), ve © push the elements in order of their arrival Next, we pep te elovrnta from St and feush tb mr $2 and the order gee invected and ferally Ho pep specosion é w carried out in $2 and reseclbant value preserves order of arstal. Cory clemunt bar fo drewene from S19. re, FIFO io Guplumented oes 9 stacks. Now, foo 1 cement, feat inert, fF tal c Lah (tJ fox Sa 5 2 pas 2 pep. 2 puch | 4 pop | Be! sii n pork, e oe ae, Te fost element Mat hoo te come orcl im prying, fore foo al thy elomto which han to cone out (ater | HP you sind a token Us no. gf paseo “ond pops abe def 4 Q : : 3 d : ‘ ay ea bee) el) * Sn ore bo inp leoenti ' ! 1 w SI} | ' i Mont (ose > It you werd ald elemento and then Pop on dlemards, UF in going tb take lots f Pushes and Peps Mewording f the quesGon, oe S| Pose: Det) | = mtn a) bet 9% sr @ for te bes core, all Sw? clenwento have fo uno, from oubvide to St amd hen & $2 im order tr tome otth, it, lin. the west f the elencto (n-m) ur have fo aUleorl push one eho $1 withoed push lo $2 ond in that way at Con sove mony pushes. © for th wort core, atl 'n’ elements axe pushed an st and | then tle 92, in ordex to delete ene ebeovrardh, 20, 2v pusher we required | © For the beak cone, af 'm? elererto have to be fopped ence ] “aa ond “once i $2 in order fo come ord. Therefore, a Bae shes Pic ta “eseiAe andl . PibPed. from <1 and then 'n elunento axe popped fiom ae a nem EC ant required Ais Be 62 | Pelticans E ) ancy ¢ nem ae whore, X> Paso Be Pops PUSH aad POP, an operation reverrer Mr order of t Clements ov te stack. ©. Insplemrunb a queue thu above stack Seftcnkitae shows how te hoe “ENQUEVE” Using a ay opex- ation and “Degueve” Mig 4 a of 3 1 Poration eB Post (arbr6 fafa feverse x | Pep o ro Revewe, = FAG le 2 Exgveve > Posy ood pipho® anti tnBlemitadion: sabes sem hedaitl | > Dequeve— Reverse, Por, Reverse NOTE Vie Vewa tan be done fer Enguens 3 gpecations and Aerasue fi operation. ® Tyee ty postfix convexnion otis qj. arb atb¥c atb-c asb-c) — Fnpex sabF zatbhex 2 abt-C > atbe- heh zabext 2 abte- 2 abe-+ —Pestfc € > Follow Hs awocietivily and, precedence of operton Sach im wed f comert an fir ta portfir. We dh the operators only, in the Cac: Precgdince? + GC, when ue are oubeide Wt oxenthess tt posentherie qele high precedence - pect), chu we ar avede ogee | . j ' Now, wtrg tock we Gall only push & the oPerators 4 dito te “tack. Te operator to be pued inte te Rack j should be of Regher Precedence to the operator in te stad: x4 for ce ¥ D4 ~ fox woe. a ras i Sac eco | Nh] 4 Opexator shoek fos av baie oe 00 98@ [ YY EL abs cd-+ And. + vie whnever ue get reght Parenthaso, Le L Pphog of te ae we get te ft Porentiherts, bere: The size of tack cell raver ao beyond ‘w! if w i» te | ae f Be expresiton. hace as O(n) ) Magosdthas @) Guat a Pack ©) for each Charnckex %t sn th t/p is @ CV in ow operand) cuspid 5 os cle if ('t & a ght paxmtheris) eb and outbut token witil a fof Poxwthert » popped Chut dort o/p) Ap EB hbstoxon spose om bt poruntheres Bedi fokeno unt one. Gower priovity than tbat era ft me ee ox By stock ea push b 4 © pop and ofp smth atl Ce foliens until th stack cont. @ Poster evaluation Algorithm Tn this, te operotow will be in th end. WETE.: Thin convertor aw dom, ar evaluation the expe s- forms become any once i w wnverted who poskfir on! sede oo con fe evaluated in on pan. Mock of te Coo.pulirs axe very Compertable P Cu expressions cor beg evaluated in cre pass. t Hf oe Bonk woe poste erpresiors » we GU continmeow é howe fo evaluate «© part of Ge expresion and come back ¢ and evolucty dorothy pet ond % on. 0, ib io 789 to | fake alot of ime, Infadd O(M) time ov rere« ' fos postfvc evrleotion, ve well push operands into He tack Therefore, hack i aloo called operand hack * TT Whenwer ue encounter on 7, 9080 GIF er cpecator , we psp ¢ elewunts - as coe aie unary op. L eladrund fp. foo bine 9 2 eumsato Pp pop th Lt damunt in dock becomes th ad porondl eration in again pushid back - In eae bb Z ius nam 4 Tene Complexity = O(n) ,09 Gu expression O evaluated oy Once. Space reqil red = nO. + ofexanclo , 4 nv Be sre of te expression , Ko. of opexonda on = O(n) » pace complurity - §) AER ov for post fir evaluation + t Sean Us postfee doing fiom Left te otght 9. Initiolize au cack - 9 Repect ef Y and 5 tit all He chorocters am sonnud 4. of Be scanned chorter io an cperond , push ob tnd the stack. & Of the Seonnecl character in an therator, and # the Operator in uno, thoy pp an element fom the hack: J} Re operator in binary, then pop 9 clunento from te Hack: Aptos popping he olimento, opbly Be dfexaby Hox popped Clomento. Push the welt av & te stack. 6. Aft all th elemento ao Komed then the reselt well be in the ark. : duction tre frovwuel > wy Tres May tree hel has almost 2 childun meand, whol in present im ery node, in what w we, mn the Roda strurctum: we oe sordhu foo a particular node foods the derirtd rock, ve stop. (i) Post- order CLR Root) Rhea #. Tro relax — BAC Preorder — ABC Poskorder ~ BCA enuaioy Wooded NOTE : Erety rode od vistted 2 ttinen, before we fenich traversing the endive tree and we go back t te inibial point thew we ish Bs nodes fv te Jot ime, He io pre-order - Abc - Tk firme. hen we vic the node pP the 2nd tine, th o in ovdur- BAC —Dad tive Ghev ae wink te node fpr the 3xd tre, it v post-order BA — Wad kine. eas Thonlex > BEDAEGC Preorder > ABDECE G es Po towdor > FDBGECA 4 5 t f f . : | | ‘ | ! | | f uplavertation of travermals and time andy spot analyse 10 att aoe - dhru vode eft rgtt> EE tele fe " hovernal,w nad nob rebww dota. %, we can doka whee ve have vist Re node @ vid Trorter (shoud node xt) £ ewoOt CUP) [fais ie rac Tnovelex (> ft) 5 ptf ("Tec’, t— data); 4 (Knight) this seurn spocq Ano rele (> voght); SSO Dae Sa Tere couplety = 3enxe when, 2 O(n) Cz Spec compleritip = Oa) @ veid Preordar (truct node xb) f # (jE 1 Poort 4c", trdnte); 2 4 >4Ot 2 Preorder (4 UPE); WE esa (> %ght) 5 = 5 ers _ Preorder (> vght); © Doubts order traverraly (frceting value 2 tines’) for ony fravenal other han inorder, preorder, potovder, Ge tan follow the Pitoutng Void oulble Ordex (struct rode ¥E) t if (t) { +4 1 potatf Cee £~> data’); ee Ne os ap (t= left) \ Ue %. DeeefaleOrdax (t— bt), de a: potntf C"Joc", & sdaba”)y ~ \ Sap (> aight) J 6. Youkke Order (> vight) ; Ypabbdffdaceegge Si @Trpe ord toweel> (printing value 3 timer’) votd Trip Order (souct nod at) a (a) 4 a paint ("toe”, k>data); A ash ip (4 Mt) d ‘s TifolOrdex (A> lft); pratt ("foc™, L—> data); Os reght) Trp Order (to sight) 5 prot (“he", >datel); J ch_mecanwniow ot treed neck recutasfovy neano ont fonction well call “Ke other and, the other function oyitt call fe colli furdion. AMS p Bsa 4 ~—_ oe ee op + abdddbbacceee cas Por ay HK SS i a td et as ee void A(Shoudk node x4) 1 Y(t 1, printf thc, ddata) ; a. ab (4 holt) 2. . Bit); 4. iP (£ wight) : Bk night)» o/p? afbdecg < 1 3 Lasting With, ie) x BOLLE vec B (sack node at) £ ADAMS nue die i (t) § ( é : ; patti Can ov » & : eli BLINKS Bt, OFLA Prd y, 3. Heth pranth (40>, t-sdota)y Ae Mhie 4. A (ta r6qhd) » oP re ef Ss ACh ight); Sadting with & i NOTE: Grew nods in executing either A eo Bb. And there tp alternative erecution of A and & belcocer the hevelo of kree- ® Nunder of binary tree foucble labettid ond enletheled = - aM the brary Gre act 3 rodeo A, Band, © whid hove Pre-erder 0 ABC. > Now, freer vttt 3 labelled node, | breep possible ; ae xul ich On oH 4 e 2 Now, wath pre-order Apc, SNS gee The above well gee ee ao AAC wiblo = 5 bx, = No. of be reed fe vith Peon ABC 01.2,3/4°5) Set of alt binary a elk nary doen footlhe + 4 Aro dren wit w rodeo Pre ord ABC a 2.45) am pot order CBA CU Note = hs we are brying ford te inkervec a blew ABC(Me), and CBA(hot) Te cell an ABC(Pr). eee posible oth 24 ay. pe ord ABC and post-order (s) CBA and inovder BCA efrtee with preardar gir 'n! olwantd = en, ey ain om fo si oy Uo. of trees fossil oti pre-order and post-ortu for ‘®! clomat, 2 We CON get eo bret. chic "eatieh the condition, OY we net gel a tre. No. of bees posscbte wth pre-order endl fost And in-order = unique ye, fo ssoble Bisa bree. OTE > (0 weed net fay cut for intersection of all 9 (Pre, forte) te get unique Binavy free, we con ao ik simply by * ways, @ Tn-orvder and preorder combination. ® Trorder and post-ordler combination. ® Construction of pee ae binay bee Tnorder end preords: eg. Pre-order = cm 5°. A In -0 ver = mes . 2 x no. Nore: IE w e gtd ad ES haeen . Bok, ¥ laxge 16 bre a iv Seecuoy way, wx bake es hie and suppos in pre-ordu ve ind the yoolo of tee ond then 90 © inody and refer te thot rode pow preorder . Ten, noder b he of fy-0 velox node lier in bbe such bree. and abl nod voght of ik, Cer iy nGylt seh bee Be 4, 5,6,4,8, e582, bret © © gat: 4,7,6,6,5 He INS 1, 2ed. 4,5, 6/78 Rts 11,4, 3,48, 6S Prer 2 Say @ Ci) GD : ( ©. Pro-ovdon 2 5) 3,-2,%,6, 8.7 An. y Je @ Reewute progam to wunt Se no. ¢ no duo SS srk node f fomelas ah L3 Nw(7) = 1¢VN( EST) oo) shack nody #2, tyes 0, To Meee : B5) int NN(Souet node #4) f ip (4) € rchoon (14 NAL ‘On leg elor [23 ted retuw 05 HL) se s pel rel ASE ab NN( drach wool xa) L vita ’ 1 ee st ® ull tat ag ave occ in be bree + shud) node € Foswula : mt by NLCr)= 1) 7 2 als shut node xlehe, x eight ; = NL(LST) + M(Rer), h ee rho tnt NU(shruck node xt) £ H (1) (t>10u) = reluw 0; ® yi tt P Ceatepe BL {E> royht) cal e ee Tebow (ie (t ft!) 4 NLL Ghd) 5S } @ ® for no. haven > © pox no. of waren paar ee ee fosurcule, : M20, TH bab. 2 oe SP 9,6 %e rz t Me “(ted Pi Reewrire aoe & fond he fell roceue . [2 A full ned i» a nodke howing 9 child, Wat ee Wh PN(T)= 0 > yf T & Now 94 =0;4 Tu leaf) iE 2 PN(L> UST) + ENCE >25T)40 5 Us, UB 4 T heo caly 1 child 2 Hee pee es ca 4 Twa full No . DAA suk PNCoAmch rode ¥t) { pNCONL yp Ck) reborn 05 Tene Couples = 6(n) ne ed U [e>roqht) o can -O(n) 4q 1 q 7 | 1 1 1 t 1 L2BE GH r t t t t t I [ ¢ al L : f iat H(Aaact nob *€) f Fomnuclar ' ‘ tae YD= O17 B enpty | 20:57 bap ele. Ke ee et4 bisects) Teve Compluritin = MOC, whe 3 iy Ha wo. of of uy ise) nod in vised. 4 = O(a) spas lonplrity Te a f ts bee » Ola) ® Intwduckion f& Btnary Search Tee + BST wv subbord to have déctinet keys ox rodiy vedas. The ches in UST should fe ox Kon he soot ane tf de RST should by greater thon: thy sol. gee fem AST wah, SO, 16, 62,5, 20,5%, 41,3 8,34, 60,24 , | -. Treo rder : (a) NOTE > We camrot ccnatruch He binacy tree dinelly, diver Gs — Morder beraure Wu gh Us owl @ : and if ue by to braver i and ie | get “emai we GB rob gh ib. © Onky advantage = bray earth bree i, te inorder | trevernol ® in sorted order 2 Fxo, pre-order = 94, 15,4, 10,25, 22, 23, 24,4, 60,50,95, | Cog fee many BST au foul with 4 disbinck keys? WOTE > Kop axe valor thot ve axe Laying f Duet it | ito He bree. IED uw WY Binoy Trees where ox 4a how wncoy dikine tren wo possible este “n? unlepelled node. $, the ‘n' erlabelled rodes and Bsti oth be same So, ds queotion wth unlabelled rock an BT can le ended t BT wrth labelld noder- BSTs post with keys (dicinet) = een OW Gr) «sede NOTE 7 Binary Search tree has elements wred in inordy, hole Benany Ti a be with » rowed © mary “Tite in Sufoly clock <1 hilum ea (I-10) in BST. Search for 58. ee of he fotlowtng Sequences cemmot be fhe sprog Of nodes examined ? a 1, 75,4,43,60,59,55) () £40, 2, 68.39, 62,45, ss} 19,€5,49, 68,43,53, 65} ee sa @ 179, UY, 42, 66, 6,53, soy NOTE: The sbuctuw of BST citl depend on the order in chil ae The clervanhe we come across Aspendo heweadl BOT, Us Hine comblualy ty sordv ) sft, wort- com complet. $0, to reduc few, time complasty 2 O(log w) AR Hf we wsbick te eight of RT, & eg te Girne complexity req ui ved * Order of betel Grenwxally, tive cowplity for 8eT= Olu) cher k= height eos Th i Rus pocorn, induder and Gait he follo Covrespor Z) , ino Bids. ‘Oa hich mes : ~ MBCAPAPYK > KAMCBY PRY bi a MABCKYFPH | { |! t ( ' t : Tes preorder , root node io in the beginning, ' t t i t Ls ZIol\= for postorder, root node i» in the end O dha, 1: Post-ordix = Pre-order > In-ovder | oe A BST store» values in te range 94 t £78, onsen 8 the fotouing sequsnce of leys. &l, 534, (09, 39, 285, 346, 305 9. $2, 47,101, 195, 20, 381, yq9 ' (4, 148, 520, 396, 245, 290, 207 Y. 550,144, 504,395, 403,402, 78 in securely ansuncee sfeatly , which of te pttoweey sequence F< tt Boas eamaanans mz which of he ftlooing i> foul @ 2,4 ard Y aw inorder Wyuncos f 3 diferent 68 T,. HP iv preorder sequence ef some BsT with HBA a te reeb. LFA van worden of some BST with (01 an root and 52 aa to, @ W wo foskorder sequence f som BST wit (41 a0 the rf. Gre We at giver sh of w diskinek elomunte and an anlabell Binosy bree with moder. In heer many ways conv we popuelocte the Gree wth a giver ek so thet it become a BST Ce, inorder bovertall') | BOO (rh aoa! ay Pe, | “Ca @ Deleting a node from BST = W) Now-leaf : Ca) Ore thild . ©) ten children < rode NOTE ~e@henrver ux have om cee and oe have a dhild t thet las rode ond ce wart to debt: Hat node, ov make the dald Point to the gromAparond and un woe cov delet Ge rode. @ e ond woke th last cement from the est wnk node elre from thu (opt sub bee lid elumenk & faint fo He pre oT property oo eae D NOTE: Jnoweder succenor io te boot element in RST. cg. | Frovder predecenor & the Mghok elownt a LST. 4 12 ® Pend virimuw and mori an a ATE ——— ———_— . Fox mtromamn: fend nai (struct node at) 4 colle €L->eft) 4-4 left; For mawinin > fxd men (struck node xb)E while (t+ aglel) 8 bo hoxtqhts } MOTE: The find_min foxcion cor be wed to fad inorder sercenor. bad findwan fonction con be umd to fad Hordor predecesror. SA complcte s-asy tree io on in which every node (oleae Ge cal. If 'y) in the number : mbernal, o campicly ray het, he mumber of leaves in 5 fox 1 ckewal rode = “4 iN Dw leaves. fou 9 theinall nodep | X (n-1) hoes | 66 0» leaver- - (m-) tn = In~] fov 2 wnterorval rodeo (2n-2') tn = Siva for Hsikennal sodep > (Bn-¥) tn > Un-3 for x boteraal nods» Xn - (X-1) = XYw-X 40 es 2 X(n-t) +1 AM. Ge Te weencber of leaf vader an a woted free af 'w) nodes, wth ead node howing © ox 3 childbeen in @) Vo ® re OAL dy Qa > Le IRD +I, from above | peeg Fd, 28) FIQH)+ | haw ¥23 % ate bs a4 fm SOD hen, ; Saas 2 Bw—-nFl & bg =] be —— is 2 Complete (struck node xt) ¢ Ww W (toon \ t “lem oe by UW Clestept Lb H>rxyht) i" ee : ay (Eo heft Lb trvtght) reli Cistonplas (eS) Weal ets i 5 @ Trbrodudtiow to AVL drew ond ballencing + gees wt ee NOTE > Main satenator of Gerary scouech ¢. w fo make the Recdi-| effictent. ! ie | AVL Bee > b a birew balanced Binary gard Pree in whidi, df ve heave ‘wn’ rodeo, Ke height f tree will be o(lon), | Balertod BST > O(lspn) + Ordinary Bs t= O(n). AW ip hard ow balanced factor (6). be - Height (LST) ~ dteaght( 2st) 5 whew, -1¢ BPE I OF BP @ nok ar Tonge [HII], he See fo unbalonced and { 1 1 | ‘ i i i | | | { / | By oS o ' oe folate, Lf fla a XN Ek 5 fe Cockootse. | @ Conatructing AUL trees And time co “ Pass NoTe? Whew How W aw jnbalanee, yor fo travel. foun iW netoliy averted node and fend oud whedh Lnbalonce db. - 50,20, 60,10, ,15, 32, 46, 11,48 © axclt Balonced eal tenth, ree. (AVL bree) OCtegui) O(logw) + 6Cogr.) tc - O(n) G4 14, 28,1815, 10,93 ,% ss © Mirinuow and maim nodes dy fn an AVL bree, of beighs hy Poe , 2 49 4974? > No. of ” y ” v » Seen Above Geomebvic Luiken , wih commony differance a - Man- nedeo fesilde - AK (ue) ee ate af [ wy ] x ae Pro, Minimeun no. ~f no den pee Y ee deat poste w(h) = N(K-t) €1¢Mh3 | MO = 1; heO | NO)29 5 h=1 | NO) = wt) #1 +N C0) bt Arie 29D et j es ) Saal MO) = wee) 41+ wr) 2 yttto Peat fee, th face min.- ro. of nodes prset xe of feight Wao ht. with, minimum mo, of moduo fe mol ufo a hucght marimuny helgt we cow get or Rob See. bee 'T hap eo :,: a tat node>. Te rundoee HO yidb ok. BP Bs no of rodeo of degree 9 ir n, Min lover & ml Of the De Me saints no. f nodes f pe %) ent Aw. pot N(n) = N(H-1) -149 { | ( MDs 2 | NO) 2 N(24) -1 42 & > NU)-[+2 = 3 7 J { { NQ) = N(2-1)-142 we : wea 2 N(2)=142 iy Gencrotiring ; ae! e vw no relokion bls N(A)= wD HI ea Be Ge: a d ie oar 2N(w-a) tt Hl ieee ( and the leave. The only reLalton- Cie Ship Bivast ee in binary bre + U(n-b) +h io 0. of qd dare and -N(t) 40-1 ( > wie of 2 24+n-1 ont Aer, t ' ! ( gece 1 “Tra Binary Hee th v0. of inbrne, oda of dagre 5, and number of internal Sa ‘ol, The | lhe ¢ leap modo in the 2 free io | Qo er ow ws | whide he fle in four abou xarcth tine | 7 Av 4 ect | A Ollegn) | OW) | OC Legn) O(ntegn) 2 © O(n) Oleg) : (a) O(mleyn) OC») i: the nad statement & fal? uth nodir el Ayes, | Bah Labelled sooked binary bee cor be unigtely tonuty gern Bo post-order and pre-ordur hroveual . ee complete binary bree ditt (n) untourol noder haw (nai) teaver 1G) Te macinusn number of als of in 0 oe : cS. ie OD. poh Ina Binaay foe, for every rode the difeunce bektoten | es te number of Trot in te. lit, and ght, ube 2 ail ae oof te height of bree in A720, then the minimum number of rodeo in de tree in @ ght ne elon yah yah . a> NCA) = UCR HT + @i(h-1)-2) > NCh-D 41+ N(h-1) -9 ] : = ON(h-1-1 pp NQ@) = 2N(2-1)-1 one 0 wyes = 9(2)-! a mals ag jHiléas ho 9 H M(h) = wt h-D 1 —@) Gf) = mW h-2}-4 —@) (Ue2) ~ du(h-2)-4-— Gi) ) in (i) (2m(k-2))-2')-1 P v(h-2)-9-| (2N(h-3)-b)-2-1 [Pething Gi) (h-3)-g-9 -1 rs gk ptt -9- (okt ok = 2kw(h-K)» (241) —w) | Now, oy aT the bare condition Ge Con shop it, >. Bose “condition, h-k=2 ke h-2 Ad pplying the value of L in WW) NOND= oy (h-h-2))- (2% 1) zs gh? N(KA+2) ei Cr) =) h-v vQ)-0'*_)) = 3 ON em st) ie ea 2 9'T 4h Bio. NOTE: See We car aloo solve the queation by wring examples and perth fe value te Ge options cr order t validate. eet ; ti fl lam. A kre balanced binary tre a binary tee in t an fr every rede, te en bases mols C | of nds in the and Kesh tabbre in atmod 1. Te ait. § du from He rook to te length of fe patty tom th, | the node. Te height a bray bee & 4 menu teonco of a mode from Ge rob wduchow on hb, thoh a see-bulonad bua: bee S Reight ‘h? contoinn otlenst 9 rode. a w(h)> w(b-) +1 (nthe D1) Q N(h) = ON (ht) 0) G) @2 N(D-1)> ON(h-2) —B 9, 2 § yf 1(2N(h-2)) N(d)> LN(H-2) —O a fustling OnHw@®@ N(h)= 9° (2NCh~3)) 2 9>NCh-3) Kerexslng, O a n(h) = 2*N(Q-k) —) N(o)=1 Nl) = DN Ch-t) Nt) = 29(1) ed To eliminate the factor N, we cow make h-k =f hkl kz h-t—-© Putting © in © NOh)= 9" wr) = kame: bh ET Te minim no. noden that con be present fy a bee af height, ‘hsv case of height Sk) = ok Ano, (Proud) fire balonecd tree] Nows, by indueckiory , Sf N(h)> 2” acen 7 induction , for het ght, ‘hE? NCA) = ha Q (AHI) = oh it aA @) (6) uy Subpos them axe ‘m’ sud numbers in T. If the Rightest upper pound en th ftimw to compute Bo sam wo O( tara 4 mi log ®t value sf @+4 b+ lee Ff0004 ioe $ bpose, L= 100 54) = 200 * Rang » 1ot-14% BO can, dl te 10. might be presents there - So, teow aap z m(logu) , where m io Uw Mot: ro, | an Tonge L and 4. ~2, Gow, = HL) leq n 1 aloo —(O) O(n? log bo Ee Vie leg 41) tuey-tJ a0; b=0;7 C=l5 del, my toont core, ~ Q410b +100c +tO00d = 400 (1) 100001) 2 1100 Ana, Note > In adwance algorithm, a co few grxph> aleo hoo Be ~~ euvilar bend of problem. 9} vo, Lend Hae lorge subboe , L= LMillion 5 Y= 2Million , we find te, NL N85- UME Se maiptigln G6, Bis Kind of Caner, We Prwvere the BST in-order thre “Tew Complexity = O(n). So, we gob a wrbed ick ona sored Lb, we can apply binary randy wo going fe fake O(4BG Rn) ier. ae Sorted lish Binore ais = thd a pee ble Land Ys 20(W the -values i ood Ly ween pak br ® 4 @, ve ; @ ffresion tree F _ Pore Tee pee ees Convate have 7 have got some ni fecorneo (eeetolianae re si ve do alll hone) a+b 40) Pre-ordex > +ab og Inowdx : 4b Post-orxdee alot @atb #c Pre-order : taxbe Tncordion,: 0+ D3 Post order sabext @ begat) Lie Sn-osele * a igs Z Mar. volur of the necsion ° = (tate)- ~(o-d)) + ef) + g+8)) (G40 - 0-D)+ (©-1)4 a CUED ECHL) ® Vaxiow tree re senboctiow NOTE = Lory node resented, a struckero and thew | ae poste petnking to other node. ‘pes binary trees, ot ned too pordters. But ip Gow ate mox Kon two children in the Sree, we como’ we er Sree representation. (WIV sec a cares WE Um representation f GPt chaldd r¢ght Sibling (LORS). Jn Hho 1 dery nad wkend of hawtig 4 potter we hove 2 potters of which 4 psixter wilt pout te th tpt chile, the oth power wutl poo to He night aight peindex wll howe the ole Sthling . Te / ao NULL. weld e choo y 4 Lees (mary 2) Fe iv unc fro syprecenting acbitray tree fox 0 chilebenn oc 90 children. ii) Array aprertastion Ss 0g | gf a pole io at inden = © bila) 2 i 2 ditt ee bi seed J nothing Bais ina 7 p put it ling ds ‘iyi by |. 4. (0), *2= 100 shaw, L=10 Ae. AG sow e oitl 2 1 (100) +1 = [00+ (Birory o) = (ol ut the pons De es impure, Dap Olan of the ne e > (108) ‘ “2 *(0), aw Binasy ub nacono YG ML ape | { t ; | l | , f { ' { i pee red binary free ao away, a th He Used Gang } in ble ale fla} . NoTe > Binary dre apreseatation, 1D Tusefol, Y ve go down te chilean “a Gel a> go up & the pa aoe senfation , We Con only qo down and i soaight - Jorworel, ae wx howe pare the pount. MP lementation Aray mprcedation o widely wed or acadaler f hope Sr heap ox. wihore te go doin and up ond moreover, & iv beneftctat fxr heap because leap DY mtomalmod tomplote binary Liee- The Ms advantare of amay mp resentation lo in care of Sy bre that aw shewed the die of the orroy reader ore ! He amay tire pecomes wout- tax oti id ea shies wr ge acs coup grows in bud ortix, thy i i better f go ca $0, Bi heals axe pofey a fh this representation. ig 9s (XYZ), Y¥ and 2 con fe NUL. Th in sted rep resentation, & go He Denaay Drees. Which a Qa binary in below’ | yy @ Ca(useD) LI ONDLSCH) ; wd (39 sop) AU (23 mys) | rook Rocld be o aw Rould be | sonal elon, 3 he ce | pet Fe aber 12) 9 ont averted inbe a st in seme Corder. Fr te resetting fee, the atght subtwe of the sect — tentoins tp’ node Te fort no. be anerted in to muck be @p Opel erp Wrpt Lect | —> Ad ebounts tn LST Rould be lex | than rect . UST Sy ; 2 (112 OP OPBAD (Df (n-pat..-..")) zn-p-t (2 di COPD (wp) (mp) Roct element 20, dot element aS, asray oe W digind abeger io ateprted oa temple binaxy Te dur Ge fest element of te 5 Fehon, of fhe povaud of element X(t) ,Lf0, b | 2| OF) ATT BE a wt a ye foo S, 2 K) 3 @) 2 for 3, 62 aA @)! BL]? wI fs Sepp ri x i Tp Pee ee r€i-1-1< “+t cl. . Peio Oe Be cuile wee Latah j-a-lie tt! . 2 y-| ne, 2 [BEAT ond (EN, bo t gue 8 fe rect node in of uel 0, Ge gas «(, tf0,v @| 9, i] Ofte, 010] © [4, 0) ona, a = by, elininadi Cpiion © D the Gnswer- ‘ Te other woy, ‘ en ia a el Ard oll eluvents at st io got hove kevel k- bourd be & and higher howd be & hsis & Co tt tot! ah Oe atok-} gtpeoty lo ace Be ail i en Leg, Set oe, i hts e cotta ol [bog Gt2) I] GI fe un child — ait — sking wpiuiidaince iy wed, Fad [ t ' ( ' ' ! [ f f t note in th bre D ¢ type tree Node : NOTE NOTE > Sope—tef tyfaduf bv nothing bet to make the coding sma | by wre of abbreviotion . | pear struct LrecKedle three to; ; breeNode f [ Seep WYtMostChald, Asean t hp ak Dae (ereehr tee) wnt value =O; ' q (tree NULL) { td ' y (tree > loft Mosfehild = = Nu) ( t vole 2135 ’ elx t ‘ 1. value 2 Do Somutlu ng hres left Most.chite) ; 2, Value = value + DoSomethng (kree—> ae es ' ' ' } sekwuv valu; ' ' ' Nb. of eternal odor a courted. s 1 ©) Height of he kre wv perks 1 @) ne of rodeo willrout aight bling i counted 1) ro. of aver ao combed. Ys Non of be pons aw covvected becowre ve do ned tavern, Ue emplete te. Only a “port of Se ee io Rraveued. | D Intro duckie to hos ete > Te Worth Weds Oc w represented sea fatto J Pid ae: a es fo fo anoth wef, 1 the thal io aw e- Abo in social | The mado Aifexne belwewn Lore and gray in, in rey all | noden axe Conmmected , in, from cw node we con scach all | 68ly nodur. tole in grap. such kind of breversal might , rob alionys ‘be posible, in sudv cane ib in fnouen an earch. ae mh ate aty ‘i | Seat tednlque > meand we may neck be able to ycet PT tede, so ue du intersted in o roe nodeo which au nachable. Use Hare) we ceev inblement Lraveroal: In social neko’ fe (ley fecebook, Qh wggestice of nothing but Breadth, fersh Search é warthing modi fint at distance 1 thin Soe vepind= 0) Civica! uifvs We wield kewe away of podbow and the awroy will contain no. of chearencts > no. of nockes th grey and cael eleswunt ett conerboncd aw node- Suppow, ~p we have 4 nodes, thn then will he av consis ee 9— a (Ha) » (-HalSH{ f ¢ [Het tal) shane eee ce ee ea Kote. = Erepoly aepreertation te we, for Aone res choy meds if E's o(v) fr pace 4 api Saked tisk BEEBE UO 7 ere Tn case of wt Le Ge ro. of eigen clamento’ © UCR m we ined i > 96 an these will be 2 tne rep resenka- tiow e the some Introduction of BFS and PPoy S. ung iy Qo on 2 baowy © Vistted - 0 node w Acoverd 01 fousdon printed. Explored - a rode m Axseovered and aloo He woes adicuce et b th aw discorend. afi | i | wd betp o. Hoek sP-08» et bee Po Other algorthm Gul use tad Deel enue ‘“h algoscthn ~ queue Brcadlty - ~ fost Sceureh,. Te algs, ae epitls -Pit Lech hore keep Crock a nwode vv visited or n& , ya f we an anay, place 1 trea, Me rode UW visited and Be atray e inhiotired with valu 0. a space req used -O(8) Pe Ope de 5... 76: alup. ee tb we Ww amay a ae a het con be Bie > i fr beth BRS and DFS ® Preadth— Fine Search nition 5 ee BPS ie | and amray CI ax gibsls” vidled LJ in inttiatixed & 6 i Wav vistled fv] = 15 repeal be oll vertices w ody. bu fy (outed Og 0) { in empty then rekwur, 4 Co = O(n "nd nae ower , in care of Be = 0(€) ¢0(v) = o(vte) Roving (EN 4 Bee gh a ® Lt [#l2']0 [Dole] U=[ > We £2,3} “we 2) if (vided [0] <0) fatee Tru 6 (2B) [_ wished (e) 21, . 3 5, Luss ¢ (vistled (J ==0) a Frup visited [oJ = 1, uf q ¥ embly ste — Palse Aclete the naxl node (tment) and add tou, eh pto= {4,5} STERIIERI oa « w 2 can howe more than J order of exploreton. pox amoy, CITT IVT 0) teu } fos que, COUITITTI 9) ee fiitay 0) aitenec froweyal wring BPS Note: he © we explo th node may be mor than 4. te @ bs auvely sto ov cee mobir Aanplemanbatti on, oN scorch if oe wt from an elernvent we ult Hoe elements Kot ew sadable that ete ; Oe grup, ra ght jot be connected. Jt might be Time Comfdrrity O(n?) , a» a node to exHored ‘ny’ ten a viicting alll rodeo: Geant Oe thal an wachahte . BPT (G,») { a for Let tw de 43 vidted (£20 viel & w do 0] ol] eee dnt. (0 JO JOTOTOTOTOT o() Be CE er. i mr od BPS (t) 63 NOTE > Time Cousploni BET = Tne Conplraty BRS, ow je nt W noded- t L io wo be vesetid 26 tine, —{il) “Tie complexity Perr - Ofer) CL pod) $9] 1 rea wy cove of Baypaency list exploring ak cther. in DPS. toky in BES, we emf gq elements f a nod and thn explore furtto» Des(v) ¢ viseted (J =f for each verter w adj. ov do 4 5 ib (visited [10] ==0) ther q | | { { 2 | cee Comb luc > 0(v) " ' Troe Conppluicty = o(v+e), for edjooncy it. ' = 20(V*), for adjacency abrir. | pet (GE, x) t fx t=! tw do visited (07-0; ! for bel badot (mater [t]=-6) | ‘pes (i); ' ' ' ' ily =O(v) 5 Tw Convp (exity -O(84V) for aL. 2 0(v) for Arwodrin § seg hf mata be ‘ ehg

grew Hill IT fon martina tn fark. J Sete Cson cane, (1 elemento were present” m weuryston , to a rected graph oe WE Constr a DPs of an und tod 3 EO racks P,O.ard oe disco ae tine A(u) represeb bt time tnatank toler the verter 'u) in fou ustted, and : foo time f(a) represenb He flew aitance ther the vate in lost idted Girer that f(P) > 12 wnito FCO) = 10 unisa f(R)- ee © Dirt Address Jabber NOTE: The main areroion of Qata strcectexo io tr (Key Pango] z be dueted inte OS Coo 1 Away of Stace 100 Seppo se ib eth troved at wer 10. And we hove to garth theb 4 leter, we can directly ge & th index and aces { Stree hes renudom aceessibdlity over dota. * ardy Gime =0(8), ve plore elewuento acco wdling & & ee Tn nethod w cavefeal ©) You ae all gs Beak pad soll ee a Man mocked in voxy lus Weatedions > ee oirg fo um ey key values in ove Theafore, Were hav to be ew ain ely Pep) A ne. of keys used ond che. of ON9001, saree. , (0000G} by afin tte hye ae Be lay, uot to store 10 volun. ; she Gud. array eleorento an clou b each ‘ : Sippox ft tu ly ee Ba E05 and 0. cf elnunts © ke Pored aw alo in (00s , then defining owe slob fos ech Clemnt wo wofeel in ach o . Hf the key sta io very large ond thy fobal ro. f keys to be unnected thy dw array in ve Soll , Cheer Rowing sech an architedww iy vote of space: So, then te a gee f& wo Tr | ®@ Trtrodurtion to Hashing - fo ee ea lashing b mappt a &h qastodla from 0 loveyer ef : mallee 2. wr hasht feuctions hile, fon Suppoe, 0 me Potertial candidates 4 be plaad in DS in vexy laxge but rob all elmurt will be preseré in ouw Ds, eal well be present. Suppose , voluse of boys soo = 0-999 , but (© elenrenty tan bk plant wm our DS ata time. ' : Tuufore, dudoring G PS chic w of 1000 pots w a ' space . Inakead we dudaw a spas of 10 elem we could ky & map. mophing furckion to called hash function. eau sux thi our dole nok goirg © 90 beyond, Q oe { { { 5 { Univeual && hack f ( ' eet en Cae 16 thet ay fone. © whow to pot He Aoka in cond. dine, And apply earl , we we the ferne. to senry. and go tw thal eloovent Airedtly fy care the element a | preenk. If ik ir rol preseat » we soy Ha nel Present. re, Starch teow 20(t) 4 121, (145,132,999 ~& he insected. Alea ae) ea oe ee a Os se Pk eS The elena should bo serted am serch a way Bak iver. on thoold Rake place in constant fine and carding abo iv conal. time. Ge, We wea func. which will fale any of Gs bays and gee W0 some wrdices a ofp: oO “Hash function to h(o- 444) Map, (0-4 Geuxalicng , ~ 60) @- a0) rab: fesse. Ma-hiod 10 oy Jn] Jos | [iv N [a] inouched - Mo 2s 674 i ob ce oie vey loxqe nos. and, the mabe, small nos. Th et stall nod. | ijl te the 1 f ow data drudure. ev farbld we ux (hash kale) . ctu ankoge ¥ wt of nes to small t ! wap { : eg ed ete ne @ clenrnl nag bib map | Re ie cel - Thin U called collision. | fos en. Idf te be Lnoected . |! { | —) fexe- AUN BI vod © =I But of 1, Ol aheady present. Therefore | coll story occu Solution to thx _prchlun + (ells Rercludicn ecniqua’) | Ci) Bebhex robions , with tha we con decrease Gu | nO- collicconn but collision Ertl mer be O- | G) cosning , in thn we Maintain 0 Linked Cat otated) by the hash Kable ekmenrto and whenever we went pree « an ebunrent «we place in Gnked tod SCHOO tatlar clare can nov road be mopped & Ho seme ale) cell. @) 9 odd ‘i » nh, ko pr~ Reiss 4 it ba is al a eis, op empty shoe Gu) dibs can te levees We conkiner oe until ue gt om empty a hie had

You might also like