DSA Assignment

You might also like

Download as pdf
Download as pdf
You are on page 1of 22
A ssidmerp§ ly difbren\ So a ih) a Bort4hy, jo Me Smajl dake sets. > me S ng isk o tr \ ing — | 2 Soxting 1 o,_Prres oat ecmangins element of. oh la lAescon dfn © i pe ht = Sines hexe ave Various +yfes ok Sorting methnds avapp sotHth9 hethod are basically divided into two Gob catego ries i an Sor! The Soxtihg me thad eer Rot Feqvived ‘external memoxy for Sexting the element JS “Known as Snitepnal sox”. Dh fs usefvl when We have to/soxh fever mount atclan bubble: cord ‘ Diavick Sop 2! 2)_Sdeciion Sort \u) Sn seyHon sort 2) 2% yeynal Sort: The sorting method Hert Yowired Cxletnal_memoxy for sorting the Clemens 15 knowh a5 ex feypal Sort: DANS welul when we have © Sovt Wire amount of elerent ord VO 36 So te to 4 : Drrly followin Sorting” aids Qh_above dala pie Soxt _ tin enti h Sark on Sort. ! [select yl avick Sark 3), Merge sax! A D bubble sox element pass | Af USS 2 PUSS? to ho lo 9 | te 10 4 10 4 q 2o 10 | 20 wo | 20 3 30 40 4a Yo Ba, Se hoes SO bo 2, Snsox ison Sout element 4 S5 L _ ass Yo lo 4 L \o 4 to | 4 de 20 | 2o ge 32. - j 30 12 0 So ($0, So 2) selectron sos xh : , se\eclioh Sor de vides ee gqrmy Ing a Syke and unsorted regih Th fwss Fhe s ote os \QVI@ + ee lemrem IW He wssated Jyh WY dnd S ways Ts WoWeh. = phe ERS Clement oF Khe UnSoysed Wegidh . WS Braces ts eyeres vont] the ensive AMY: TS Gove Pass \ =" | Basser | OC mek ess \_ | Swa pred he sway 4) Avick theese a ~ornk gwd “Po Sibion Hy, ary inn two Svbarmivs. sh very Lays tres Fre syme ypyotess to Sub qwerr. —_. ee pa ss ( Facer / Volo] 4 Jaap Tat Gel els 2) 5] py xr R iS fass3, lad tol ee 20] 30) | ‘ pene. . og) Merge Sore 7 hexye Sork doyrdles Fhe avxay jn two? valv@S 1 Yecusivly Soxts peach half and Hen we 7 the Soyked Values nevide he ay . a yet tn to bwe valves: lett Ke, 10, 4 Arouer® Petey RE Cvrvisvel4Y aPP ly merge § a7 04 leHOR Ds, > G, ©; YoCsostd) Saas Left es ghee eos A fon Y ROs Fe, 50Esosded Ch hv mbe) ba No hed wing Aadix sort 4, WjoS, Hout > G Tol, 996 IS, 44,°)8, aoy See i c = Flarranae hé number jn asSending ardey 7 Using Radix Sart ; a : ; Clinend _paSSl. Sorting the list actordinrae oa04 00. offi a rE, Lloé lial ool 4094 doy V6 b> oot ool ooV5u* the - qiol 20 |l \boé Shy igi 0440 o¢alo g19 06 fee ols oot ES 004d © oda | 9094 2 colo 3 ool of eott i i oto4 04 oft | qed Diob 0 4falo : elo! 0 Ol) J lot aiff 000% 0 oot /5 st 0004 : ufos ood od ale Pace oof ooh pP 4 94 o440 AID) ony por. f 4044 04d 6094 PaSS 3 sayt the digzt hwndyved digit Lojol ar ‘ oot itlec Milo 6 Q00F HAC olol oe 2210! odo oldo4 oOo7s ofted 1044 rapt ren os ol) $ ~OToT | olaao TTo¢ aloe 4 0907 ObId 0440 Lass % Serf She Argites sutand digit. q £ aol t Lolo o oboly 007 i colo 1 6 ontle ufootre Slo 15 on ols Ao!94. «3 oltatg “02849 | ete Og 04049 | | aft ol diby 0740 Uo 6 Kho Hoe —}-*}8e4 é Ge Tle! Lodo Hood 4044 Bip bee GS hat is_the output of puss 3 oF bubble Gn oe _ 7 oe element = Pass, ~acsa~ passy —] : Ss ons 4 3 ee Y 5 3 3 3 a OS 5 aaa 5, i 1 ! W 7 g sl a HS 5 3 8 W128 - £3 bl, Wy S87] bobble Sorts Bibble soe Comyuyes ddsoent element and Sway theintt they. ave tn won oO. iS Process i efeakeh unre\the end List sorbed ) fassi> 19, 4,20, 39, Wo, bo PASS \ A700 3%, Yo Sa Usorthed CnscrHoh Sori: Syrsoyhioh Sord bvilds te thal sorted aymy one element aha he V4 Cah oleme and nseybiny Th tate COYYE YoSitich I’ pre so ted yur ob aryay ~assl*. yo, a, re, $e, 40, $2 fa SSE2 9, Jo, JO, 40, ko, 56 EEE EE ———————————————————— Ossig men -3 allpetfne \enved lok. CwP)arh dyes af L\enked \ggh. ‘ 2 f z | 1 | | rexCS* 4 se wueNnce of! eleynehss “Where ayes tyfes of” Vinveed gt ayer > ltt ® cavcvlaly cenaly liniced yo) Wc yculavy doubly vikked ps) 2 : | = 1 stnaly Wnked Ich ; : 2! Dows\y | ech 3 LG? poly Vwwed lrsts- 4 - < { SSeS: 7: traly itwked \t6 beach ade hag LOW Vointers which Zorwsains address oF nex Node. Newb Bens I tee Lnode Con raty Nol) / - d-atast | 1 2 Booby leneed lish : | maa eT le Tan dow bly lined leat “each CoiWke V nexk pPntey aid pre a node have hue VIDUS 26 indey st fa er gin Gly linked IG FE] elt) Ie) = crrevlavly s7naly Mtnked Ii¢ ty each | sa Ne node has a polhbey tak Ports tp the She node qi, Hye VICh. Civo\gv doubly Iwked Ui) Grxcy\erly dovbly linked Wok te a male fom/lexed +4fe ol data ctrucdyes th Which 4 hohe cohtay painter “bo P49 Pevies g € Swell ag Wwe Keel wade Dt * 2 OY yaxfte San algorithm fx fnsexh amd delete elemens thle Praly~ Wwyiked “Tigh. »— Al Maorithm “tas « tysexifon Clemens of sthaly \tnked lok Step \ 1, - Start Gehry. Tl py R=) 7 SS wt +e pve yA c _ cp oe t# 8 cend ot FF stent) Syepy- -SoT PTR 5.~pTR SvexT SherS= spy NEw —=Nepf 2pNTN=VAL. Sreyf > SET ew i Bev ?: Set HERD NoDie > Ne KT S HERD = NEW~ Nobeé Skeprs S+oV _ Dole Han (Pao vies S Sheri: Soak, Sos a WED Noll urs} se Unter Fp Go ls Step 4 Cewn of red crop =~ SET PTR weep Sears Rewea\ Sreys and ¢ while Poe a We [shes Sam PRoyta ae (ere ve ay we i N | Sewn loot) = NEXT | Chep7-, SEX PRETR SS Vex = wh | 1 gerg- EREE PPE a eran SY amet Gd write 4h d\gorPthm fay Thseyh and deletas — yI0h OF jowbly linked list Tefen do i Ta) Plsent thm fey Prosere Foy delay Vin Ked \js! — Teer tt Stat GQevr. Th PHr=nol write overF\ow tno Fo Step jo (EW of rt] Gey 3. SEV. MEW. Vode oh Fey: s¢P pays fy 3 peas! Chev SS Sev ew. NeP6 S DATA = VAL Steve cet WE we Want 4 Prey =Nult GerT: SET NEW NODE Dy WVEAT sore —IsreyS s Sey head Prev =Wew. Move Sle? 4s SET hegel = WEW = Nove Step (o: StoV fri 927% thw Foy Dele tion | choy +A. Stepr: PE HEN 2 Wo I Wwy8 Ye Ondey Hs wy | (ne 2 ster? T Tre? 3 - Sey PTREHEND € peter: VY _AESD = HeAD NET StevS + SET REND! 5. preveswol) igvevc: Pree pry Q 2 640P Yitrile Atl petuicen Kumay and Imbed 19 | | fey | Be are Sexed Dy eenhg S$ leegkoh | Crred 1K se i irked lid o__|inked | igi6 ave pal Stewed Ih Con Hoos bec * DY nem CG Pa gire ° | | Memory 1S aNerabed oe LomsNie ry Awe Time © hSomma s Memor? Ts aftocated a+ Pon dy me cs Fas d@r thar gyay cep tlain DY hamrc memory Allecabon( O/H) gpm ie 35 Phe process ob assiging he hmemod oper! foring the execyvlon time 6 ¥ Fen Fire — ; : — [hee are oor foresioh th OM 1 t~ —i co) DQ calloc 3) ¥eal\oc co) ¥) Tree 7 ha te ; — HL _Mallec OS + The mallee ) Pnction Allocate cingie viock of Wave sed | premvry. sa doesn’) Prlale memory aberecution june Th has —grqbase Valve iwitally Ls vebowh Null Thi memory |S het sdtticiey Syntax pry = (cosh tye) malloc ( bite Ge) er: Henclude LZetio-h7\ To tht maith () £ i thy wt * | pallor ( re Spe ak cnt if [pty => hull) i i \ fin [tacate meomort ")i CY i (0; ie 4 % trintt (“sum > 74 hyee Yr); tr 1 -$um )3 Tebom™ 24 3 Ol’: Eyer the element gh gym: 3 | enter Eleme ab grany + io |e. | te bees SU bn = 3d . - vy) culloc (ys TS} th hilly jnitatre al by bes by | ey; Wf) Yelorn NO\ tt memory iS nak Su Arepep Din tas 2 ¥ ys bcage = byl) *) calle co Chambor boys) er. Binwlde 2¢thig sh? tema 0 ¢ Whe wt, Fy Subat 1: ; prim EL” Endey number /o + @ lomends 3); , Count (ted Uo hus fer = Cont® )eatlac Od, Soe al inn 30 ¢ pty s = yl) (ed 7 : {Ras EC" Pllocade eee ay _exiite)s 12 Y ifvihs LA" CHIEF Clemen [oy Gee yen 5 jH é Scant (yd \) fy HO; XQ [gum t= # Crh ai); arcs ( *Sumaxd 5 Som) | pyee cry) pes —~blhensoy Clement of ayxvwyye —~ len tor elehens ob array: ip lo \o Sum +30 Ww | Rea Woe C)? TL mewory ts nat Gott tcent tmalle ¢ \ Nl ocak the prematt py ghoc 0) tun chon. Ty Short Yk Chan4*t the memort sie cuntays fy: veallog (Ptr) new Cie) 4) lee QO: Ke memory occufiéd by maior 0 OY Calla bonetish mued be yeleased by ——L calling tree O bunetion Th will Cohtme me Mort until Program exit Cynics y . fyee (f +7) ma Define following hee texminolaaies = 2) i de. & | foot pode \Rnode havina tn degree egal too } called ® AS n_abave fisuye node A is yoot hade - stbltng hode ‘- 4 hades, hatind Sthee_eeres axe Called tltnanade = ig ve thes fatents fs eae re _6 BOO Fett nade ‘= ——_ [an he taht nade level pssinkex ab Yoot fide is cet ane ates hese Ba al tree is always ake 4 ¥eqiey +h the } | de eh. e leve) Tt ee ob its Payent Rade | iguxesle vel! num J dekned as foley [level pvmbey nodes level o , As 4 leve} “I BE | level 2 COE [levers Booch ven viel or -| De gree ot tec TK a dtyee thé Sula’ Ot sedges canes ith bo d lay © Gran cula hode led degvex -of.tha sHculay pode’, mahy dogyee: “ot that: faceselttr Sum sof oTh = + - de ‘ alo Ga ae I xX “forest ee Complete binary tree, 8 foxect is a collection pt 4wo “ox no Fe. disioind tyee consider Followtns figu ye Lforege 1S a collection wah We disjdiniaye eo oe in which a Cera fate Com plete binaxy Wee awd ‘full_b ihary 2K [full indy tyes Wes ifova tree - t) which HeVels: aye folly tiled Thissis actyee in which cexce Pt bor. Psst bie Every nedev has: the lst level which 16 tilled fyom leery fo xfoht either. 2eyo- childseh O08 pws ohivldven ah Ble 2 23. 5 hf BS hh 2 “abe a in m Lind fe = a and th grey }raver Sal- car 7 . = | pg alae | ae | ae i : al tre ardeye foo t— je bb = Righ* | [ @-B-B SS ; | sn ~ordey >~ Jett ~hoat- Right | é 1-4-0 = 15 z 33 yh 62 Zn ok fer-l- % -\o-— 5 S25 MG “WE-S3 ni creave nary search Hee ox followin LS NSA ts | Pe ler? nore > pe lete wede y pelete hode 4 O plete hede 12 48 a © g & 6 —@_Lele fe hoe 4 — — a Se fee. LY Qt q waite a algorithin for pase. =ordey ih ovde and fost order uve tsa) a Xn ode» Ser Spr Stayt Zt yoo } = woll then uzite “Dee Is empty" Else: write Kor} > Info Jer} EE goo + =) PTR Wull then all_wn ovdey (KooT= LPTR) sett write fh eoT >In Fo Serh TE Root = LPTR -& MLL del phen all zy order vA CRoot = RPTR) Sref, yo P PRE- ORDER ii Stop\| Stax) Stepo| =F Roo T =fWwlr +en ubite “Tree is emf}7" £1) Se Sef? wrixe Roo + ~INEO Jef} S3er4 Sef 5 TL Root =UPTR* MyLL Hen “all PRE ~-ORDER C-Rort -L PTR) L Root = KPTR * Nui} Hey all PRE -oRDER C Reo} -)YTR) Sif PAGE N ' Loate: 1 4 ie \—— | Pas “ORDER nae tase a] ~ ser! Shar) ~Tiseos| Tk Reo} eNuLL then a Q aw . : ctor re Roo k= LPT Re WoL then: all" PosS+ oRDER: (Rood =LPTR) ! __Sierh [gf Roat= RtM Ratha os fost oT =RPTR Sep Waite. RooT' =p No voli Se oeaaie sfep-g. Sto Pi’ i> a {ayn hod 5 6)! Wafit@ capp)icaton of tyec le: = age : 3 QL fs s used ctw the manipulation oF a¥ithmetic leexpTegsians 10! oe GoTe can pe also sedi fn’ +he conshavetioh ahd samt h tay of Symbol table @_tyee/is widely used tn compl)ey fox synta¥ Landlysis @ Tree is alSo vSed 4 Implement: hush Jable Inte idence. @ Tree 15 ysed ww apt Peat (Qr

You might also like