0% found this document useful (0 votes)
9 views

UNIT-4 data structute

The document discusses various types of tree data structures, including binary trees, complete binary trees, and threaded trees, along with their properties and traversal methods. It also covers tree search algorithms and the importance of tree structures in data organization and retrieval. Additionally, it highlights the performance implications of using different tree structures in memory management and database applications.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
9 views

UNIT-4 data structute

The document discusses various types of tree data structures, including binary trees, complete binary trees, and threaded trees, along with their properties and traversal methods. It also covers tree search algorithms and the importance of tree structures in data organization and retrieval. Additionally, it highlights the performance implications of using different tree structures in memory management and database applications.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 42
2. epttr, a ie My eet gy. a anon afk) © E012; ‘ogee f= ty, rove 1g, ele A LKD RII a, death: p TREES eee ward 2S de % A non- Linea dara dtiucture , x8 is moanty lued to-rebraent Gata @nvalving g O hieroxchicot Aulosfenship beteveen elements. => bh preest— 1s uated au finite Set of eloments (ie, nodes) Susn—thar 1a) gl gia | Ordered pair of die tg T, Gnd an udhe re, 10} . hy Teme fe ernpty .(huu-hee ov empty Free) 08 peadt | GT Comatns a nede,R catted tre Yoot node of tT and Femaining ned Of T form GH ¥ Ont Sina else T= Aeft Subtree OI LM ard y= Rigs ue ee of REE x4 a 7 fs fr equerury re " Mg 4h ad tor et: - Ar beet node ee ee ine x A a rat CF ap inf pile me binary aves «3 has 4 an Sorel a 8 é ‘ oa: (ania) Nocke ' ‘ai Nt Binaaw tree T has ebther 04. ca CUM OY. Jresfireauch Aelant hs es Es (ab eas bhe ¢ Atiy > Complete binany trees 2n)) The Hee ‘TI's Said to be (em pute ip au fy +) ny Levels, except possibly Ane Lost have maximum = Nov of posible noeles and Hat the tools WU jhe ot Rost Quvet a@ppemr ardor tet as peisibte of dor ex:- ) i : a oe > Guyended 81 sree 1 ~ (Q-trees) — wir ua, votuw'has other 0" or'2' la ¥ $0, Noda toith o chiidien Ort Calle eden . #% Nocus WHin 2 Chi Deol, 9 eaenod } ees cated fntenar 0 > eternal la external nagy = irate sae) n ESO | Se O Atk representation of T, w Sequentat sepsesembadion - Abe sprinted! i. we i ¥ Fy Kink serach os We Use 9- eae et any I } fr | wb Info ty Contains data at node | Uy LENCK) 3 tontaing Aotation of a chsed, on, i (lid RIGHT Dk) 5 contains Aocasioyy of Ri get chind. # and 1 A pPinter Vax VON CUbLe ek Ror tdi Sequer ial Representation: — Ab * UEK Only a single Link ee TREE Q ‘ 2 3 3 @ © ; ‘Oo do c C = 4 = 8 a satin fo Binary tree 2 @ Fnovcler nd | i) Preorder : Wy Fostoraea Traverse Aept Attbhee of R fo Mortar, roar} ee Root 8 Traverse Ry! fprssel etree Suetvee of R tp thovda, * Root Preorcles tape | Right hep ag Right Root & Preoredes Sau eR bOvedrer : e ABDEFCOHIL = AS fotos nee BG LI kM OA ’ be) ¥ 4 Tnordes:— Dea rea ce Lap , et) y i Guar ous: pe ctorcter ~DEEBG LI | ~ Ca jmorden ; ACA % ‘7 BBFEAG Sela Hk i JVROE Hat tree 9 Wunt-I : Tees @ Arn Ked Afcts © Proms f Staves @ YWeV: Seorcnin: sorting” birdy Search trees, \ Sorin & Dolettoy ty Ost p-Twens, B'frena A > Threaded 8 DOM -hee :~ ¥ Hos} of Ihe nies Pn ttu pelner fietd Lepr ¢ Rian lS iomtecen Wott element. aed ¥ This Space may be more eo by veptacing. Ane nore eddies by dome otis ybeofinpssmost On, y shecificoty, Replaced bY Apecdat_ belwters.tyttth pent +o nocty tiger iyo tree. ¥e Thee skeclat peines aie atted threads and pore sy AKL cated | bis out cLyees tty Such . us wees, x» Wadicased = ~~ Usted nd , field 2 Pn Compudey MUMbry, a Extra Ors | bi Bas be wed fo distinguish Hhveacls from oxdin okays 08, by posive fnseg- lohey exdinany: beirers demotet ee Jrages. or i * There ake mary toa to-+tpread 4 me ree , dy Spee Wit Corvespond To a POH Cag rH 7 Avovextat of Gvee In), = # Thattam be Geer oy oo) Hyveo ding - | / + If Not Stated, Cur threading WIM Comespord J, the Trorden trawersal of 7, A. oN / A ! Gon AR Joe KR yy x) Jee L Srciny tating oy fh o” | o O 4 to aoe js 5 bande! mys IK Bes o Ro ah ae ae = Nex Gcternal nedy ANee Nett | 8, = Tndevnal reds x Hexe, Mngesnas nodes Nee re Geena neti, es aU ones | < Running time of aeienG —aipenhs OM Sength d of Postns in tree . 20, External porn Length = be, be tie tira of fe rhs Aunoned OvUr each ply Hert R ety fo oH Insert OF Lebe “| > thon singer of ae * The Keys ty a binday earth wee Ake alive sore tw Buth o y ast} Soltsty te binary, Search bree py 4 : % het "be node Tha oy 6eanch-tree FpAgisa 3 X Pode ait Subtive ofc" then ee Voulure of | g < Hp Vole se [Re Raya] ath fF Sinn ats futtnee of yy TREE-SEARSH (1, 19 4, if T=ENIL ov Ba teal o hen hedonic 2 IP K< Key tx] 5 Oa norwnp yy = i Me 1, 13, a a Sy aN ae ee aa | 4. Shen gern Tree-seant (Let tod, K2 5. Ube Setar TRee- seARCH (signe t20 9) ITERATIVE - TREE- SEA RCH (x, KD SUSBANINE SSS See SOV wgs, 4, Wohide LE NIL ond KE Key eX) & dole “Rey lea 3 shen TA ke OY 4. ee %<- pie Ca S. Aduiyn X. TRess Werner) dove JSS 9, x a— feot [T) = 5. While XENL AN doy Embloaiys — ‘ iG OCH) tht ena tree of is fh fo Msettten Rg a both . feven _ “nner . ow f J nie yor | fais Nelo <1 Bas Ws eh dere = EAS | Rene MY os 13 2) [hoka Tem ety wep. PRs dee eee cack = 4 fe {ae \sA)5 a tft 1239 nt ALIS] iy uaa, ease) auetion fn Bots — White dalesing 0 qi Hock % We wt COnideh three Casesihtt < has ne idedeen tty fez has noditdrens- Modify ts poets ple? G Fo veplace. % Usb NIL Os Ss ehitd ex Node D 0 wv a) TP Node hos a Hirghe 0 childs - Wt Aplice Gu Z by rae ey & new tink bin 36 ated Qa Ms Powemt . eo: Node @ UH) PE mods hos od chi eum: = We Sptice et £5 Successor te US ch has ‘no hing and plate Zs heey and Stuctlise data lofty ys Kory £ Soedlive dader . H Oy Ss) > TREE-hetere (1.2) A. Tp tot fel= Nib ov suphs tele NIL 2 then Vos _ che a Z-reee- Guccessorl2) Fh depb eyo oe are qhen x dual yo ae 4 2 RGN LY) «TP MANIC. ” Heh ee i 8. then btad phy), 4. Ft plydenn 0, Men foot fj no-e! Cunrevlf Stored in node X- () nt) Keys agnarrged Fraacemcting Onder, 1st) Reg fx) < Rey 2 $< emo & faye (©) Aeop fal, a beetean vradue ror is sprue. i 4 folteahord eo"! sone agen va ned x) Ue Ts WD Each t GY Am Leanes have hom oan? | tulgus . {Wy Thee axe Lever and upper beends On the yp, Keuga nede Can comdaim , These heeds Ca he expretced fo terms eh a dived Prepare ' Shy Vent ks ted min ho this, so hey £22" calles DULY My, some y) Every Moke ober than Ast must have Biase as ay Ke Ke, EVE Trtemal node Other Han wy “hus has cd Least Ee CLAM. hE tree Fs net emphy tne Lo0+ atocke e hovectteast J eu ‘ Awiy Evy node Loy Contain cumbst (24-1) jeu therehor, an Trzemat node ton how. Ames 2t cthitdyem, aM PR a Aecde) LM wo) Mv ya Quy: gi 2 SS FEV KE 4 EMAL oh x ip ih } Ze, hler, b= 5 I : Cotade Be Tree MM) Fa) Sas kuye oe Ate Y chit, ae : \ Quen! to, 20 So, 60, 19 © EEE 80,100, 70, 130,90, 10) YO, 25, 38,160, 7 © Ter nae ELENSE(sJ-] mana(S1) 24 Joes | & yay ae bk So GF LSE ie Xehmtt &) nik, “Se @ @ G G @ Ne S ‘a ge at A pier € i: ia rig (Hist) qf 0, (cl ul @ 5 : re f RS Vw | (® 8 ne Al A pawl i] Wy tye 24 =2 bays {= 3 ditdeew Fett een t . Kaest Yn. TV ehesnap or ether thon Wi dle delete 4 4 ee ee Predewuer ctntey Di “a ae Ne fh Ruler a , e ( CF te elomunh ; . A ‘ng fn. eo Pn 3 MHtrnal nade | fa] Per [Pek] PEIK] iN] Om (P] Hn tote teal i de i J WOW aid Adley Merge Hs duo Teac x x £ ~> Simypty dotule E I> predecener oo ek | ae > Frets detete ) leg g BS duccensee nplai, reset 2 ia) \ w chy . | @& ©) Set wees 4 » Alemmen vanians Of BoTee ‘kneton Os Oltree Stove all tl) the souaiitte Pnformanion inne Leaves.and Stores Orig Kee ® chit SmueTS Tin the fnlereat nodes 4 Pt fotior of the fmsernal nodes. fp sind te mmoainising 8 bronchi x Hatn difference fs-nat Pode of a Bi Tree cot many thidren Nodes , # SINCE ,WUA Fear fs to marion ye Asem accoaes, BE) RES nodes dioks sn ond arewwed ly ot. Placehoiders to qa Hue Seasth , J} The tam veces of © Oh Trees Ane fined 10) ether to form a Gnic-tict This §s done, So Hak fre xecovds tan be AetAieved seqpentialty totherd axcestng Mae Bi twee [nclex + 3 Ts lO Sup ports feast precess’ins : |g StvcePeq batanced tree belauke ery bath drm tar 90d node +o a Leaf node ts of the’ Same Luaghh- Abotanced tree Mearu 04 Ath Seon sno. of nodes He ep oval Snail dual values veapire shan Sarat te € tobe ¥ead yom ~Hhe daek ae r pice Fas a ‘ Bivvee Geechee > . OH frosuchw ef poctes Linked pointes eckat node colted Hh fect ond dh Fs cnehoved by a sh fo each Leap ard alt pots aXe bounded by Leavy Gh) has @ un » of oa. t . PWN) Stores Keys Values a leaves ond stoves Scher emey y Value in intemal nootes . W) Fildes Kuyseareh Viartne &eherenee vatiios SOM ne Foot to thy Leaves. ® * 2 BL tee of ordey mM ConaFers a} Hoo puts: = ty Pndex sere Provides Indexed Agy i fost acceys of date . tonatote of Mites nal Hodes thar Stoves on: Uy fey and boubtvee heinters, d # uty SQitente Co on Consists of enh nactes +hat Contam data i Site rs, i} | : p¥eujoler Ufdent ee ¥ £ mol accen of date | | 7 ou buyg tink th) # R hg r A Hoap fst Feused Gaued Heap fe wed » A 4 Ateee Sructure iS whieh fe of tune Fy Pest pels es “ej hetonead Binary tee) diy maxe Heap FOr Sr co we Mant OL } Max value fs Stored at the on clament wrth Last i forstng F exahoongtng tne emey ; a. * Riga trad rsiae's acfeasel MY TESOW Sot Sep Ls- Catlto duigd- heap (4 Leuliding? SHR?" Ieob exchangt ng Reet, ond fio n9 G true twop fox tS Length [pi] down te 4 ao exchange 111] exutil heobs'ge Cueheap sige DH] —1 cou to fo maxe heapsize (4, 0) Step 3'— yeaa, ab the Beira oF cat. Sadad-vea ot? Sept Pact ALi 2 aHOn SU heap Sige Tn] <= fengi by) Sepa — 43d T p> x oe Spal EL Pree g ue TREES = > 7 PUL TREES T— + (Batancgctxea) * Seasahing ina ae Stile ae hedge Antghe Aworrees of Any noe ah 2 equa. + Hewever, Frequent frSertons € Aelosfons fo 1 tree unbalanced. * The sppfciency op Seanchlig fs feat fp-tne UF Fete) a of fobtand Night Substrees oF CU the ned 8 a BST fs atthe most t: % Sed a Bs Is calted asa Balanted Bst % Fh oso En verted Fin Jeon 1962. by teso Rtusfon Munonadiclant GM. Adelsen-Velukie and a Poy + a Bothy Es M-hanolet® F Hence, Such reer are Kneeon as AVL Trees ee. (2) ) Y ) a Se Yee): Gis ©) 2 oO FI Op & 7‘: # To Pepresent fiw rece of BAve tree. pat Metals axe wy 4 fordara ai ® © Stor storing. Ada. op, LOFT 4 Rabie chitg. Gin and, on add hionat fied Te hela Balance face mp Mocks Fecatcutased by! Aubrading tiny Ofte Blot Supivee et ts een Ryding nee eSubtece , (1s F os & a 4 (ee)! a AUL-hee wine =e ey 3 es # The Value Of Batome factor of ar node fe 0,1, >). & Stag Ayt met ruck AVL SARE | 2 fmptamentect’on fi ogra T Max, Int dase Pepe Spud AVL akon 5 eres by Trt besfocts node, ty toalee © oO )2® a i sSQ (tr2de-] a 4 o @ Go) i ee AvL fee 2S AvL yee | SIncertioo fy Avi Teees ox otkton ij sats cen vey fag apt ps, Bur Prsevtion Tver contain ARrheacls ySivee thee Moy beCome UNbalanced die fo Wersease ty ts tefald, cn re a | Reles)-fy newnede fsFnsenied os achitd of nen- ‘ 2 keel teal node thenthere Wi, be New |bbeck On res Aatonce, Othe helgit-ef tree cdeesrit Increase, Fach or «| 5 | * ¢ by 4 ee ine op 6 ©O® Before aaa Hon Atex addition f © jid of fab node, 5, amis Ps Prsexted ALO oh s (aez] a se ae ol ete befome a nbasanced Peg. 0 one AES | ee a ae Subhee ox to scigut Subtree ,hyich Pn duom Changs, Ge gs * Eolante {acter of the nodes. ‘| Core a): TF New necks fs Mrserted AL c Hit of Pty x Yede ©} subjree Cleft or Hane) estoy then-trere Wilt be no ebheek, , x tamat) ish Of labt ond Roni Sinteee fs conn tuctnse efa new a cnty ¢f “iu Gea disteno tos botante of AVE dace = 5 a Case otis t Sorc oti hyn NWO mecke fe carted 4 0 chind of ink spor Kigna) then tne Avi Fo x Pehly adyinted so age my poe he tree Fa Jase oY fis g fo the node Wi der Ingestion of NWO Nodethuse anefyse Caress - (@ The neo node fe Mreevted as cc Chitd (Lojtor riehsl OF tre | Bd Reap moda ef Suutree GTR), eae (b) neno rode fe Inserted a4 a Chitd [ Lobt ov aTght) of the Raa} node of Qusivet @ ‘ deeds P they es 5 Louiny Gi ey (mec a1) Hue, Balance Jactor of note containing dada © Fe vietoly — Sore AcLatonve We Ane ALyred to mee Apt Rotasien of Beles rede tontalving the data ©. o i sate Rees a Robt Antotion Of tree Way [erehatance Tistiy we make t t ee " inka} cv (ity he Niynt onitd of the nee . Bet balance rhs Ustuxbed ') : ae @ @ e g Citentnetiee ts b atncog + Thee Be hso Woe prstu; tne ®) fetepion fn avi Teer y FSM LAA +0 Steven fy Stray tree, | aa a oe 4 Bt ae aa Y mom ILS Us ttf Ot (® y Resauting Pig Se ow fh ee Sti 2M r whl vO OOo ) mf fa 3 o a ey th on 7 ee

You might also like