100% found this document useful (2 votes)
630 views31 pages

Recurrent Problems

Recurrent Problems: TOH, Pizza Cutting Problem and Josephus Problem

Uploaded by

Supriyo Chakma
Copyright
© Attribution Non-Commercial ShareAlike (BY-NC-SA)
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
100% found this document useful (2 votes)
630 views31 pages

Recurrent Problems

Recurrent Problems: TOH, Pizza Cutting Problem and Josephus Problem

Uploaded by

Supriyo Chakma
Copyright
© Attribution Non-Commercial ShareAlike (BY-NC-SA)
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/ 31
“Recurrent Problem” Tih Tower af Hanoi (Tot): Hes ee disk.-on 3 diamond needle. Recurrent problem solve ®ST% stepsé ies oo Appropriate nota tion 2, Find Recurrence 2. Find Recurrence Relation. / epuertion 4. Starting fom the smaller ones, find / ques sol”, 5 Tf needed » break down the recurrence 4o gel 3o/* 6. Prove the sol™ to be valid. ig Source Tnlermedial e A 8 foge BY J Tne n S53? disk @ A Bi C ab movements Complete. So, for 3 disks, 2°3 -1 = 7 Moves required 2 acl move & Yecurrence relahen form =4T+2+1 Ged =a [axa 2 open form ; Ly aft caleulation @@r Or eTt(6 wrocorer PAO ar | [ if mg ie R42 closed form Las n gle direct” ans 1031 *r] i 4) T.20 Ta ni 5 aT al as guess b= 5 wae om aff Ty =F | Ty ls) | pete) 6. Induction method u Prove. Guta prove @a(6 ay The2™1 Page 4 | nro = ee f Basis $ se OP for the lowes} value of n which isd, We show that Th 20s, holds To=8t=4- 19 [ @r eg prove @376 ae OST Cab value a ery ee Hypothesis’ For “alll. «Wales of 1 betweery I to n=l we assume that Th = 2" Sol” holds. 2 Weassume Tt =2%et)~1 ee a snk 2 TF q-! Sb ap vahie 20 1m RAF vig gn Awe Ua Fer OTS alt value 4 pr Me 0) CIOs gaior aa SRI clipe dice me MSI ra S arr eey hypothesis & way 43] Tnduction * n ay Hay ve curvenc é relation, hypoth esi: Te tony yrothesis C4 Tn-a OF value guess sey ai wer apt | = 262" 5) Cmpomessy /a@® ty reeurrence, prob solve @8/ 42°) Worst case. 4S no step. use Fl 2. @ TOK GF Ha closed eg” 2 @ Tou az ool OE PAO wall Le Qalby (ways ol @ ay iwabae proof 5122] Qt recturrénce Ds Da) direct far Proof & bil war */ from PDF => MUST See also: Double Tower of Hanoi (DTOH) and Triple Tower of Hanai (TTOH) (with their Inductive Proof Too!) 7 in DTOH, the Tn = minimum no. of moves to solve Double Tower al ttonot the DTOH problem with{n pairs (2n disks] Each two consecutive disks have equal size, so either one can be placed above the other one of its equal size é Q: For DTOH problem, prove that Tn = 2 (24n- 1) vv Ans; see below Q: Prove that Tn = 2 (24n - 1) for the Double Towr of Av Hanoi problem using mathematical induction on n. Ans: do yoursclf (hint: basis: 10 = 0 obvious, as T0=2(2"0-1)=2(1-1)=0 Hypothesis: Tut =24(2°r-1 - 1) i =2Tmi+2 oar 7 2*(2Anat = 1)]4+2 — se =2[24n-2]+2 ats 7m al aens tt Mave Top n-I pairs ‘Move Bottom Two disks Now, Again Mave the (Largest Two) nel pairs from from LtoM a. ‘ ate 2 T from L to R (destination) Mt R (destination) == n= oD he pe ad n-) Tee] eal a 2 )* we =2 (Toot 2)+2 2 7 iit in TTOH, the Tn = minimum no. of moves to solve the DTOH problem with mtriplets of disks (3n-disks). a Each three consecutive disks have equal size, so cither Hoe NO) one can be placed above the other one/two of equal size —____ x Q: For TTOH problem, prove Tn = 3 2-1) eX) ans: see below Q: Give inductive Proof Tn= 2*n-1) for TTOH} ; v hint: basis => n=0 => TO = 3(2°0-1) = 0 obvious: § — Induction; Tn = 2Tn- Z Z s i =3(2!n-1) proved) s ais ge 4 => ae a sft L 3 3 Move Top =I triplets Move Bottom Three 5 ae from E Hi M disks from L to R Mave Remaining n-1 triplets from M to R (destination) In = my orn Ws = 2 +2 = 2 (2Tr2+ 3) +3 oe a =o AG 8 AO n-) i“ | nT 2G Sno a ee =. nn - * +2°.8 1 nat Bee ee m-) + | Pole eee ae S x “fs ll Ghilepeapaneahe wanes fh Lines on ie PI = sae line Wy max” are cover. 361 Surface ta straight line fier we max, region. - infihity 74, @lA no. position bl sage | J) = |] + curvivour's number number of people in arelé, | L@t/ ate “YO MAME OHH iy dive ee 4¥ WHC (n) wy the ofr ony no Mb] ae at Tale oO Oo few att Sa gt Ae Oe Spec le prea cep AGW span SIRE ee: ® An) = 24(n)- J (6) = a(2a 3) =2J (2) =I odd HP RET eee: 4 ge 0 ge 70 om Bo a2 £0 Ba 5 @ © er Bs vs @I(en+i) - 2G)e1 So, Ki) = J tven > J (an) = 29(n) -1 ee. odd —> Tanti): 2 Tfn) +4 erie 3 ita Ie f 3 ier oe te | a a - ale) tlt 33 we [sn | ol “Odd -no. 47 »2 AF power GREE chan start 2 ,| ie ect dae Dies, [erat , neo es form & ey 5] IS 29747 Barer deek fre wl wee, myo, o¢b<2™ | FRA Joo = @ oS +68 wy area ay | dh: Pye = 6x83 0 - i ID = 9% 49 '= 941 > Bud tS £m Joo = 2+ 36-94) = 2x3b4t= 13 | lIdnductive Pronk angen) <24aN Basig.e Ne prove the closed form on m. for the lowest value of m which 1s zero, we show that o(24 4) = Ql+l is true if mis 0 yturll also be zero | og 42] . a I(2°+0) = 2x04) = 1 > ati shes hm, m4 L) = 2+ 1 holds for m=6 Hypo thesis= For all). yal edumboiieen() Yt) " ie hea : TMD. 21+) is tue. wrt Gee So, 12+ x)= 2x41 Tduchive proof t (24 1/2)=2(02)+ 1=1+1 [d(en) “U+ 1 proof #3(0 az for even en) Even Cases Ten) = 25 (n)-1 here, 2n foes cn Lf gy et seri PRAT | J(tn) = a Cote dja) <4 [oor value ai@| 7 afe Alp +1] —1] hypothesis wet | 2 22 pla = H+) Jan) = adr J [odd case (enti) GF GH] © basic ,hypethes'> came only proof dtd] Opp coset Jlons J) = 2I(n)t 4 here, In¢d = OL JM = Mt1- 1 2 ae 2 i, Fee 4d ' "J dna!)- 2904 4) dare 52] mag + ier feat = lf r Alt = 2L4] L pj(inri)= ales [50 odd even tld @RGe proof af Cra Give are indudlive proof wait reeurrence ep™ia Just Trae proof o 1a Ae wa problem proof Hat ayslbr a eg RUC GER Glo Cuan age —podd AF way at] dia evor 4 a > thn recurrence ie Ns Sosephys, prob aft evert/odd or ¢ven+odd 47 Gap OBE are | Mn) =3 (2" +) =2H1 Gy Binary Solution of Shgeplus problem é Question: Derive the Binary Property of the Josephus Problem. = 8t0 = 1° ene in =r ee is aloas ool | Since n= Het =n-2°m ken Janes * @x) tooo number (n-2" vis 0, rest af the bits are same as the hits of n. See exampte=> JS = Bt} = he On G h Toie® the last m bs of! dake a may Ong 8s - bs b, bee ee if n= 15(1 111) then [=P (OLD) pol= (a, E b 0), [ne of people Ce" cay Oe o. Li tet al wis an Ce far eat estng ‘om yee D+] = (bm) bigai aie by bol), n= lk WP bit binary @ Slr L @e U0 bit {a» bin aty @ once Loe aay 5 J] MSB ‘0! opya (alos) Ea — Exe set og N=24 = 11000 100=3 00100 ged m é 28 2436 94 SOOFOOI=72 | oh, a Ca x re iiss 01900 i ‘ ze n@ bn @® evra binary no @4 conver} 8 MS @ alae WT left shit } SAA No CIC OMT Ahn OT dl ediral dowble z@r agar a k TIGR soludon OF 26F a * Ex —> "8" So, nike just aaa a ate aon je 21 $= 0 101 double ~" ag 0 = 1010 ca Ip] Generaliz = ver si0n_ a seaeorenena) ui blem: wire Yosephus problem ay a {=o GMA Yeeurrence Ch¥] W1TR, closed fan) = 28(n) +P form G3 9R(O 20 pied GA, p,? ay] Bae F(2n+3) 5 24n)t” Josephus Prablem Recurrence. spat Aan) = Dien) - 1 Qe pees $(2) = f(2mt) = 2F0) +B = 2h +P (3) =f (a1 +1) = 2009+ emma eS Lol + IK emma $0, fn) 9X QI GNA solulfon OFT d f(n)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy