0% found this document useful (0 votes)
51 views28 pages

DSA

Practicals of DSA

Uploaded by

kartikjadhav7107
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
0% found this document useful (0 votes)
51 views28 pages

DSA

Practicals of DSA

Uploaded by

kartikjadhav7107
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
You are on page 1/ 28
Titles Binasy, Seauch_tsee fn [fiir :Tenplement binay semcn tee as _4_pesForm_tollowing — os doka_sixuchuse a> _Agglicalian_oi__OST: ins i ecfic valve con gecussiie ob Tae Cometyscadaudion see cal necursive See oe te Beoetny cof vale 2 Rho tvee is NULL, Yhe Najue__we _ose_¢ seasching “does Mat esis) ent in tree. othexwise, (€ yolue equal Ave sso testa secgeestis ————_ ete ¢ nail eutnkee Sn eat then oe xnost nat he _pyesent in Asee ~ 9} | nsation + T+ beg seasch_waild again if xoat is ‘ot equal to the yolue,uie seaxcl the le€t ov obtsee__0.5_beloxe: Eventually, use ill seach _an : - - i Bi eft | pi ai Detetions= ‘These axe 9 cases fo consider — aber e Deleting a leaf Deleting a_ eaty is seal e0sy.05 we ce jt Exam Ts ee. ___— Simply —_semovle Zann Qeleting a node with one adi Remove the node & Replace with it’s —chid-—__—— sieseniea {=| Deletiing —o eae - cal the node to be deleteal N= Qo wot _dadete Ns Tustead. choose _eithes its inoxdes gurcessop nade Algositnn:s | step 2 + Nade__ddto ts Less that Raat daa Root lett deco is NULL: etd : i *. foot to left: lniee B 2 Bice 5E node data _is_geeates than equal -soatdali Pa Rot Right nt__tuee Jig Woee hen _insest_Nade to Right pe oe oe (Poon. \ oS Searcy Wades z =u Skep \* Repect steps 2.2.4 until aemonics not find £2 i Root | =wuLt . Step 1% TE Mnemonic equ o then pint 4 Wie! aha Shep Bt Else? Mnemonic pied te — Then move Roat to Bi re = Shep H+ Else Move ook toS left ge SNeo 5: Stop asi Delete Node i= Step \* Seascl Mnemonics ino. hiinasy teec. ake step 2% Th Qoot==WULL Then tsee is —NUEL +—— W gz Teme? te; —______— ee ee errr Skep B~ Else Tk tee > leh == Nur 22 Tree Right zSNULL == 4 = NULL) Tay LE Root == Tee then Root = NPs ——— po ye Tee 1s _a_sight _chitd_Pse aight tenet += NULLY ee TS ee 32 vi. ight = MULL. = ter ight fa +) Suck 4 u / b= ry > TK Atel = = Temp 5 Then Teng Sats aaah a Sted S$ Else | Th Yee 3 ight |= wut Nnen_a} TE Root == Tee Root =Root > Righty by TE Noo ee ge ee Elae PTsee > eft =Teee > lefts Step &: Else Lt Vee > (cbt) = putt the zeTxe = Ro left © Axee is! a si i ce > Right =Thee > left; Else Ptxee > lett =Txee > tof ty Gite 72 Stop Poel Depth: EEE al Tey civil siacu ic ek eos Repect steps 2.4456 ontil stack —is_Emd ly ——§ ay [Step 2 rim Rook Oda ai ea ea x stock [opt] = Tse? Rights op. ——T Step ui Root = Root > lett ee s\n ae ee NULL ——T“gkee 62 Root = Stack (-- Tod); | a —— a | So oe aan Steps 45,68 2 7 until Queue beagly “lee = Ayeue [isons 44]; SkeQ S* int Root ato, = cee NULL e144 Reay) = thee > lebes Skee 1 TARost => Rigint \= WoL = 4 Msias Tage t= | Skee ls Aveve [e) = Roots step 2% (1,4 until Oveve Empiy- Skep3 Root = ret? Tae Shep Ue Templ = Root? leEt _ St Qoot > \elt = Temel Step 6» Root Ri SBR Step 7+ Tk Rock > lett | =NuLe “Hnen Aueve Rew +41 = Toe > lett S $4 ight | =NULL & 2 et @ 5 Then _aveve [Rent +4] > Root Right Step 4% StoP ae ; ——| gE Reat=2NyLL thon Empty Tere a eto ——T a at Repeat pet tae. at Aueve is Emo * ~ Aue [Ssont +415 ster paint Ret (Gabe 15 +) Vet | = yt —~Fgkep bs Tabet (mone (om J Thon _Aveve [r+ Reavl 2 Root > Lige ik Root ~> Right 2 = > ULL G Root Si orited oat ti 72 Sto ~ Studied Ae binary, Axe, Binexy seasch teee @ ON [aa gesboxrn ec nile non “Rise ae get apr 2) Undesstond different tupe of travessals type of _teavessal 7 Theasy?= ) Definition of on expression “kee uh digcana. — ‘he _tevwinal node fi on expression yee axe the \aiables_ a (i aa iin_see than vou ltiglication- J — a = = Gd 2) shaw _dtfesent ype ot _+savessal : ply tomary tece im _peeasdes ae = Nisit Yhe__soot a — + vigtt left Subtee + 4yonesse the sight Subbtyee. | aegis ee oe | Se — [a T Ta lated eel thy To tronesse a _o- ern « Tranerse Ane tel + Not the soot fod binasy tee tnosded * eublece + ‘Twovosse —_xight Suisse: To *rxonesse a _on-eXn} + Tonesse ‘the binary hee _w_gostondess: lett “subtsee. : 1 + \Yigit the oat: ot subtyee. ———|__ greg ht Tot ‘| step 5 > \e $= stack! = sai Trop?) = Nodes. ae _| ot ; et » Rook = Strack (2 eg Node. pointes _vasichieok ty pe_Stauctuse—__— | shack aon? psinter— Pd Ree det ove gigi = Oo $$ g_walite Sting OL =nubt ok _type —steuctose uihichy_cottioit_pos' jane © of type eges of _oteuctuse Step \t if Tee =wuLe 2+ Tmosder R (teee ~) 1+) Step 3% Pxint ‘Tree > Ooba a ee o- testes Teavessa)__Recussive Step |: TF tee l = Null Stee 2* Postoydcs & Cree lot: B*. Po’ (Tsee -) Right) ' Step 42 Pyint tree — Data : es txavexsal Recossive ——"; Presi —__| step t= > TE Axees =Nutl Skee 2: Pant = . Rostasdes Txauessal Non secuxsiVe ___ . ec i Srep 1: Oo step 3145612 ¢ while Templ=\uilé Stack is ino _emely_ ee steps “S46 while Temp) =wurt sink Jeno aa Shep Skee b= “ent Tem th 7 Se heads Teme 2 ua Rveosdes _tuavessal Nonvecussive ope Skee 2. Oo tee 3.45.6,72% while Teme) =Null & stack is — “9 Step At Do stee uses hie templ=Wubl dé ule Temp |= NOLL Sep 4 Pent Teme ~) Oabo; Step S: Stack (44 ToP| = Temp: shop 6: Teap> Temps lel Step : Teme= Stack Crop -<15 Step 4: Temp> Temp > Right; cU6Si ie Tai = Teeey Ske 0 RE 346.1, while Teme|= Nutt £ stack 6 ep 2: Do steps f | ~ THheTeweaded inary “Sse 2 Traversal, Bin ened. tneaded_tnoy tee Case n 7 An-cides_£ pre-ardes. _ f_Aimeadedtinaay “ce, = “2 undesgaad diffewem_type of Ssavessale-— : - Theasy s- Explain an ‘noades _“Trrscaded dinars tee. 4 teee in_uilich eves yy __ Sn ee ETT a Tain cerwsie Oy dang ea Ahienng soe eid theca node that does “nd 0. sight child a 1 eS use of Gtack < £ Ame The node struchse fox a theaded binary tree yasits a bit _2 5 like aho- F_ Stuet_wodeh 4 eft child) a7 poe ee ote wlio Clog, — Asuct NDEF - uct NODE + Veoh = - Linasy AL _ansee is _ j—P : © © — 44 eaded binary Wee is delined as Lollows- Avinay Iwe 19 —_Hnwaded by mettin all ight chitd_ pons the __woold normally be Lunia Ae imoxcer_successat_of node, all eft chil pointes thab auld _ypovenally Loe atl pt to-fhe tnandes pred esses of node. if sean secursive —imoides_tequersal_Fer_aihieaded Ginary, tyce- aia is nan -ecussve_rnelhod sn fos_tuaversalit haste. be — pf an tee sored amcor elt ae steps fos “he tyovessed. wT ak a pode Nave 40 be onder a loop so that same_can_he—— applied to all the inales_in sce. td us _congides the inasdes_travessal next gub-xea_ts_ndl__ these, we check Fos__thseaded_link 2 vnake Se Aseaded nade the —_cuscertt nade. 1m_considexction- Se oa, a epee entree Peer eee yy Pxeasdes s i eee Nisit the soak - 7 = eavesse_the_left cubtvee ae ‘tgouase the sight sobfsee ————— | Rganesse the _lelt___subbtsee _ [wisi Ane oot __ | gastos se wight! suldvee PP ie eee Txowesse the _ \ett_subtiee Teavesse_the sight _suratvee [igi the woot ___ ae et ae — See vw / — / mare | Egat /—|Seoumn Steels Fox all_cosert nade neck inet Vk nag. hE dni ld whith ote fit hag tnen_ge 40. pep — is_not_—Ahere_yx_sisited. i __ Ane listo} _yistted Step 1+ ut ‘1 -* yoo _esssent_nod2, ww _consides ction 307 as fr __ tices of wh 3 — <> wi fll S L po wm- i tn 7 Explain Piinn’s _& Roskal’s Algonithrg s________—_~ ™ computes Sckence , ovin's alexi is a aseeds algasith te @nat_nds_a_rinimord seaiting —4see fox a contested —_ ‘one ivack ae a ok edges Mrat toh a kee nab includes evesy verte where ine total _vieight of _a\l__edges—n_tseo.—i5 — Y Node ¢ Edge liets- eo Deep ae A, _edgeo of a.c() OM WO) Node_C_edgss to i = al of) at) W Min, Beppe: -aQ) [ao CAE 4 Ad (5) = then entes col) c 02) : win Heap * ee [ang)_cole @ of b* tyen_add eol) Win Heaps 204) Tao (3) co(r) Dats coz) | no (a) Duap_O2- BOO) 6—£ ) s=_cemely) Dsop_B2- _fiad the ohoyteat _pdn_ucing Dijkstra alg oritam __ Definition of _Oijtstso's _shovtest path jo__find the shostest path_t fom tha henge a oath is __calavloted as A Nr a_shottest_it- ———s x toy P_|L_ witty \owes__w = Ls eee Gaal ah “ph kena eee wnordeg o_—_incyeasing distance Feom %. thak isi (Nooses the Gist yin ey ores this value ¢ a | ane next _asminium valua From “new edge it select. [ yA _stagt out _d one us vertex & branches out oy selecting ae Eigse hat \ead 40 now Nestices: oe o | Th ‘6 cienilas _4o_minimnam _ Spanning tee _alg. oxen in in that 5 Lgresdy—_alings. haosng—the he edge “in_nops of | “at optimal “So. _ . . | als ar ri + i Ex Th is easiest to drink of _geogzaphical. distanve, wits vectices being placed, such_ag cite Rodvilie — ‘o stat see tei otange ville ———— S QWevilte Geen vite? > Ka —_ eocple ville Step \* We Redville os nox comet node -we ge so ‘glue vot 0, Since {t doesn't cast —an ping sg Th fyam_00% ghavting ot Redyille aye No, ley] a Ste 4% The onvisited 4 it diacent 40 blveyi \le, ous_cu» SAG axe purple ville < Gseen yille + $0 we want to_ = ifthe value ot eithes of {hee Gites ts teas tah eo Value of Alveville_glus_velue of connecting edge. ——O. va purcle ville Stee WS these is only one unvisited mede_adiacent 4 Wile, {€ we check the values oxatige. ville plus-the 5 * 5 a F faa sod IS 2 \IO}G Se OO MM QS eusple ville gin + 91: Reped Stept Fools | toN OC) scost TET Shep r+ Repeat Sten @4 Foxtel to Gkepa% Repeck Stee 4 Fox j=l toN “kop 4® xh i >olt of) then Off] =0fd +0016) step 6° StoQ — ¥ at 7 a) | _ & Es) + IWWle = pragementatian of teap Sorte __+ || Bitns= Tmelement Heap _soxt. boy conghwuctin g qa _ax_min bere oe 2) ‘ kon of heap Gext- Th = ig heap sort? EAMES) ieon bo wnt cee fe etal is select \ e. mat clowes in _ Practice on mes _4l ae quick. oxt Ni ¢ Tussst case o(nlogh ) untime: Heapsaxt _is_an imealie algosithm. Tne binary heap dalo__stnu chuee_15_ain_qecay_abjech Bok carn _be view. inary tee wah _n vodes_¢ depth _k compide EE its node coxxespand to the —nede_ao From _{_to_n_in_fuil_binary tee of epi w+ Thae axe tula Hinds of heap binagy. fae Max -heap2- In this heap, pcopesly_is_that Fox every nodef othes thon the yoot, A[eaacws (12 ALI the - Lost element in a _Marx-heap i's sovted at __- eee > % Tchagi= The an heap pny & fhe Tn avery nade — adver than thewot A CPanews(0) 4aft] ——— Ae _Sroallest element yn_a_enin-heap is _sonk Heap dato. Steucluxe see oe ar A fee Max heap. Min_heap Heap sost _puirnasily. . eftecien + _genesal_pcipose_neaily "n_glare_compasieot = — é ; s S et 5 noth at cae [ | a Tee oon L- “2 dat 18 stable _— Heapaast is wot stable Sorts Mesge sacl is _S™ re . mmeshe gaxt pataltnes wll con achieve <1098 12 es Dinu

You might also like