Algorithms and discrete applied mathematics second international conference caldam 2016 thiruvananth
Algorithms and Discrete Applied Mathematics
Second International Conference CALDAM 2016
Thiruvananthapuram India February 18 20 2016 Proceedings 1st Edition Sathish Govindarajan
Visit to download the full and correct content document: https://textbookfull.com/product/algorithms-and-discrete-applied-mathematics-second -international-conference-caldam-2016-thiruvananthapuram-india-february-18-20-201 6-proceedings-1st-edition-sathish-govindarajan/
More products digital (pdf, epub, mobi) instant download maybe you interests ...
Algorithms and Discrete Applied Mathematics First International Conference CALDAM 2015 Kanpur India February 8 10 2015 Proceedings 1st Edition Sumit Ganguly
Security Privacy and Applied Cryptography Engineering 6th International Conference SPACE 2016 Hyderabad India December 14 18 2016 Proceedings 1st Edition Claude Carlet
String Processing and Information Retrieval 23rd International Symposium SPIRE 2016 Beppu Japan October 18 20 2016 Proceedings 1st Edition Shunsuke Inenaga
The firstConferenceonAlgorithmsandDiscreteAppliedMathematicswasheldat theIndianInstituteofTechnology,Kanpur,duringFebruary8–10,2015,andthe proceedingswerepublishedinthe LectureNotesinComputerScience (volume8959). The firstconferenceaccepted26papersoutof58submissionsfrom10countries.
Wenowstateafewstandardterminologiesaboutrandomizedalgorithms. Therearetwotypesofrandomizedalgorithms:LasVegasandMonteCarlo.A randomizedalgorithmiscalledaLasVegasalgorithmifitsoutputisalways correctbutitsrunningtimeisarandomvariable.Arandomizedalgorithmis calledaMonteCarloalgorithmifitsrunningtimeisfixedbutitsoutputmaybe incorrectwithsomeprobability.Whiledesigningoranalysingagraphalgorithm, n and m willdenoterespectivelythenumberofverticesandedgesofagraph.In thecontextofarandomizedalgorithm,weusuallysaythataneventwillhappen with highprobability iftheprobabilityofitshappeningismorethan1 n c foranyconstant c> 0.Formostofthepracticalapplications,aMonteCarlo algorithmthatsucceedswithhighprobabilityisconsideredalmostasgoodas anydeterministicalgorithm.
2Fingerprinting
Weillustratethistechniquethroughitsapplicationinsolvingtheproblemof fullydynamictransitiveclosureofadirectedgraph G.Theaimistomaintain aBooleanmatrix M suchthat M [u,v ]=1ifandonlyifthereisatleastone pathfrom u to v .KingandSagert[16]designedaMonteCarloalgorithmfor thisproblemthattakes O (n2.26 )updatetime.Theyfirstdesignedan O (n2 ) updatetimealgorithmforadirectedacyclicgraph(DAG)andthenextended ittogeneralgraphsusingfastalgorithmsformatrixmultiplication.Forthe sakeofclearexpositionofthefingerprintingtechniqueinthisarticle,werestrict ourselvestoDAGonly.
Asimpleandobviousapproachtomaintainthetransitiveclosureistokeepa matrix P-count thatstoresthecountofalldistinctpathsfrom u to v foreach u,v ∈ V .Twopathsaresaidtobedistinctifthesetsoftheedgesdefiningthem arenotthesame.So M [u,v ]=1ifandonlyif P-count[u,v ] > 0.Inorderto maintain P-count underinsertionanddeletionofedges,thefollowinglemma, thatholdsforaDAG,turnsouttobeverycrucial.Asimpleproofofthislemma isbasedontheexistenceofatopologicalorderingforaDAG.
Lemma1. Let (i,j ) beanyedge,andlet Pu,i and Pj,v beanytwopathsina DAG.Thenconcatenationof Pu,i ,edge (i,j ),and Pj,v isapathfrom u to v .
Considerinsertion(ordeletion)ofanedge(i,j ).ItfollowsfromLemma 1 that foranytwovertices u,v ∈ V ,theincrease(ordecrease)inthenumberofpaths fromanyvertex u toanyvertex v isexactly(P-count[u,i] × P-count[j,v ]). Thissuggeststhefollowingalgorithmforupdating P-count uponinsertionof anedge(deletionofanedgeissimilar).
Algorithm 1 thusperforms O (n2 )arithmeticoperationstoupdate P-count foranyedgeinsertionordeletion.However,thisisstillnotan O (n2 )timealgorithm.Thisisbecausetherecanbe Θ (2n )pathsbetweentwoverticesinaDAG, andsoanentryin P-count canbea n-bitnumber.ButthewordRAMmodel facilitatesexecutionofanarithmeticoperationin O (1)timeprovidedthenumberofbitsis O (log n)only.So,atfirstsight,Algorithm 1 seemstohavehita hurdletoohardtoovercome.However,observethatwehavetojustdetermine whether P-count[u,v ] =0,andsowedon’thavetomaintain exact valueof P-count[u,v ].Thisobservationcanbeexploitedwiththehelpofrandomizationtosolveourproblem.Insteadofworkingwiththe n-bitnumbers,basically weworkwiththeirshort fingerprints asfollows:
–Pickaprimenumber p randomlyuniformlyfrom[2,nc log n]forany c> 0. –PerformallarithmeticoperationsinAlgorithm 1 modulo p
Thoughthealgorithmwilltake O (n2 )timenow,whatistheguaranteeabout itscorrectness?If P-count[u,v ]mod p =0,surely P-count[u,v ] =0and hence M [u,v ]=1.However,if P-count[u,v ]mod p =0,itisnotnecessary that P-count[u,v ]=0(andhence M [u,v ]=0).Butthismayhappenonlyif P-count[u,v ]isdivisibleby p.Weshallnowshowthattheprobabilityofthis happeningisextremelysmall.
Thewell-knownPrimeNumberTheoremstatesthatthenumberofprime numberslessthan k isasymptotically k/ ln k .Therefore,thereare Θ (nc )prime numbersintheinterval[2,nc log n].Considerany u,v ∈ V .Sinceeachprime numberis ≥ 2,and P-count[u,v ]atanystageisatmost2n ,sothenumber ofitsprimefactorsistriviallyboundedby n.Therefore,theprobabilitythata randomlyselectedprimenumberfrom[2,nc log n]divides P-count[u,v ]isat most1/nc 1 .Probabilityofunionofasetofeventsisupperboundedbythe sumoftheprobabilityofindividualevents.Therefore,theprobabilitythatany ofthe n2 entriesinthematrixiswrongisatmost1/nc 3 whichis n 3 for c =6. ThuswegetaMonteCarloalgorithmforfullydynamictransitiveclosureofa DAG.Thetransitiveclosurematrixmaintainedbythealgorithmiscorrectwith probabilityatleast1 n 3 atanystage.
3RandomSampling
Thetechniqueofrandomsamplingisoneofthemostpowerfulrandomization techniquestodesignefficientalgorithms.Itspowercanberealizedthroughthe followingsimpleexample.Supposethereisalargeset S consistingof good elementsand bad elements.Moreover, α fractionof S consistsofgoodelementsand itcanbedeterminedefficientlywhetheranygivenelementisgood.Theaimis toselecta good elementfrom S .Thereisnoefficientwaytoaccomplishthisaim deterministicallysinceintheworstcasewemightneedtoscanthroughlarge numberofelements.However,thereisasimplerandomizedwaytoachieveit: Pickanelementrandomlyuniformlyfrom S .Thiselementisgoingtobeagood elementwithprobability α.Thisprobabilitycanbeboostedarbitrarilycloseto 1byrepeatedsampling.Weillustratethepowerofrandomsamplingtechnique indynamicalgorithmsthroughtheproblemoffullydynamicconnectivity.
Thefullydynamicconnectivityproblemcanbedescribedasfollows.There isanundirectedgraphundergoinginsertionanddeletionofedges.Theaimis tomaintainadatastructuresothatthefollowingquerycanbeansweredefficientlyforany u,v ∈ V : Is u connectedto v byapathin G ?Thisproblem isarguablythemostextensivelyresearchedproblemintheareaofdynamic graphalgorithms.ThefirstalgorithmforthisproblemwasdesignedbyFrederickson[8]thattakes O (√m)updatetimeand O (1)querytime.Theupdate timewasimprovedto O (√n)usingasparsificationtechnique[6].Thereafter,a majorbreakthroughforthisproblemwasachievedthroughrandomizationonly: HenzingerandKing[12]designedaLasVegasalgorithmthatachievesexpected amortized O (log 3 n)updatetimeand O (log n)querytime.Theiralgorithmmaintainsapartitionofedgesamong O (log n)levels:higherthelevel,sparserthe edgesets.ForabetterexpositionoftherandomizationtechniqueusedbyHenzingerandKing[12],wepresentanalgorithmwith2-levelpartitionoftheedges, andfirstconsiderdeletionofedgesonly.
Wefirstpresentanoverviewandintuitionunderlyingthealgorithm.The algorithmmaintainsaspanningforest F ofthegraphsuchthateachtree T ∈F spansaconnectedcomponentofthegraph.Soinordertodetermineiftwo verticesareconnected,wejustneedtodetermineiftheybelongtothesametree in F .Foranysubtree T ofatree T ∈F ,let E (T )denotethesubsetofedges withatleastoneendpointin T .Anedgein E (T )issaidtobeacutedgeifits exactlyoneendpointispresentin T .
Deletionofanynon-treeedgedoesnotchange F andsocanbehandled trivially.Letusconsiderdeletionofanedge e presentinsometree T ∈F that splitsitintotwotrees T1 and T2 .Weneedtodeterminewhetherthereisany edgein E thatconnects T1 and T2 ,andifso,findonesuchedgetojoin T1 and T2 Withoutlossofgenerality,let T1 besmallerinsizethan T2 .Soweneedtosearch foracutedgefrom E (T1 ).Maintainingthecutedgesdefinedbyvariousedges intheforest F explicitlyisachallengingtaskduetotheunderlyingdynamic environment.However,asimplerandomizationideashowsanefficientwayto findacutedgefrom E (T1 ).Observethatif α fractionof E (T1 )consistsofcut edges,thenarandomlypickededgefrom E (T1 )isgoingtobeacutedgewith
probability α.Soif α isagoodfraction,wecanfindacutedgebyrepeatedly samplinganedgeandcheckingifitisacutedge.Butwhatif α istoosmall? Thishappenswhenthecutdefinedby T1 and T2 isverysparse.Wecollectedges ofeachsuchsparsecutinaseparatepoolatlevel2duringthealgorithm.Itis ensuredthatthenumberofedgesinthispoolremainverysmallalways,therefore, searchingforacutedgeinthispoolcanbedoneinabruteforcemanner.With thisoverview,weshallnowdescribethealgorithminmoredetails.
Inordertocarryoutvarioustasksefficiently,weshallneedadatastructure thatcanperformthefollowingoperationsefficientlyforanysubtree T ofatree T ∈F
–Determiningiftwoverticesbelongtothesametreein F in O (log n)time. –Pickinganedgerandomlyuniformlyfrom E (T )in O (log n)time.
–Computingalledgesfrom E (T )in O (|E (T )| log n)time.
Thealgorithmmaintainsa2-levelpartition- E1 and E2 oftheedges E .In thebeginning E1 = E and E2 = ∅.Asthealgorithmproceeds,someedgesmay getmigratedtolevel2.Inaddition,weshallmaintaintwo(insteadofjustone) spanningforests: F1 foredges E1 ,and F2 foredges E1 ∪ E2 suchthat F1 ⊆F2 . Thus F2 ateachstageisthespanningforestofthegraph.Deletionofatreeedge e ishandledasfollows.If e ∈F2 \F1 ,wehandleittriviallybyscanning E2 to findacutedge.If e ∈F1 ,let T1 and T2 bethetwotreesformedbydeleting e, andlet T1 besmallerthan T2 insize.Algorithm 2 (onthefollowingpage)isused tosearchforacutedgefrom E (T1 )asfollows.Let t beaparametertobefixed lateron.Wesampleanedgerandomlyuniformlyfrom E (T1 )andcheckwhether itisacutedge.Werepeatthisstep2t log n times.Ifwesucceed,wejoin T1 and T2 bythecutedge,andadditto F1 and F2 .Ifwedon’tsucceed,wescanthe entireset E (T1 )tocollectallcutedges.Ifnumberofcutedgesisatleast |E (T1 )| t , wejoin T1 and T2 byacutedge,andadditto F1 and F2 .Otherwise,wemove allcutedgestolevel2.Wethensearch E2 foracutedge.Ifacutedgeisfound, wejoin T1 and T2 byit,andadditto F2 . Letusanalysethetimecomplexityofdeletingatreeedge.Supposeedge deletedbelongsto F1 .Therearetwopossiblecases.
1.Thefirstcaseisthatthesamplingissuccessfuloratleast |E (T1 )|/t edgesare cutedges.Ifsamplingissuccessful,thetimecomplexityis O (t log 2 n)time. Letusanalysethesituationwhenatleast |E (T1 )|/t edgesarecutedges.Inthis caseanedgeselectedrandomlyfrom E (T1 )willbeacutedgewithprobability atleast1/t.Therefore,theprobabilitythattheloopdoesnotterminatewith success isatmost(1 1 t )2t log n ≤ n 2 .Inthissituation,Algorithm 2 computes alledgesofset E (T1 ).Sotheexpectedtimecomplexityofthefirstcaseis boundedby O (t log 2 n + n 2 |E (T1 )| log n)= O (t log 2 n)only.
2.Thesecondcaseiswhensamplingisunsuccessfulandlessthan |E (T1 )|/t edgesarecutedges.Inthiscase,wemoveallthecutedgesfromset E (T1 )
Algorithm2. Efficientsearchingforacutedgefrom E (T1 ).
1 count ← 0;success ← false; 2 repeat 3 count++;
4 Pickanedge e ∈ E (T1 )randomlyuniformly;
5 if e isacutedge then success ← true;
6 until (count=2t log n or success);
7 if success then Add e to F1 and F2 ;// Join T1 and T2 by e
8 else
9 X ← allcutedgesfrom E (T1 );
10 if |X |≥ |E (T1 )| t then
11 Addanyedgefrom X to F1 and F2 ;// Join T1 and T2 by e
12 else
13 Move X to E2 ;
14 Search E2 foracutedgetojoin T1 and T2 ,andadditto F2 ;
15 end 16 end
tolevel2.Apartfromsearchinglevel2foracutedgetojoin T1 and T2 ,the additionalcomputationcostinthiscaseis O (|E (T1 )| log n).Moreover,the numberofedgespassedtolevel2isatmost |E (T1 )|/t.Wecandistributeboth thesequantitiesamongtheverticesof T1 proportionaltotheirdegrees:For each v ∈ T1 ,weassign O (deg (v )log n)computationcostandassign deg (v )/t edgesthataremovedtolevel2.Theseareindeedhugequantities.However, noticethefollowingeventthathappensinthiscase:Atlevel1, v nowbelongs totree T1 whosesizeisatmosthalfoftheprevioustree T .Thiseventcan happenfor v atmost O (log n)timesoveranysequenceofedgedeletions. Sotheadditionalcomputationcostis O (m log n)andthenumberofedges passedtolevel2willbe O ( m t log n)overanysequenceofedgedeletions.This establishesthat E2 willhaveatmost O ( m t log n)edgesonly.
Ifthedeletededgebelongsto F2 \F1 ,wefindacutedgebyscanning E2 . Since |E2 | = O ( m t log n)asshownabove,thetimecomplexityforhandlingedge deletioninthiscasewillbe O ( m t log 2 n)(usingEuler-Tourtreedatastructure). Inordertominimizethetimeperupdate,webalancethetimecomplexitiesfor handlingedgedeletionatlevel1andlevel2.Sowechoose t = √m toobtain expectedamortized O (√m log 2 n)updatetimeperedgedeletion.Thiscompletes thedescriptionandanalysisofthedecrementalalgorithmforconnectivity.This algorithmcanbeextendedtohandleinsertionofedgesbyinsertingeverynew edgetolevel2andrebuildingtheentirestructure(F1 andEuler-Tourtree datastructure)afterevery √m edgeinsertionsin O (m log n)time.Thuswecan maintainfullydynamicconnectivityinexpectedamortized O (√m log 2 n)time using2-levelpartitionofedges.Withamorerefinedpartitioningofedgesamong O (log n)levels,HenzingerandKing[12]achieve O (log 3 n)expectedamortized updatetime.
Itwasalong-standingopenproblemtoachieveworstcase O (polylog n) updatetime.RecentlyKapron,King,andMountjoy[15]designedaMonteCarlo algorithmforfullydynamicconnectivitythattakes O (polylog n)timeperupdate andanswersanyconnectivityquerycorrectlywithhighprobability.Interestingly, thisalgorithmalsoemploysrandomsamplingbutinadifferentway.
4MaintainingWitnesses
Whenmaintainingapropertyexplicitlyappearsdifficult,itissometimeeasierto maintainitimplicitlybykeepingoneofits witnesss fortheproperty.Inorderto illustratetheeffectivenessofthistechnique,weconsidertheproblemofall-pairs decrementalreachability.Givenadirectedgraph G underdeletionofedges,this problemaimsatmaintainingadatastructurethatcananswerthefollowing queryefficientlyforany u,v ∈ V : Isthereapathfrom u to v ? Weshallusethe followingwell-knownresultthatfollowsfrom[7].
Lemma2. Foranyvertex v andapositiveinteger d,ittakes O (md) totaltime tomaintainabreadthfirstsearch(BFS)treerootedat v in G andtruncatedupto depth d foranyarbitrarysequenceofedgedeletions.
WeshallnowdescribeaMonteCarloalgorithm[3]formaintainingreachability underdeletionofedges.Let d beaparametertobefixedlater.Apathissaidtobe short ifitslengthisatmost d,andissaidtobe long otherwise.Thedecremental algorithm[3]maintainsreachabilityassociatedwithshortpathsexplicitlyand maintainsreachabilityassociatedwithlongpath implicitly asfollows.
ReachabilityAssociatedwithShortPaths: MaintainBFStreeuptodepth d fromeachvertex.ItfollowsfromLemma 2 thatthetotalupdatetimefor maintainingthesetreeswillbe O (mnd)whichisquitesmallif d issmall.
ReachabilityAssociatedwithLongPaths: Let Gr denotethegraph obtainedbyreversingalledgesin G.Let Tout (w )and Tin (w )respectivelybe theBFStreesrootedat w ingraphs G and Gr .Consideranypairofvertices u,v ∈ V suchthat u ∈ Tin (w )and v ∈ Tout (w ).Observethatvertex w alongwith thepair(Tin (w ),Tout (w ))actsasawitnessofreachabilityfrom u to v .Thusan alternateschemeforcomputing(ormaintaining)all-pairsreachabilityisbycomputing(ormaintaining)thesewitnesses.However,tomaterializethisscheme,we needtohaveasmallsetofverticesthatcontainsawitnessforreachabilityfor all-pairs.Interestingly,forall-pairsofverticesseparatedbylongdistance,randomizationhelpsinconstructingasmallsetofwitnesseswithhighprobability. Indeed,Algorithm 3 computessuchasetandalsocomputesawitnessmatrix thatwillstore,withhighprobability,awitnessofreachabilityforallsuchpairs.
Lemma3. Supposedistancefromavertex u toavertex v is t>d.Withhigh probability, W [u,v ] storesawitnessofreachabilityfrom u to v .
Proof. Let i besuchthat2i d ≤ t< 2i+1 d.Let Puv betheshortestpathfrom u to v ,andlet w beanyvertexonthispath.If w isselectedin Si ,itfollows
2 Si ← asetformedbyselectingeachvertexindependentlywithprob. c log n 2i d ;
3 foreach w ∈ Si do
4 Tout (w ) ←
5 Tin (w ) ←
BFStreeofdepth2i d rootedat w in G;
BFStreeofdepth2i d rootedat w in Gr ;
6 foreach u ∈ Tin (w ) and v ∈ Tout (w ) do
7 if W [u,v ]= null then W [u,v ] ← w
8 end
9 end 10 end
fromAlgorithm 3 thattheentirepath Puv iscontainedin Tin (w )and Tout (w ). Sinceeachvertexofthegraphisselectedrandomlyindependentlyin Si ,the probabilitythatnovertexon Puv isselectedin Si is
Soatleastonevertexof Puv willappearin Si withprobability ≥ 1 1/nc ;and so W [u,v ]willstoreawitnessofreachabilityfrom u to v
Let L bethelistformedbyconcatenating Si ’sintheincreasingorderof i Noticethattheremaybemultiplewitnessesofreachabilityfrom u to v inthe list L.ButAlgorithm 3 ensuresthat W [u,v ]pointstothefirstwitnessinthe list L
Therandomsamplingtoconstruct Si ’siscarriedoutindependentoftheedges ingraph G,soLemma 3 mustholdtruefor G evenafteranynumberofedges aredeletedfromit.Therefore,inordertomaintainreachabilityastheedgesare beingdeleted,allweneedistomaintainthecollectionoftheBFStreesbuilt duringAlgorithm 3 andmaintainwitnessmatrix W accordingly.Thistaskturns outtobesimpleandefficientasfollows.
Consideranyvertex w ∈ Si forany i.Let Tin (w )and Tout (w )betheBFS treesassociatedwith w .Weprocess w upondeletionofanedge e asfollows. Wefirstupdate Tin (w )(and Tout (w )),andwegetthoseverticesthatceaseto belongto Tin (w )(and Tout (w )).Thisallowsustocomputeallthosepairsof verticesforwhich w hasceasedtobeawitnessofreachability-foreachsuch pair(u,v ),either u hasceasedtobelongto Tin (w )or v hasceasedtobelong to Tout (w ).Foreachsuchpair,if W [u,v ]= w ,wesearchforanotherwitness, ifany,in L startingfromcurrentlocation(w );westopuponfindingthenext witnessandupdate W [u,v ]accordingly.Aslongasthereisapathfrom u to v of length ≥ d,Lemma 3 impliesthat,withhighprobability, W willstoreawitness ofreachabilityfrom u to v
Inordertoansweraqueryofreachabilityfrom u to v ,wemayfirstquery theBFStreeofdepth d associatedwith u foranyshortpathfrom u to v .Ifit
fails,welookinto W [u,v ]forwitnessofreachabilityforanylongpathfrom u to v .ItfollowsfromLemma 3 thatthequerywillbeansweredcorrectlywithhigh probability.
Letusanalysethetotalupdatetimeformaintainingthewitnessmatrix. Expectedsizeof Si is O ( n log n 2i d ).SoItfollowsfromLemma 2 thatthetime complexityofmaintainingthe in and out BFStreesforverticesofset Si isof theorderof m n log n 2i d 2i d = mn log n.SotheupdatetimeformaintainingtheBFS treesforall Si ’sis O (mn log 2 n).Notethatonceavertexceasestobeawitness ofreachabilityforapair,itwillneverbecomeawitnessforthepairagain.Sothe extracomputationaltimespentinoutputtingallsuchpairsoveranysequenceof edgedeletionsis O (n2 )foreachvertex w ∈ L.Further,eachpairmakesasingle scanoverthelist L insearchofwitnessduringthealgorithm.Ittakes O (1)time tocheckifavertex w ∈ L isawitnessofreachabilityforapair u,v :wejust querythecorrespondingBFStreesassociatedwith w .Expectedsizeof L is O ( n log n d ).Sothetotaltimespentinsearchingforawitnessin L is O (n2 n log n d ) timeforallpairs.Therefore,theoveralltimecomplexityofmaintainingall-pairs reachabilityassociatedwithlongpathsis O ( n 3 d log n + mn log 2 n).
Combiningtogetherthetasksofmaintainingreachabilityforshortandlong paths,thetotaltimecomplexityoveranysequenceofedgedeletionsis n3 d log n + mn log 2 n + mnd
Theaboveexpressionattainsitssmallestvalue O (n2 √m log n)ifwechoose d = n√log n/√m.Thuswecanconcludethatall-pairsreachabilitycanbemaintainedinexpectedamortized O (n2 √log n/√m)timeperedgedeletion.This algorithmwasthefirsttoachievesubquadraticupdatetimefordecremental reachability.However,thealgorithmisMonteCarloandanswersanyreachabilityquerycorrectlywithprobabilityatleast1 n c forany c> 0.
Wedemonstratethepowerofthistechniquebyatoyproblemsoastohighlightitsintricacieseffectively.Considerastargraph G =(V,E )on n = |V | verticeswithauniquesourcevertex s joinedtoeveryothervertexbyanedge. Theedgesarenowdeletedbyanadversary.Theobjectiveisthat s hastocling toexactlyoneneighbour,denotedby N (s),ateverymomentoftime.Whenever theedge(s,N (s))isdeleted, N (s)ceasestobetheneighbourof s.So s needs toswitchtoanotherneighbouramongtheexistingones.However,foreachsuch switching s needstopayacostof c units.Theaimistominimizethecost incurredoveranyarbitrarysequenceofedgedeletions.Observethatifweuse anydeterministicalgorithm,thatis,asequenceofneighboursthat s shouldtake, thentheadversarycanmake s paymaximumcost c(n 2)bydeletingedgesin thesamesequence.Weshallnowpresentanextremelysimplerandomizedalgorithmthatwillincurexpected O (c log n)cost.Theideaistofoiltheadversary byselectingarandomneighbourfor s whenever(s,N (s))getsdeleted.Notethat theneighbourmaintained(basedontherandombits)by s atanystageisnot knowntotheadversary.
Algorithm4. Handlingdeletionofanedge(s,v )
1 if N (s)=v then
2 x ← avertexpickedrandomlyamongalltheexistingneighboursof s;
3 N (s) ← x 4 end
Itiseasytoobservethatthealgorithmmaintainsthefollowinginvariant. I :If A isthesetofverticesadjacentto s atanymoment,thenforevery v ∈ A,
P[N (s)= v ]= 1 |A|
Weshallnowanalysetheexpectedcostincurredby s foranyarbitrarysequence ofedgedeletions.Let X bearandomvariableforthenumberoftimes s changes itsneighbourforthegivensequenceofedgedeletions.Let v1 ,...,vn 1 bethe sequenceofvertices V \{s} inthechronologicalorderoflosingtheiredges incidentonto s.Wedefinearandomvariable Xi , 1 ≤ i<n asfollows. Xi = 1ifdeletionofedge(s,vi )incursacost 0otherwise
Clearly X = i Xi .Hencebylinearityofexpectation E[X ]= i E[Xi ]= i P[Xi =1].Considerthemomentjustbeforethedeletionof(s,vi ).There were n i neighboursthatexistedatthatmoment.SoitfollowsfromInvariant I thatprobability N (s)is vi atthismomentis 1 n i .Hence
[X ]=
Sotheexpectedcostincurredby s is O (c log n)whichismuchsmallerthanthe worstcasecost Θ (cn)incurredbyanydeterministicalgorithm.
Let G =(V,E )beanundirectedgraphon n = |V | verticesand m = |E | edges.Amatchingin G isasetofedges M⊆ E suchthatnotwoedgesin M shareanyvertex.Amatchingissaidtobe maximal ifitisnotstrictly containedinanyothermatching.Itiswellknownthatamaximalmatching achievesafactor2approximationofthemaximummatching.Formaintaining maximalmatchinginfullydynamicenvironment,IvkovicandLloyd[14]designed adeterministicalgorithmthattakes O ((n + m)0 7072 )updatetime.Recently,a randomizedalgorithmhasbeendesignedforfullydynamicmaximalmatching thattakesexpectedamortized O (log n)updatetime[2].Wenowprovideasketch ofthisalgorithmnow.
Inordertomaintainamaximalmatching,itsufficestoensurethatthereis noedge(u,v )inthegraphsuchthatboth u and v arefreewithrespecttothe matching M.Therefore,anaturalapproachformaintainingamaximalmatching istomaintainwhethereachvertexismatchedorfreeateachstage.Whenanedge (u,v )isinserted,weadd(u,v )tothematchingif u and v arefree.Forthecase whenanunmatchededge(u,v )isdeleted,noactionisrequired.Otherwise,for both u and v wesearchtheirneighbourhoodsforanyfreevertexandupdatethe matchingaccordingly.Itfollowsthateachupdatetakes O (1)computationtime exceptwhenitinvolvesdeletionofamatchededge;inthiscasethecomputation timeisoftheorderofthesumofthedegreesofthetwoendpointsofthedeleted edge.Sothistrivialalgorithmisquiteefficientfor small degreevertices,butcould beexpensivefor large degreevertices.Analternateapproachcouldbetomatcha freevertex u witharandomlychosenneighbour,say v .Followingtheadversarial model,itcanbeobservedthatanexpecteddeg(u)/2edgesincidentto u willbe deletedbeforedeletingthematchededge(u,v ).Sotheexpectedamortizedcost peredgedeletionfor u isroughly O deg(u)+deg(v ) deg(u)/2 .Ifdeg(v ) < deg(u),thiscost is O (1).Butifdeg(v ) deg(u),thenitcanbeasbadasthetrivialalgorithm.To circumventthisproblemanovelconcept,called ownership ofedgesisdeveloped in[2].Intuitively,weassignanedgetothatendpointwhichhas higher degree.
Theideaofchoosingarandommateandthetrivialalgorithmdescribedabove canbecombinedtogethertodesignasimplealgorithmformaximalmatching. Thisalgorithmmaintainsapartitionoftheverticesintotwolevels.Level0 consistsofverticeswhichown fewer edgesandwehandletheupdatesthere usingthetrivialalgorithm.Level1consistsofvertices(andtheirmates)which own larger numberofedgesandweusetheideaofrandommatetohandletheir updates.This2-levelalgorithmachieves O (√n)expectedamortizedtimeper update.Acarefulanalysisofthe2-levelalgorithmsuggeststhata finer partition ofverticesamongmorenumberoflevelscanhelpinachievingafasterupdate time.Thisleadstothelog 2 n-levelalgorithmthatachievesexpectedamortized O (log n)timeperupdate.
Abstract. Let A beasequenceof n orderedpairsofrealnumbers(ai ,li ) (i =1,...,n)with li > 0,and L and U betwopositiverealnumbers with0 <L U .Asegment,denotedby A[i,j ], 1 i j n,of A isaconsecutivesubsequenceof A betweentheindices i and j (i and j included).Thelength l [i,j ],sum s[i,j ]anddensity d[i,j ]ofasegment A[i,j ]are l [i,j ]= j t=i lt , s[i,j ]= j t=i at and d[i,j ]= s[i,j ] l[i,j ] respectively.Asegment A[i,j ]isfeasibleif L l [i,j ] U .Thelengthconstrainedmaximumdensitysegmentproblemistofindafeasiblesegmentofmaximumdensity.Wepresentasimplegeometricalgorithm forthisproblemfortheuniformlengthcase(li =1forall i),with timeandspacecomplexitiesin O (n)and O (U L +1)respectively. The k length-constrainedmaximumdensitysegmentsproblemistofind the k mostdenselength-constrainedsegments.Fortheuniformlength case,weproposeanalgorithmforthisproblemwithtimecomplexityin O (min{nk,n lg(U L +1)+ k lg 2 (U L +2),n(U L +1)}).
Let A beasequence(ai ,li )(i =1,...,n)of n orderedpairsofrealnumbers ai ,calledvalues,and li > 0,calledlengths,and L,U twopositiverealnumbers with0 <L U .Asegmentof A,denotedby A[i,j ], 1 i j n,isa consecutivesubsequenceof A betweentheindices i and j ,bothinclusive.The length l [i,j ],sum s[i,j ]anddensity d[i,j ]ofasegment A[i,j ]are l [i,j ]= j t=i lt , s[i,j ]= j t=i at and d[i,j ]= s[i,j ] l[i,j ] respectively.Afeasiblesegmentof A isa segment A[i,j ]suchthat L l [i,j ] U .Inthispaperwestudythefollowing problems.
c SpringerInternationalPublishingSwitzerland2016 S.GovindarajanandA.Maheshwari(Eds.):CALDAM2016,LNCS9602,pp.14–25,2016. DOI:10.1007/978-3-319-29221-2 2
Whenthelengthsareuniform(i.e., li =1)and U and L arearbitrary, Goldwasser etal. [7]gavean O (n)timealgorithm.Forthecaseofnon-uniform lengthsandarbitrary U and L,Goldwasser etal. [8]extendedtherightskew decompositionmethodofLin etal. [11]todevelopan O (n)-timeandspacealgorithm.Anonline,combinatorialalgorithmwithtime-complexityin O (n)and spacecomplexityin O (m),where m isthemaximumofthenumberofelements inasegmentoflength U L,wasproposedin[4].Italsopointedoutaflawin thelinearityclaimofageometry-basedalgorithmbyKim[9].Lee etal. [10]fixed thisflawbyexploitingthepropertyofdecomposabilityofatangentquery,and proposedarevisedalogorithmwithtimeandspacecomplexitiesin O (n).Inthis paper,wepresentasimplemodificationofKim’salgorithm[9]thatredressesthe flawusingabatchedmodeapproach,whileretainingthesimplicity,eleganceand linearityofhisgeometricapproach.Fortheuniformlengthcaseandarbitrary L and U ,thetimeandspacecomplexitiesofouralgorithmarein O (n)and O (U L +1)respectively.
Asanaturalextension,weconsiderthe k length-constrainedmaximumdensitysegmentsproblem,definednext:
Problem2. Givenapositiveinteger k suchthat 1 k totalnumberoffeasiblesegments,the k length-constrainedmaximumdensitysegmentsproblemisto find k feasiblesegments A[i,j ] suchthattheirdensities d[i,j ] arethe k largest.
Ourproposedalgorithmsolvesthisproblemfortheuniformlengthcaseand arbitrary L and U in O (min{nk,n lg(U L +1)+ k lg 2 (U L +2),n(U L +1)}) time.Itsspacecomplexityisin O (U L + k ), O ((U L +1)lg(U L +2)+ k ) or O (k ),dependingonthevalueof k .
Theratio(C + G)/(A + C + G + T )isameasureoftheGCcontentofa DNA-sequence,where A,C,G,T arethenucleotidebases.Accordingto[12, 15] thecompositionalheterogeneityofagenomicsequenceisstronglycorrelated toitsGCcontentregardlessofgenomesize.Ithasalsobeenfoundthatgene length[5],genedensity[17],patternsofcodonusage[14]andotherproperties arerelatedtoGCcontent.However,itisnotestablishedthatthesinglemost denseregionistheonlymeaningfulregion.OthersegmentswithhighGCcontentmightalsobemeaningful.Ourproposedalgorithmscanbeusedtofind lengthconstrainedCG-richregionswiththemaximumdensityand k maximum densityinaDNAsequenceefficiently.
InSect. 2 wedescribeouralgorithmforthemaximumdensitysegmentproblem.Ouralgorithmforthe k maximumdensitysegmentsproblemispresented inSect. 3.ConcludingremarksaregiveninSect. 4.
2SPLITHULLAlgorithmforMaximumDensity Segment
Theprefixsumsofthesequence A,definedby s0 =0and si = i t=1 at for 1 i n,arecomputableinlineartime.Define n +1pointsintheplanethus:
pi =(i,si ),0 ≤ i ≤ n.Thedensityofasegment A[i,j ]isthenequaltoslopeof thelinesegmentthroughthepoints pi 1 and pj .Thisreducesourproblemto findingasegment pi pj oflargestslope. Themainideaunderlyingthenewalgorithmistoconsidertherightend points pj (for U j n)ofallfeasiblesegments pi pj inbatchesofafixedsize. Foreach pj ,insteadofcomputingasinglelowerconvexhullofthefeasibleset ofleftpoints pi ,wecomputetwolowerconvexhulls-aleftoneandarightone. Thesestartat2adjacentpoints pm 1 and pm , j U +1 m j L +1,going leftandrightrespectively.Therightlowerhullsarecomputedincrementallyin aleft-to-right(LR)passforabatchedset pj ,andthelefthullsinaright-toleft(RL)passforthesamebatchedset.Thispre-emptsadynamicconvexhull updateproblemthatarisesinKim’salgorithm[9].Notethatthepoints pj with L ≤ j ≤ U 1canbehandledinasingleLRpass.Thecorrectnessofthisscheme followsfromthefollowingobservation:
Observation1. Forapoint pj ,U j n, let Gj bethesetofthecandidate leftendpoints pi ofallfeasiblesegments.If Gj 1 and Gj 2 areany2subsetsof Gj suchthat Gj = Gj 1 ∪ Gj 2 , then
Weconsidertherightendpoints pj , j U ,inbatchesofsize U L +1. Thedetailsofthe LR and RL passesforabatchofrightendpoints pj , j ∈ [k,k + U L], k U ,aredescribedbelow.
2.1LRPass
Inthispass,weprocesstherightendpoints pj , j ∈ [k,k + U L],lefttoright. Foreachnewpoint pj , j ∈ [k,k + U L],thecurrentLowerConvexHull(LCH) Hr isdynamicallyupdatedbytheinsertionofanewpointontherightof Hr FollowingKim[9],wemaintain2parameterstoaidtheincrementalcomputation: atangentline l tothecurrenthull Hr withthemaximumslopefoundsofar,and thepointofcontact α of l with Hr .Theline l isalwaysrepresentedbyapairof pointsanditsslopeisthecurrentmaximumdensityforthisbatchofpoints pj . Initially, Hr = {pk L }, l = pk L pk and α = pk L .Assumethat Hr , l and α havebeencomputedfortherightendpoint pj .Forthenextpoint pj +1 ,theseare updatedasfollows. Hr isresetto Hr = LCH (Hr ,pj +1 L ).Theupdated Hr is traversedcounterclockwisefrom α (orfromthenewlyinsertedhullpoint pj +1 L , if α hasbeendeletedfrom Hr )tofindthenewtangentline l ofmaximumslope sofar,andthenewpointofcontact α on Hr withtheupdated l .Wehaveto consider4cases:
Case1: Both pj +1 L and pj +1 areabove l Hr isfirstupdatedandthentraversedcounterclockwisefromthecurrent α tothepointofcontactofthetangentfrom pj +1 to Hr .Thistangentline anditspointofcontactaresettobethenew l and α respectively.
Case2: pj +1 L isabove,and pj +1 isonorbelow l . Hr isupdated.However, α and l remainunchanged.
Case3: pj +1 L isonorbelow l Hr isupdated.Let l bealinethrough pj +1 L andparallelto l .Let pj +1 be above l ;reset l = pj +1 L pj +1 and α = pj +1 L
Case4: pj +1 L isonorbelow l ,and pj +1 isonorbelow l . Hr isupdated.Set l to l and α = pj +1 L .
Eachpointintheleftwindow {pk L ,pk +1 L ,...,pk +U 2L } isaddedtoan Hr once,anddeletedatmostoncefromasubsequent Hr .Notingthat α never movesleft,foranewpoint pj ,if α remainsstationary(asinCase2above),the costofcomputationisconstantandischargedtothepoint pj L thatisaddedto thehull.Considerthecaseinwhich α movescounterclockwise(andthusright) alonganupdatedhull Hr .Eachpointon Hr isaccessedatmostonceduring therecomputationof α,sinceitnevermovesleft.Thecostofrecomputing α is chargedtothehullpointsthatarepassedoveraswemovecounterclockwiseon Hr fromthecurrent α,andthecostofdeletingthepointson Hr ontheleftof α arechargedtothem.Thus,eachpoint pi intheleftwindowischargedatmost3 times:2timesforinsertionintoanddeletionfrom Hr andonceforbeingpassed overby α.So,thecostforthispassislinearinthenumberof pj ’sconsidered.
2.2RLPass
Inthispass,weprocesstherightendpoints pj , j ∈ [k,k + U L 1],rightto left.Foreachnewpoint pj , j ∈ [k,k + U L 1],thecurrentLowerConvex Hull(LCH) Hl isdynamicallyupdatedbytheinsertionofanewpoint pj U on theleftof Hr
AsintheLRpass,wemaintainatangentline l andthepointofcontact α of l withthecurrenthull Hl toaidtheincrementalcomputation.
Initially, Hl = {pk L 1 }, l = pk L 1 pk +U L 1 and α = pk L 1 .Assume that Hl , l and α havebeenupdatedfortherightendpoint pj .Forthenext rightendpoint pj 1 ,theseareupdatedasfollows. Hl isupdatedbyinserting thepoint pj 1 U ontheleftsothat Hl = LCH (pj 1 U ,Hl ).Theupdated Hl is traversedcounterclockwisefrom α (orfromthenewlyinsertedhullpoint pj 1 U -if α isdeletedfrom Hl )tofindthenewtangentline l havingthemaximum slopefoundsofar,andthenewpointofcontact α on Hl withtheupdated l . Again,thereare4casestoconsider:
Case1: pj 1 U isonorabove l ,and pj 1 isabove l . Hl isupdated.Wetraverse Hl counterclockwisefrom α tofindatangentto itfrom pj 1 .Wereset l tothistangentlineand α tothepointofcontact betweenupdated l and Hl
Case2: pj 1 U isonorabove l ,and pj 1 isonorbelow l . Hl isupdated.However, α and l remainunchanged.
Case3: pj 1 U isbelow l Hl isupdated.Let l bealinethrough pj 1 U andparallelto l .Let pj 1 be above l
Another random document with no related content on Scribd: