Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
32 views
16 pages
DS QB Unit III Answer
Uploaded by
udbhavfest
AI-enhanced title
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
Download
Save
Save DS QB unit III answer For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
32 views
16 pages
DS QB Unit III Answer
Uploaded by
udbhavfest
AI-enhanced title
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
Carousel Previous
Carousel Next
Download
Save
Save DS QB unit III answer For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save DS QB unit III answer For Later
You are on page 1
/ 16
Search
Fullscreen
O Wh AA) A binony Ree fa type oF date. tree dala slructure en vabtch each nocle can have atmost +wo chrla nocle. Example ts binary Hee tet SZ SHO 4B) Propattu of bimany Hees : s) The mavimum number of neces Ina binany Ree of height “ht Coh-d) | where *) The max. numbu of noc ak level 4 O- a binary Ree ts att) cohere -the level of: the root fs ©. fh, Se os non-empty binany Hee the numba of edges ts alusays one len than the number of nodes, %- AD A bimany seco Kee fh a type OF binary Kee fn ohfch the data tn BBE node &% gieata than ar equal to -the dato en tk leet child and less than/os-eseat—tothe data tn dis Aight chtid. TO conshuck a binary search free , we Can Ure The fotlocoing algorithm. © stank ewith an empty Hee. Fox ecich aata fren fry sequence, Teak Il lo the Hee ox Fo\lovot IE the’ tsee Ps empty . Veale a neo node wilh the data. Stem at the Aook OF the Kee. YT the hee ff nok empty, €ompaxe -the data thm etih sthe data %n -the Avot node. *) TF The data ts lets than or egual to the vook elata, fret te fnto the left subbree recuutvely, *®) Te the data Tem fs greater than the yook dala, fnseak tt tnto the argh subhee vecunrtvely. Given Sequenk oe delat Sb, 32.11, 95,94, 85> 46) FF, 22, 5/38 14s 42,.4,66.= a s . farce Si | Tmesttng. -the elemenky Into the Kee. a) pe ee ) Truting 22 oe | . y e Ne a WH Inserting BON ce & a 38) ee > ) ae | < oe > Novo | Amseaking. the elementnn tatoscthe | acest Se *) Insulting 56 4) tepaepting./ a3. E, #8?) Taking " tw) aes 35 Ny) Insulting 24 Waee & x) 2 : os i 2) Imaking & tt) Trueating as °, 64 erate vi) ‘oe. :) oe 9 vin) Tmeakmng & ic » Qe *) sg aa x) Tmatting & Lier.xt?) True a” Ty | % get & = *% G2 @ @ xiv) Grating 9 xv) arueiking 8) Novo “the -final Ree atty frie ling 66 a ee | ri 4) Se ) 2 i gee hb 2% © S aa) The prececenos aefe to something “that comes before anothes tn a Sequence Of hferanchy, while the successor aetar to Gomething “that comes atta tts JP tars oF Humbe, “the predecestor f a Humbe, “thak Comes Framedtately before bile Cuccesmr Ahe numba ~thak Comer Srimed talely afta 3 tH A fequeng, RB) Balanced Hees ane a type of binary search Kees that maintary sthett height as small ar possible , usually legeatthmatte fy the numba of node, fr eFftcient gecach, Inseatton and deletion, Balanted search Heer achteve thir by re-balancing thernselves afta any modiFrcatton that: might eause the height HO tnnecae Sore of Mosk Balomeed Bees anes examples are? © AVL thees wg =Beed + Red black Kees + BA teesBEN ick cea splay Trees Ore ‘beth types of sel balenaly | binary Seorch Hees that can effrctn perfor anseaian deletion and searching. see have AtPearent advantage: and dtradvantage: | depending en the appktatton and data Atsh bu lton | PReci black Heer: | Propertters i | Recl-black Trees have the Accompanying props: | + Bach hub har a Veatch + The root % black | + Each leaf tran exceptional node called Null + tin the case that anode t ved, %h child ane black. * Each wocey Ron “the aoot to leat has fame number of- black nodes | Eeamplet- Importana © Recblack Hee balanw -the level of the Ponotlet Hee « Red-black Ree gel some mangin to Shuctune the tree boy_ | ~eestabltihing. th oa, dye! Of she povtalle) Kee. | + The tte ihc, “oy seonth acttutty #% Oltegn) © Tt ha stenilos ly low constamh Pna wide Scope of— £ituations . | YY Red-black fees cre dynamte In hatune Red-black Keer ane Aelattvely easy bo fmplement and undertone | Red-blacte Ree canrneduc, the me Tt takes to feanch for a specthre kem. |g They have vote vange of appltcattons Ikke al | Mmemoyy management, networle routing. ree etc.r- Splay Hee % & Self adjusting benooy Seanch Hee | dates shradwre ,cahfdh mean: thal the Hee shuckure th Adjutted | dyranicatiy based on the atcened ov Toverled elements. Tn other | words, the Hee Cutom attcally, Aeorganizes tele 50 “that Frequanty THR accemed or Micled elements becomes clas to the rook node, « the baste tdea behead splay Hees ?s to bring the mort Accenty | Accemed or insakd elements to the Aoot of the tree by. | performing a Sequenu ef Hee elalfons calud splaying. | | | Rotatfors wed © Splay Hee ones . 2g + 20q + Zig -Ztg * 209-209, * 2ig-2aq } ak Fag -2%q | | Tmportane of the splay Kee: | + Caching ¢ — Sploy Hees combe cred to Implement cache memo. management , Whee mot frequently accenred thems ane moved to the fop of -the tree For quickey acces. [+ patabase Indexing! Splay Hee can be used to Frdex dalabosel for fasky searching omd Achteva) of late | | Splay Heer Com be wed to Stove fle Syst Fe Re syphknos + | metadata such os splay Hees com be wsed to compren dole by allocatton “tabi, and fle atytbuty- | + Pato comprenion® | and encoding repeating pattans. | * | dent? fying Splay Kees Cambe wed iy, Online gomeng Fo = Online Gaming s - Stove amd rmoamage high scores, leadenboancds, and player statestres + | -AHhough they | gotattom make them useful tools may dééter havea higher overhead fry tAms of -foy sowing & wrde Aonge |Oe eee. t re, 23h pala h RStaly oy@ BA) There one AtPhrent types of binary Hees, cith dtPfrent nee anc application. + full binanykee | + Complete binary Kee | 1 perteck btnory Kee + Balaned btnoay Ree + Degenerate binary Kee + Skewed binoxy Kee. | 28) A Aredblack Kee ta type OF seit balomctng bimeny search Hee thal! | urea simply colouring scheme fo maintain balant. and guesantee O(tegn) “Hime complexity for search, Msetion and detton, | proparts of Aeci black ees? | + Every node fs either aed On black | * The rook node ts always black. | * Eveay leat node (Nut) ts black + | + Tha node fared, then both tH chilcren arc black + Evy simple path fiom a node fo a desendant kof rode contains | FAL same numba of black nodes. AVL tree & @ binony Kee fn cohich every Node satrsfees the Balancing -factoa [hi-bp[ 223+ AVL Heer one developed by | Adelson —Velsky and -Landit. AVL trees alo named as | | Selfbalaned Kees, cee | Bro | CK. 6 Bra | Be BFeo Bre ® . eee : Unbetaned » batomed = Be- [hi-Pp] + PR= height of Righk sub hee : he hetghe of ler sub bee AVL Rotattonc: - De To Make the AVL Tree blanc balance *helé, when Pnseabing On deleting a node fom-the Hee, Aotatfon: ane performed| We perform the -Bllowing Lt Relation, RR votalfon, LR Botatton , and RL xotatton, | aLePt- LePt Rotattons- Shr aotatton ft perfoarned then a evo nede fr Incested alt the left child of the left subltee. BFR, wo fEleaee Ob radest gbisoialionar perform oH" node 20 low Ree B balenneed AY single rrtght sotatton fs performed + This 4ype of Sotalton tt Fdentefted when a node har a balanced factor as +2, ond th leet-chitd hes a balonce fcton as +4. _#) Right— Rube Botatton s— Ther aotatton 3 performed when a new nocle ts Inserted] at the aeghk ehtld of the Atght subkee. ero 09 ert ere| — > oF Bro eS eos = gh Ben prse 4 | a. A f& A ABAD aA Puforrn left otal BR 2 at Nodk 10 at node 208 eae 26 A Single lePt rotatton te performed . Ther type ef dotatton és Pdentefted when a node te hora balanced fecton as —2, and Ms Stght- cheld thas a balance factor as ~4, *) Right — le@l- sotattons - This notation vs performed when a th frmakd a “the atghk child of the leFr subkeee. | pew node BEER ad | at) a | : eel on BFF | oe ee RL rotation A _ | 5 | re ; KA AAA puforrn arghtactation ak node20 ome let at node 30 | Ths dotatton te performed when a node has a balance factor as ca, and th atght-chtld hos a balanu -facoy as 41. vs rokakton ff performed wohen a new node or caak node DLefl —Right voratton: Thi % Anierted ak the leer chtld oF the Aight subbsee - GF=0 A rp dolalion 20 5 Ee BO. BE-o | Bp <2 at nodso parforrn aoleftarotation < x BORK A at node 208 Atgh- dotation at node to | Ther Aotatton % performed When a node has a balan factor asta, and th left—chtld has a balanafactoy ax - 1+4A) An ave hee ta selP-balanct es _ fing. bincay ‘Seorch hia ee , here the AtPAnence between the hughk of “the left: and xtght subtrees of ge oat mat one - ang nocle we thi — hy) <= 4 B) A Splay ki i 48) f 7 ce tf a type of binary, seanch tee thal adyials e al ynaemicatty. cbased on the elemenb Ahok ane aceesied or incertecl, TE user Aotattona to batng the mos t Decenty metened on trserted elements 0 the Sook te vt become” unbalanced. AO) -nbsrasty sehen Gain) © Oo chucteore that spr values omic. Each pode he EL) oy Nee oat id. The value of axhode fr greater thom left sublree om a Kuondhical child, and o aight cht 5 ot equal to the values of : and les than encceppette Ne Vatued of all the nodes m ats agg ht— subku- Anatton operationss To Hal a) Nate “intese: Bemiicee. need to fd “the appropatate posttton er a new node Ror the Rook And Ccompore the vatue voit The ~the value % smaller, We go to the longer 1 we ge to “Ihe atght- untill we r40ach a null ehtld, all “the nodes wh Re steak cusvienl- node - ae teft chads IP she value ®& Wwe repeal hes prow» new node and attach tt to the parent: child - where we create “the het us comtde the following brnony seorch Hee ond trebiy athe elemenr = 44 HO ths Trawling 44 Aelucles Hrure steps + i) + composing 44 OTH 1044210 CP) Move Rigt side ak « Now head node % ad compoutny © © oO wot) 4a 44> 22 Move fo-vight head = 33 1 Comparing wikhag 44733 %& 33 1 leaf nodcof head hence twet 44 to vii ia of 33.2 @® © 668 Deletton operation:- To clelele, & value —Rom a Ket oe need to-fd the node That contain the vatue amd remove tt om —the Hee. There ane three cases to consider coset ® cee ee neces hos no childnen, woe simply delle Fr oma sek- ets porrents child pofoter to NUL. Hq: = conitelen “the following. He amd dekt elemmt 44 10 és | The element 44 box null i @ GQ potora a tha cWStdnode oS Oe hi amd Pt daesn't howe S az @ O@ CB otter chld nodes cay See ae (>) “remove SE amd Update tf (6) @) Gd | posent- cotth Nutt potriex cose? t Eo The noe to be deleted thos ome cheld - Inthts case, We delete the node and Aeploc tt worth vk child» by capdating ony envy bo the child porentt po : oe, cComsider =the ~follow fq tur amd detele element” 33 ©) The element 33 & nt a kof 13 co TW hor a child: Hone swap HAS)...283) aq 44 —then dee 33. < ) & 6 inh \ Tints corm bbe obtained by on 8) @) fnorele, Fraveial The 9 © ay Peak elem. anord er ) getty he 2? stravetal ts swoppe clement to be deleted_@ i Couea--The node to be na ey oer ~wo cheldeen. In “the cose, oe feng the ‘morden Succemr of “the node, Which & the smailul value fh th Aight gubku. We copy the valus of the guctenor +o the node, omd then delete —the succenor -from the Stght Subre. The Suceaor com be esther cose 1 Or core2, so We Com apply the Same logic as Above, 4 Frenne te delete | é keh ws: a the -followtng He omd de | 4 | she element a2. Zt cantar both 4° wghk oma | ct @ OO @ tee submes. UY Aloo Finding ~the fnorde, succemor OF The | element ag, Which % 33. Now sappy 4 — ag and 33. 0 “that 22 become leat oo 63) node. alow aa tom be removed omd updating, 6 a o © ts panent- node 33 wih Nott porta, Ikke ctaten drucken teak ators YO TO O tm the tee has at most 00 chstdaen al to Aool(head ond 5A) ran bimany seanch Hee F Wtenarchtcal order. Each node The vatue of Uert sublres len than or Gu Value of Right sullres ¥s greater thorn root [head 58) To make “the -AvE-Kee balome ehele rotations one performed. ane rotation oh nV Tyee one 4) Right -Ro -Riht | votats ats performed when o new note Snseated até dWghh eld of Atght sulokyet - >) beft— Left Aokations s— ats purtormet when a new noce & anvated at the lef child OF she left sulbhree ts notatton 2) puformed when a new aeghl- ehitd of- “the ler Subbree WON) S— w Right leet rotattont— node ty wsetled atthe 4) Leet-Risht Yotations - Thi % performed When a new node 3 | anserted at the e leet child Of he aight subhee.a ee oF (sy = DUL Hee ate self- balametng. binony seanch Hea that maintarn the height Arefacna between “the lett and wight subkrees of omy nodw at motone. To delelr an element from am “AvLl Hee, We nerd to flip these. skepss » Rind dhe node to be deleted using binary search and a as In a normal binary seanch Hee- Tht may. Predecenor, | Kemove. involve Re fe har two children . | Update the height and porent_ potrkens ofeach node or tea path from “he deleled node to the soot ak any node on the replacing Whe node with wh Successor OF check tf the AVL propaty & violated poth. Te yer, kt 2 be -Gut unbalanud node, Y be the loager height aad chrld of Z, and ty. form a suitable rokatton on nestove the baloma, There ote -foux posible eases : left -leet, aight Argh , amd dtght- leet. Each cased Prvolve ld potter of the oder Mnvolvecl x be longer height cheld Ahe subtree rooted Bl 2 to teet_atght, chomging “he povient and chk &m -the Aotatton + Repeat the prevfous skp emtet the Aook- ¥s reached 61 no fmbatamce fs found . | Yecmple- tee Us comfdey The fue at follows “Then delete eltrwnt- to from the He. Bre) Bho detele Go) 20) Cai Spr Lefts | oreo BER A 2eec ay @. 9 The Fmbatamud hu T te UME Srewedd The pecfectty batemced perform ;| Novo conitder Another tree amd delete We eee neds | er) " a ») dele 3) | BEO OF or —>» | | BF=o | | a (i) 8Fee The Mmbatomad tee performeat Leet- Atght Aotatfon ane final belomted fer 8 Cfo Oy w 3A) A tree IN dole chruckute! and non-lmeod fashion + connected by ectqes - Each node or More child node. The fp mesle Mot node % called the Acct. ef) ee & wa way of orgent 29g date tna hfeneutchicof A tree consdls ofa sek of noder that ane can store some daly ond have 2es0 58) A Redblack tree % 0 type of balomud bmany Storch #4 “thal ue coloun, bo: erence balona. Tt Wow a ood Work Come sunning Fine complexity of OClogn) for openattons Wke ansenttom , deletfon . and Searching, OQ] Avk, twee B brnory, Search free & which every node satsiR ane balancing “factor athe [Se line NS trees ene developed loy Adelson Vebkiomd temdo- -Auctree alo named selfbalonud trees | Bre pel on = 0 BF=e, “® P® os er | \. GF =oBF = Bolomeing fac © (hy - hy ® height of teft self | TR the balamung fattor t gre hr) CO tue he os height of atghl- sel een, ctea them one for ony ode sbolanw —the tree by using “the forlowsing, rotation. | There one ur rotattom ov tw se te Neh aciatren | 2) Right Fo AYght aoration >) tere to Atghl-aotation 14) Right to left rotatton j | Given datas to ,ta, 3 “egnsu bing the Aut element 10 t o type of Aotattons } Sing aotatton double Aotatton 30,45, 44 Mit, 5, 40, 13, 40,56 ee a < Imateng, the element 12 by-following BST rules Lo Trmathng dhe element 30 20 BF=2, . ==. 5 Réghi Rah | BF: 7 or See | Ggere ansest a3): Right-lett (>) ce 8 BF Bret (a Tsar resat(ar) as Righh RAhk (a: 0 NA gibeacl Ga, Bro A _BF:0Bfe) canon © 9Exe Lestelere (NY gg=/7 ib oO CRP ere 0 Trvest (25D, LQ S ee : Ansut(40) ih i Ag BX su aor) eo AGS iG a es * OB © 08 oes a @® e on Ay @ e@ mt oe : Tract (2%) Qy © @ EX ie ¢ | eS <0 The —fmal ave tree %
You might also like
DSA Notes MAKAUT 3rd Sem
PDF
No ratings yet
DSA Notes MAKAUT 3rd Sem
13 pages
Data Structure Notes Part2 Csegyan
PDF
No ratings yet
Data Structure Notes Part2 Csegyan
13 pages
Cp4151-Advanced Data Structures and Algorithms: Unit 2
PDF
No ratings yet
Cp4151-Advanced Data Structures and Algorithms: Unit 2
100 pages
DS U4 Tree
PDF
No ratings yet
DS U4 Tree
81 pages
Unit 2
PDF
No ratings yet
Unit 2
100 pages
Aad m2 Notes
PDF
No ratings yet
Aad m2 Notes
39 pages
Unit 3
PDF
No ratings yet
Unit 3
39 pages
02 Balanced Trees
PDF
No ratings yet
02 Balanced Trees
34 pages
DSA-Unit-5 Handwrotten Notes
PDF
No ratings yet
DSA-Unit-5 Handwrotten Notes
22 pages
Trees and Programs
PDF
No ratings yet
Trees and Programs
21 pages
HW 3 Part 2
PDF
No ratings yet
HW 3 Part 2
13 pages
DS Unit 2
PDF
No ratings yet
DS Unit 2
23 pages
Data Structures Part 2
PDF
No ratings yet
Data Structures Part 2
13 pages
Adsa Asection Mid2
PDF
No ratings yet
Adsa Asection Mid2
18 pages
DSA Solved Paper (May - June 2023) PDF
PDF
No ratings yet
DSA Solved Paper (May - June 2023) PDF
27 pages
DS CH-6 (Final ?)
PDF
No ratings yet
DS CH-6 (Final ?)
24 pages
Unit 5 (ADS)
PDF
No ratings yet
Unit 5 (ADS)
24 pages
Elementary Algorithms
PDF
100% (1)
Elementary Algorithms
618 pages
ADA Unit 2 Notes
PDF
No ratings yet
ADA Unit 2 Notes
25 pages
Unit 3 Data Structures Notes
PDF
No ratings yet
Unit 3 Data Structures Notes
46 pages
Ds Assignment 2
PDF
No ratings yet
Ds Assignment 2
10 pages
Data Structure
PDF
No ratings yet
Data Structure
6 pages
Fds All Unit Notes
PDF
No ratings yet
Fds All Unit Notes
19 pages
DSA Unit-8
PDF
No ratings yet
DSA Unit-8
28 pages
DS Unit-II1
PDF
No ratings yet
DS Unit-II1
46 pages
Unit - 3, Data Structure
PDF
No ratings yet
Unit - 3, Data Structure
23 pages
DFS 2017 Akash
PDF
No ratings yet
DFS 2017 Akash
12 pages
12 TH 13m
PDF
No ratings yet
12 TH 13m
5 pages
Elementary Algorithms PDF
PDF
No ratings yet
Elementary Algorithms PDF
642 pages
DS Notes Unit 4.1 Tree
PDF
No ratings yet
DS Notes Unit 4.1 Tree
44 pages
Daa Unit 3
PDF
No ratings yet
Daa Unit 3
16 pages
Big O and DSA Sketch Notes
PDF
No ratings yet
Big O and DSA Sketch Notes
12 pages
Unit 5
PDF
No ratings yet
Unit 5
34 pages
LeftListHeap and BinomialHeap
PDF
No ratings yet
LeftListHeap and BinomialHeap
14 pages
Red Black Tree
PDF
No ratings yet
Red Black Tree
17 pages
Govt Based
PDF
No ratings yet
Govt Based
19 pages
Algorithms Everything
PDF
No ratings yet
Algorithms Everything
33 pages
Nikhita (CS) 1 Assig.
PDF
No ratings yet
Nikhita (CS) 1 Assig.
12 pages
Unit2 Daa
PDF
No ratings yet
Unit2 Daa
5 pages
DSA-Unit4 Handwritten Notes
PDF
No ratings yet
DSA-Unit4 Handwritten Notes
20 pages
Fds Assignment 3 4 5
PDF
No ratings yet
Fds Assignment 3 4 5
23 pages
Algorithms and Data Structures.
PDF
No ratings yet
Algorithms and Data Structures.
10 pages
DS Assignment - 4
PDF
No ratings yet
DS Assignment - 4
10 pages
Daa Notes (Final)
PDF
No ratings yet
Daa Notes (Final)
41 pages
Unit 4
PDF
No ratings yet
Unit 4
24 pages
Introduction To Binary Search and Red-Black Trees
PDF
No ratings yet
Introduction To Binary Search and Red-Black Trees
6 pages
DSA
PDF
No ratings yet
DSA
28 pages
Elementary Algorithms
PDF
100% (4)
Elementary Algorithms
630 pages
DSC NOTE Handwritten
PDF
No ratings yet
DSC NOTE Handwritten
9 pages
DS CS3301 Unit-4 Notes
PDF
No ratings yet
DS CS3301 Unit-4 Notes
52 pages
DSA Unit-4
PDF
No ratings yet
DSA Unit-4
9 pages
Notes
PDF
No ratings yet
Notes
50 pages
Daa Micro
PDF
No ratings yet
Daa Micro
25 pages
Red Blacktree
PDF
No ratings yet
Red Blacktree
16 pages
M-Way Search Trees Representation! M-Way Search!
PDF
No ratings yet
M-Way Search Trees Representation! M-Way Search!
15 pages
Binomial Heap
PDF
No ratings yet
Binomial Heap
7 pages
Dsa Short Notes
PDF
No ratings yet
Dsa Short Notes
37 pages
Balanced Binary Search Trees! - Black Trees (RBT) (Ch. 13) !: Not Counting X Itself
PDF
No ratings yet
Balanced Binary Search Trees! - Black Trees (RBT) (Ch. 13) !: Not Counting X Itself
6 pages