Daa U-1
Daa U-1
wo NOM YY C ) be. hel cn) G yen 4 Ahern ce aa | n> EC) Such -thel Jony= 0g(n)eguacti on, Ree MEW yvence Relatlon The recurvence. cauatton tg ap that Aetines a sequence: yectoral vel Ww ots Norvatiy tn following. -form Ths TON ah Nze 2) wee urence leche Tle) = Oo > inital Condihoy Soli i . Soling- Recemence Zqcteclions TT “The wecumence rclatlon can be solvect by Pollowt nq werthads 1 Substithatten =Met hod Magers Method S 1) Sabstihesen Mcthool The Substhit on rethod method in which a qvess tor the, of eluhon ne. mate. There are tO types ot cubs bchow hea kind ) Forward subshtehon it) Ba croed Forwarek) = 3 ip =a then Tops TO o4ts = St 7c3) = 6 — B Obs Aarnr abocey™ - Soe. ban deve a_tormeal_ cult to mess fhe pattem +h fs methoA 7 ne ) Backward Ea fe u>2t © tn lors ) = o(n tert) Toy) = 9 (n>) J , MiceDrvide and _Conauer> Jn divide and Conquer method, a aven Problem ig es | \) div de poblen tale smatler parls r - a | MY Trdependently golve The paris Bo bp Jy | UL) combine these -soluHons be qeh Ade perteaey Overall golurhon Prblern af size DN ub problem | of SIRE O/, | Zolutt on bor Sub problem Y aub problem | Of Sige fr Solution Sub poblem | Zolution te OW ap nas probleny Divide | Conder tech NFAUes , (ee pik smal oy coben nis ate) 1 tanetenads Tey yt fen) eit | wt me for Age OF SRE D se 2 A nay Hane neq, to Bole emalt Ips oe en to dividing ¢ Combating the sol HEN] ug, EE OS 1 cub pate, a = atéex e \fe mp ict £4 i we want Ly Bir of MN Numbers ther by Atnide G Conquer we Can solve the pwblen as (a0 an : ban) alee : val Qot - ayy, = ant --- + 4n~y z& solubon | solution 2 solution bo (Got o. + 4-1) Applications af Divide ¢ Conquer Uaatous applicahtns fhat use. the dinide, G& conquer ehratgy ee Bl nary- gearch an: Merge 7 3. Quick sect A: ahascen’s Matax Muttip licahOr ne Bind ng. Mlaniroun 4 minimum ebernent-Binant Search 4 Binary, Zearch Ig an efticient Zearching ee while eearching, the element usin 1g method the most esental thing, fs ae the elements in the array should! be Sorted one. An element which is do be Searcheol from the Aish | elements Stored 19 area aa Aile--.-*-a called Keep element - Ser Ated be che mid element Of aay A. The three conditions that needs te be tegteel cobile searching the areag, Using, thig roethod. \) Key == ply then desired element is present in the List Vi) other wise if Key < ptm then search the Left gub Us if key > ACr3 then search the iy 4 wight aublist- &,. consider a U€st of element sq ep wl] foo high - Key = 60-h Gq - of, : 6, =3 atid = Up skepo Key = almtd’) bo 2 = UO co) Key < arta) bo < uo CNo) Key > a toe) Go > Ub Yes is presenn al aight cab fist element kow = mice) steps hoo Y Lu 5 4 Sj So | 6o{ -}o- J a mide Ute = —= atmtd] = 40 Steet Key = = a emi Go == £0 clement ts present al hides th pogibon be Gan" = eth posithon ,Algowthrs t Binary Search (GigE, bey) Lowe. 0, high —v-l; while C Low «< high) do t m < (leo + high)/. 7 if (key == Alin) ) then aehun else Chey Atm) ) Shen high — rot else ove cost tnvol TU) : PalThe recurrence relation (3 Ttn)= § ee Tinp)tb if nee where a qb are Some +e conten b- tty = TOMd+b Aet de 2k tek) = t(2%b +b Sa (9 +5 Subsite fhe value of (2-1) k& T(2*) = ( (ak) tbhJ +b = TOK) + ab S foek + bj +25 = Gt) 4 3b \ + (ab-*) a «b T (2) + Kb = TcN+kb = at kb = a+ toro b Tin)= eClogy) aXu _ are tse, ET ec ects when an element ts feand ee ‘Ss foun between dhe retursive calls bak call ends ret +) ota stHhe Nothe yecursire Suceessfal Search + TEN) w lego Unsuccessha Seasch | Tn) ie! ortega | [een] (ame com ent pf BS \ \ Bestcase ee | ecg © Cl) o(teqn ) oCtegy) Ae Binary seasch ee Ddvaning of “opimal searchin 'e. [Binary geasth 1s a algosthro using. ohich we can seach + dested element VEY eghcreatly . pisedvantage SHES This algesthrn wequtres the Urst t be. oried: ne only Ahrg method fs oppucable. Applicaton at binas seanch phe Binet cence efficient Seaschin. We auses 2 geaach des tred recom method % fro acta ease ie 2. for AVN non Line augtrens Oe pe unknaeor hrs method te Ue, @Autck sort ig a sorting alqvathm that uses the divide and conquer Strategy . In this Cassie d out. method the dtvsion 14 clipnarnialty, : The = three Sheps of Quick sort are as +fellows Split the are fnlo +eo sub aernys , that each element WW the bef sib array 1S \ess than ov esuel dhe middle element. 7 each element in the might Bub anny rs oprenter than middle element The splitkng of the arrace Tite hoo ) 20 +o Ca Ae foe atl Regt enxiblis = \o 20 30 +o 10) 55) eo fo XO 2.0) 30 +40 10 20 200 46 10 20 30 +40 lo #95. 30 40 The Quick Sort Using. 400 Important tun ctons ‘Gules nN) partition’ go “T° 0: Ao 1° 49° 10 Ao FO i “lj on a ; 3 oe 7, had 10 4 - i co 0 _ | (sorted ) algonthnn 1s performedAlaos Laos thro, Baek CA Co: nt], tow, hog) if (Row < high) -then rm Z< partihoo Cp Chow - Guick ( A Choror- > mo-)) Qurce (A Croidtty- kigh3) 4 hgh) Alqoathen partition (A Cow high3) t Piwt <— AC Low) 1 = ho je hight! uohite (14 =) do L ohile CACTI <= prot) do jeitl while (AGI >= pivot) do 4 <3) it (igs) theo gap CAC, A cia): ewap (ALLOOS, A cs)Analyst s ee Of Buick Zork i) Beet cage * at occers , if the pi@e ehemen VEST Cage 4% , 1S present eracHy at the centre divicling | the erat Inky two euel ation For Ge paris . The Recunence vel icksor® _ a we oF | TOS J eotay r¢nb + en HDI Tonys at(Ma) + EN 2 Ftp) en 2 ary (913) + 30% \ eX T(Mfae) 4 KON kek gk =n oF k= loa seme TCI lope = YN TC) + legnen : = YW Cat CN lo Sv Lo ore) l aoepore case, OCs Py all +he the worst Elements ac already gorleA keh TON) 9 cost involved to sort elemen& TOn-)) > fi u lo sort night part in parti hon ny ao7 * The «Recurrence relation (% Tune TON + oP cn) = Fron» + een“ J FCN = & (n-3)+ etn- 2) + cent) ¢ Oh) \ | ‘ ‘ 2 oT Cn ¢ typ C2 40:3 = ae + ecn-ayrcrr) tor 2 tbo) $e (It2t-~- Cnpery = O+ ¢ ncntl) Zz eee err (™) z oc%?Time complexity a Fe lO hoe | Average cast | Uoorst a. m(nlopn) (nto) o(m : Mere sort: is sorting. cleosithm thelr uses the, dinde q_ conquer ehatequy. an this roethed. Antigen is dynamically Cassied outs Merge ort on an input array, uotth 1D element Constes af thee Steps oivde: partion array into hwo gublets $! fy S2. uorth nfo elements -eech conquer. Then Sort aublist S15 Sublist Sx Cornbine 5 Merge Sl 7 S* inte a Unique, sorted res we uolll make hoo eublists ag safle] x0] 22 ao] 40]Algoritin Mergeset (A [o)~- ne, Aner high) q ih (how. high) they © idee Coot high) fy mergesott{F, too, mid) ren gesort (A, rides, high tomblne (A, Lo) mid hig h_) 2Algosithrs Paaine CALS) p-) , few) mie, high) & K ) +65 @ atin) Jet ft ar(rieetin) ve rt orth det Henle the averaat> % wears “5 et roementt ‘s €(n logs} case> time cory leat deb the returrente Relaten fer Mergasot £ ztn) = T(r) + T(Mh) +0 Por 7 Tn) = a T(r) +0, ! acl): det us apply gubstrtuhen on ejuahop KSSUME n a - ae er TON) = 2 21(2) te ak eek tia) = 21 V4 ¢.28(h we put = bel ther TC 24) = at (2%) te cea + (\2 2t(2 pF we con orhe 5 eat) = BTID 4? pats (at) rue aks (25S) + kent ah+ (2°) + Kes (8) a Sit Kee 5 ti) =0- 4 (8) 2 250+ weak TO) Ge but we assumed N= x funy Jeg OS, Jeg n= ( yin tone 44h! @Sbassens —__ lenity al Me Me sort— ———_!_. Fen &(n (09,9) Avy.case Matix Muttiplication ° Suppose woe want to multiply hoo matsices A ZB each Of Size N te c= AXE theo & Coes ene cis Ne Be fee fae ae a Aa) #22 Bzt Bar The multiplication F ves cu Cia Co) Cre Thus + there are additions. = AuxXBn + ANXB2y = ANXBal + ALYXB25_ = Asi RBu+ Aoo® Bay- = Ag) 88+ Aaa % Bay accoroplis b 2x2 Mahixn mult plicabdy 4otal ¢ multiplications and Y“Te Can accomplish his mule aS “the Foliewing, a lgvsitiy Algeasthmy Mat. mut (A, b,c, 9) g 4or 41 <1 tery de for jvc iten do clijj: =03 ster Kretbn do ctij]= CCE IIT AG IT BUI] 3 The ime complesit, ef abeve alyesthy Sieur to be o(nsnxn) = ol). Brbassen Shased that 2x2 math mubtplicticn Can be accomplished in F mutipleatton ¢ 1S additions or Substactions- The dlivicle g Conquer apprrach Can he used for implementing, Shassen math imu tt plication - s Divide 4 Dinde matszes inte sub-matnces Po, Al, R2- -ete * Conmiers se a Geup cf mab muttiply existe, “Combine » Recursively multiply sub-matyrces * get the foe of Che bres , ter pexformi eequixcd eddcht0s 7% a Pi in seared ) »( w) es ) - iG oa Bay Bas sre fn + Avo_)( Bit Bos) = (Pathe) x BY $3 = On x( Bi, ~ By a) SY= Por (By, ~ Bu) $5 = Ona+pp) * Bos = fay - Dy) x (By t By) Sta ia (Pia~ Pa) d (85,4025) CU StS ~So 45 Cn cm R= Sat So Qre Sat Sy (22> Si+ 53 Sats¢ | Tn shassen's mytt pltechorw ; - Cis Sit Sy Se 45y. = (P11 PasCBit Baa.) t BX (Bg) -B),) = CPt Pi) KB, + (An- Psa) x (8314 Bas) = PAuBy + PuB22F &,, By) Aas Baa + scence Po 5.Bi\ — Py Baa — Pio Bot Pr bay + AinBas Pas By Aas Bas Cie Py By + Pp Bay—Anatycis The Recurence ve lation ig Ton) = ! ae FTN) + 0™ nea d= az as o(0 ton L) = o( **!)