B
1
0.5
0.5
B
2
0.5
0.5
...
B
N/4
0.5
0.5
B
N/4+1
2/N
2/N
2/N
...
2/N
2/N
2/N 
Figure10.22 Optimalpackingfor0.5,2/N,0.5,2/N,0.5,2/N,...
B
1
0.5
2/N
empty
B
2
0.5
2/N
empty
...
B
N/2
0.5
2/N
empty
Figure10.23 Nextfitpackingfor0.5,2/N,0.5,2/N,0.5,2/N,...
B
1
0.2
0.5
0.1
empty
B
2
0.4
0.3
empty
B
3
0.7
empty
B
4
0.8
empty
Figure10.24 Firstfitfor0.2,0.5,0.4,0.7,0.1,0.3,0.8
Convert pdf into powerpoint online - C# Create PDF from PowerPoint Library to convert pptx, ppt to PDF in C#.net, ASP.NET MVC, WinForms, WPF
Online C# Tutorial for Creating PDF from Microsoft PowerPoint Presentation
how to convert pdf to ppt online; convert pdf file to powerpoint
Convert pdf into powerpoint online - VB.NET Create PDF from PowerPoint Library to convert pptx, ppt to PDF in vb.net, ASP.NET MVC, WinForms, WPF
VB.NET Tutorial for Export PDF file from Microsoft Office PowerPoint
how to convert pdf to ppt for; how to convert pdf to powerpoint slides
10.1 GreedyAlgorithms
463
Asimplemethodofimplementingfirstfitwouldprocesseachitembyscanningdown
thelistofbinssequentially.ThiswouldtakeO(N
2
).Itispossibletoimplementfirstfitto
runinO(NlogN);weleavethisasanexercise.
Amoment’sthoughtwillconvinceyouthatatanypoint,atmostonebincanbemore
thanhalfempty,sinceifasecondbinwerealsohalfempty,itscontentswouldfitintothe
firstbin.Thus,wecanimmediatelyconcludethatfirstfitguaranteesasolutionwithat
mosttwicetheoptimalnumberofbins.
Ontheotherhand,thebadcasethatweusedintheproofofnextfit’sperformance
bounddoesnotapplyforfirstfit.Thus,onemightwonderifabetterboundcanbeproven.
Theanswerisyes,buttheproofiscomplicated.
Theorem10.3
LetMbetheoptimalnumberofbinsrequiredtopackalistIofitems.Thenfirstfit
neverusesmorethan
17
10
M+
7
10
bins.Thereexistsequencessuchthatfirstfituses
17
10
(M−1)bins.
Proof
Seethereferencesattheendofthechapter.
Anexamplewherefirstfitdoesalmostaspoorlyastheprevioustheoremwouldindi-
cateisshowninFigure10.25.Theinputconsistsof6Mitemsofsize
1
7
+,followedby
6Mitemsofsize
1
3
+,followedby6Mitemsofsize
1
2
+.Onesimplepackingplacesone
itemofeachsizeinabinandrequires6Mbins.Firstfitrequires10Mbins.
When first fitisrun on alargenumber of items with sizes uniformly distributed
between0and1,empiricalresultsshowthatfirstfitusesroughly2percentmorebins
thanoptimal.Inmanycases,thisisquiteacceptable.
BestFit
Thethirdonlinestrategywewillexamineisbestfit.Insteadofplacinganewiteminthe
firstspotthatisfound,itisplacedinthetightestspotamongallbins.Atypicalpackingis
showninFigure10.26.
B
1
B
M
1/+ ε
1/+ ε
1/+ ε
1/+ ε
1/+ ε
1/+ ε
empty
...
B
M+1
B
4M
1/+ ε
1/+ ε
empty
...
B
4M+1
B
10M
1/+ ε
empty
Figure10.25 Acasewherefirstfituses10Mbinsinsteadof6M
Online Convert PowerPoint to PDF file. Best free online export
Convert a PPTX/PPT File to PDF. Just upload your file by clicking on the blue button or drag-and-drop your pptx or ppt file into the drop area.
adding pdf to powerpoint; convert pdf to ppt online without email
RasterEdge XDoc.PowerPoint for .NET - SDK for PowerPoint Document
Convert PowerPoint to ODP/ ODP to PowerPoint. Insert Pages into PowerPoint File. Download Free Trial Download and try PDF for .NET with online support.
picture from pdf to powerpoint; convert pdf file to powerpoint presentation
464
Chapter10 AlgorithmDesignTechniques
B
1
0.2
0.5
0.1
empty
B
2
0.4
empty
B
3
0.7
0.3
B
4
0.8
empty
Figure10.26 Bestfitfor0.2,0.5,0.4,0.7,0.1,0.3,0.8
Noticethattheitemofsize0.3isplacedinB
3
,whereitfitsperfectly,insteadofB
2
.
Onemightexpectthatsincewearenow makingamoreeducatedchoiceofbins,the
performanceguaranteewouldimprove.Thisisnotthecase,becausethegenericbadcases
arethesame.Bestfitisnevermorethanroughly1.7timesasbadasoptimal,andthere
areinputsforwhichit(nearly)achievesthisbound.Nevertheless,bestfitisalsosimple
tocode,especiallyifanO(NlogN)algorithmisrequired,anditdoesperformbetterfor
randominputs.
OfflineAlgorithms
Ifweareallowedtoviewtheentireitemlistbeforeproducingananswer,thenweshould
expecttodobetter.Indeed,sincewecaneventuallyfindtheoptimalpackingbyexhaustive
search,wealreadyhaveatheoreticalimprovementovertheonlinecase.
Themajorproblemwithalltheonlinealgorithmsisthatitishardtopackthelarge
items,especiallywhen they occurlatein theinput.Thenaturalway aroundthisisto
sorttheitems,placingthelargestitemsfirst.Wecanthenapplyfirstfitorbestfit,yield-
ingthealgorithmsfirstfitdecreasingandbestfitdecreasing,respectively.Figure10.27
B
1
0.8
0.2
B
2
0.7
0.3
B
3
0.5
0.4
0.1
Figure10.27 Firstfitfor0.8,0.7,0.5,0.4,0.3,0.2,0.1
C# PDF insert text Library: insert text into PDF content in C#.net
Able to add a single text character and text string to PDF files using online source codes in C#.NET class value, The char wil be added into PDF page, 0
convert pdf pages to powerpoint slides; convert pdf file to ppt online
XDoc.HTML5 Viewer for .NET, Zero Footprint AJAX Document Image
View, Convert, Edit, Sign Documents and Images. viewer library can be easily integrated into your ASP powerful & profession imaging controls, PDF document, image
change pdf to powerpoint; how to change pdf to powerpoint slides
10.1 GreedyAlgorithms
465
showsthatin ourcasethisyieldsanoptimalsolution (although,ofcourse,thisisnot
trueingeneral).
Inthissection,wewilldealwithfirstfitdecreasing.Theresultsforbestfitdecreas-
ingarealmostidentical.Since it is possiblethat theitemsizesare not distinct,some
authors prefertocallthe algorithmfirst fitnonincreasing. Wewill stay with theorigi-
nalname.Wewillalsoassume,without lossofgenerality,that input sizes arealready
sorted.
Thefirstremarkwecanmakeisthatthebadcase,whichshowedfirstfitusing10M
binsinsteadof6Mbins,doesnotapplywhentheitemsaresorted.Wewillshowthatif
anoptimalpackingusesMbins,thenfirstfitdecreasingneverusesmorethan(4M+1)/3
bins.
Theresultdependsontwoobservations.First,alltheitemswithweightlargerthan
1
3
willbeplacedinthefirstMbins.Thisimpliesthatalltheitemsintheextrabinshave
weightatmost
1
3
.Thesecondobservationisthatthenumberofitemsintheextrabinscan
beatmostM−1.Combiningthesetworesults,wefindthatatmost(M−1)/3extra
binscanberequired.Wenowprovethesetwoobservations.
Lemma10.1
LettheNitemshave(sortedindecreasingorder)inputsizess
1
,s
2
,...,s
N
,respectively,
andsupposethattheoptimalpackingisMbins.Thenallitemsthatfirstfitdecreasing
placesinextrabinshavesizeatmost
1
3
.
Proof
SupposetheithitemisthefirstplacedinbinM+1.Weneedtoshowthats
i
1
3
.We
willprovethisbycontradiction.Assumes
i
>
1
3
.
Itfollowsthats
1
,s
2
,...,s
i−1
>
1
3
,sincethesizesarearrangedinsortedorder.
FromthisitfollowsthatallbinsB
1
,B
2
,...,B
M
haveatmosttwoitemseach.
Considerthestateofthesystemafterthe(i−1)stitemisplacedinabin,butbefore
theithitemisplaced.Wenowwanttoshowthat(undertheassumptionthats
i
>
1
3
)
thefirstMbinsarearrangedasfollows:First,therearesomebinswithexactlyone
element,andthentheremainingbinshavetwoelements.
Supposethereweretwobins,B
x
andB
y
,suchthat1 ≤x<M,B
x
hastwo
items,andB
y
hasoneitem.Letx
1
andx
2
bethetwoitemsinB
x
,andlety
1
betheitem
inB
y
.x
1
y
1
,sincex
1
wasplacedintheearlierbin.x
2
≥ s
i
,bysimilarreasoning.
Thus,x
1
+x
2
y
1
+s
i
.Thisimpliesthats
i
couldbeplacedinB
y
.Byourassumption
thisisnotpossible.Thus,ifs
i
>
1
3
,then,atthetimethatwetrytoprocesss
i
,thefirst
MbinsarearrangedsuchthatthefirstjhaveoneelementandthenextMjhavetwo
elements.
ToprovethelemmawewillshowthatthereisnowaytoplacealltheitemsinM
bins,whichcontradictsthepremiseofthelemma.
Clearly,notwoitemss
1
,s
2
,...,s
j
canbeplacedinonebin,byanyalgorithm,since
iftheycould,firstfitwouldhavedonesotoo.Wealsoknowthatfirstfithasnotplaced
anyoftheitemsofsizes
j+1
,s
j+2
,...,s
i
intothefirstjbins,sononeofthemfit.Thus,in
anypacking,specificallytheoptimalpacking,theremustbejbinsthatdonotcontain
theseitems.Itfollowsthattheitemsofsizes
j+1
,s
j+2
,...,s
i−1
mustbecontainedin
C# PDF Convert to Tiff SDK: Convert PDF to tiff images in C#.net
with specified zoom value and save it into stream The magnification of the original PDF page size Description: Convert to DOCX/TIFF with specified resolution and
change pdf to powerpoint online; convert pdf to powerpoint online for
C# PDF File Split Library: Split, seperate PDF into multiple files
SharePoint. C#.NET control for splitting PDF file into two or multiple files online. Support to break a large PDF file into smaller files.
pdf to powerpoint slide; how to change pdf file to powerpoint
466
Chapter10 AlgorithmDesignTechniques
somesetofMjbins,andfrompreviousconsiderations,thetotalnumberofsuch
itemsis2(Mj).
1
Theproofiscompletedbynotingthatifs
i
>
1
3
,thereisnowayfors
i
tobeplaced
inoneoftheseMbins.Clearly,itcannotgoinoneofthejbins,sinceifitcould,then
firstfitwouldhavedonesotoo.ToplaceitinoneoftheremainingMjbinsrequires
distributing2(Mj)+1itemsintotheMjbins.Thus,somebinwouldhavetohave
threeitems,eachofwhichislargerthan
1
3
,aclearimpossibility.
ThiscontradictsthefactthatallthesizescanbeplacedinMbins,sotheoriginal
assumptionmustbeincorrect.Thus,s
i
1
3
.
Lemma10.2
ThenumberofobjectsplacedinextrabinsisatmostM−1.
Proof
AssumethatthereareatleastMobjectsplacedinextrabins.Weknowthat
N
i=1
s
i
M,sincealltheobjectsfitinMbins.SupposethatB
j
isfilledwithW
j
totalweightfor
1 ≤≤ M.SupposethefirstMextraobjectshavesizesx
1
,x
2
,...,x
M
.Then,since
theitemsinthefirstMbinsplusthefirstMextraitemsareasubsetofalltheitems,it
followsthat
N
i=1
s
i
M
j=1
W
j
+
M
j=1
x
j
M
j=1
(W
j
+x
j
)
NowW
j
+x
j
>1,sinceotherwisetheitemcorrespondingtox
j
wouldhavebeenplaced
inB
j
.Thus
N
i=1
s
i
>
M
j=1
1>M
ButthisisimpossibleiftheNitemscanbepackedinMbins.Thus,therecanbeat
mostM−1extraitems.
Theorem10.4
LetMbetheoptimalnumberofbinsrequiredtopackalistIofitems.Thenfirstfit
decreasingneverusesmorethan(4M+1)/3bins.
Proof
ThereareatmostM−1extraitems,ofsizeatmost
1
3
.Thus,therecanbeatmost
(M−1)/3extrabins.Thetotalnumberofbinsusedbyfirstfitdecreasingisthusat
most(4M−1)/3≤(4M+1)/3.
Itispossibletoproveamuchtighterboundforbothfirstfitdecreasingandnextfit
decreasing.
1
RecallthatfirstfitpackedtheseelementsintoMjbinsandplacedtwoitemsineachbin.Thus,thereare
2(Mj)items.
VB.NET PDF File Split Library: Split, seperate PDF into multiple
Split PDF file into two or multiple files in ASP.NET webpage online. Support to break a large PDF file into smaller files in .NET WinForms.
how to convert pdf to powerpoint; how to convert pdf to ppt
C# PDF Page Insert Library: insert pages into PDF file in C#.net
from the ability to inserting a new PDF page into existing PDF or pages from various file formats, such as PDF, Tiff, Word, Excel, PowerPoint, Bmp, Jpeg
conversion of pdf to ppt online; convert pdf into powerpoint
10.2 DivideandConquer
467
B
1
B
6k
+
4
B
6k
+
5
9k
+
6
B
B
6k
+
5
8k
+
5
B
B
8k
+
7
11k
+
7
B
11k
+
8
B
8k
+
6
B
Optimal
First Fit Decreasing
1/4 − 2ε
1/4 − 2ε
1/4 − 2ε
1/4 − 2ε
empty
1/4 − 2ε
1/4 + ε
1/4 − 2ε
1/4 − 2ε
1/4 − 2ε
1/2 + ε
1/4 + ε
1/4 − 2ε
1/4 + ε
1/4 + ε
1/4 + ε
empty
B
1
B
6k
+
4
1/2 + ε
1/4 + 2ε
empty
1/4 + 2ε
1/4 + 2ε
1/4 − 2ε
1/4 − 2ε
Figure10.28 Examplewherefirstfitdecreasinguses11k+8bins,butonly9k+6bins
arerequired
Theorem10.5
LetMbetheoptimalnumberofbinsrequiredtopackalistIofitems.Thenfirstfit
decreasingneverusesmorethan
11
9
M+
6
9
bins.Thereexistsequencessuchthatfirst
fitdecreasinguses
11
9
M+
6
9
bins.
Proof
Theupperboundrequiresaverycomplicatedanalysis.Thelowerboundisexhibited
byasequenceconsistingof6k+4elementsofsize
1
2
+,followedby6k+4elements
ofsize
1
4
+2,followedby6k+4elementsofsize
1
4
+,followedby12k+8elements
ofsize
1
4
−2.Figure10.28showsthattheoptimalpackingrequires9k+6bins,but
firstfitdecreasinguses11k+8bins.SetM=9k+6,andtheresultfollows.
Inpractice,firstfitdecreasingperformsextremelywell.Ifsizesarechosenuniformly
overtheunitinterval,thentheexpectednumberofextrabinsis(
M).Binpackingisa
fineexampleofhowsimplegreedyheuristicscangivegoodresults.
10.2 DivideandConquer
Anothercommontechniqueusedtodesignalgorithmsisdivideandconquer.Divide-and-
conqueralgorithmsconsistoftwoparts:
Divide:Smallerproblemsaresolvedrecursively(except,ofcourse,basecases).
Conquer:Thesolutiontotheoriginalproblemisthenformedfromthesolutionstothe
subproblems.
Traditionally,routinesinwhichthetextcontainsatleasttworecursivecallsarecalled
divide-and-conqueralgorithms,whileroutineswhosetextcontainsonlyonerecursivecall
468
Chapter10 AlgorithmDesignTechniques
arenot.Wegenerallyinsistthatthesubproblemsbedisjoint(thatis,essentiallynonover-
lapping).Letusreviewsomeoftherecursivealgorithmsthathavebeencoveredinthis
text.
Wehavealreadyseenseveraldivide-and-conqueralgorithms.InSection2.4.3,wesaw
anO(NlogN)solutiontothemaximumsubsequencesumproblem.InChapter4,wesaw
linear-timetreetraversalstrategies.InChapter7,wesawtheclassicexamplesofdivideand
conquer,namelymergesortandquicksort,whichhaveO(NlogN)worst-caseandaverage-
casebounds,respectively.
Wehavealsoseenseveralexamplesofrecursivealgorithmsthatprobablydonotclas-
sifyasdivide-and-conquer,butmerelyreducetoasinglesimplercase.InSection1.3,we
sawasimpleroutinetoprintanumber.InChapter2,weusedrecursiontoperformeffi-
cientexponentiation.InChapter4,weexaminedsimplesearchroutinesforbinarysearch
trees.InSection6.6,wesawsimplerecursionusedtomergeleftistheaps.InSection7.7,
analgorithmwasgivenforselectionthattakeslinearaveragetime.Thedisjointset
find
operationwaswrittenrecursivelyinChapter8.Chapter9showedroutinestorecoverthe
shortestpathinDijkstra’salgorithmandotherprocedurestoperformdepth-firstsearchin
graphs.Noneofthesealgorithmsarereallydivide-and-conqueralgorithms,becauseonly
onerecursivecallisperformed.
We have also seen,in Section 2.4,a very y bad recursive e routine to compute the
Fibonaccinumbers.Thiscouldbecalledadivide-and-conqueralgorithm,butitisterribly
inefficient,becausetheproblemreallyisnotdividedatall.
Inthissection,wewillseemoreexamplesofthedivide-and-conquerparadigm.Our
firstapplicationisaproblemincomputationalgeometry.GivenNpointsinaplane,we
willshowthattheclosestpairofpointscanbefoundinO(NlogN)time.Theexercises
describesomeotherproblemsincomputationalgeometrywhichcanbesolvedbydivide
andconquer.Theremainderofthesectionshowssomeextremelyinteresting,butmostly
theoretical,results.WeprovideanalgorithmthatsolvestheselectionprobleminO(N)
worst-casetime.Wealsoshowthat2N-bitnumberscanbemultipliedino(N
2
)operations
andthattwoN×Nmatricescanbemultipliedino(N
3
)operations.Unfortunately,even
thoughthesealgorithmshavebetterworst-caseboundsthantheconventionalalgorithms,
nonearepracticalexceptforverylargeinputs.
10.2.1 RunningTimeofDivide-and-ConquerAlgorithms
Alltheefficientdivide-and-conqueralgorithmswewillseedividetheproblemsintosub-
problems,eachofwhichissomefractionoftheoriginalproblem,andthenperformsome
additionalworktocomputethefinalanswer.Asanexample,wehaveseenthatmerge-
sortoperatesontwoproblems,eachofwhichishalfthesizeoftheoriginal,andthen
usesO(N)additionalwork.Thisyieldstherunning-timeequation(withappropriateinitial
conditions)
T(N)=2T(N/2)+O(N)
WesawinChapter7thatthesolutiontothisequationisO(NlogN).Thefollowingtheorem
canbeusedtodeterminetherunningtimeofmostdivide-and-conqueralgorithms.
10.2 DivideandConquer
469
Theorem10.6
ThesolutiontotheequationT(N)=aT(N/b)+(N
k
),wherea≥1andb>1,is
T(N)=
O(N
log
b
a
)
ifa>b
k
O(N
k
logN) ifa=b
k
O(N
k
)
ifa<b
k
Proof
FollowingtheanalysisofmergesortinChapter7,wewillassumethatNisapowerof
b;thus,letN=bm.ThenN/b=bm−1 andNk=(bm)
k
=bmk =bkm=(bk)m.Letus
assumeT(1)=1,andignoretheconstantfactorin(N
k
).Thenwehave
T(b
m
)=aT(b
m−1
)+(b
k
)
m
Ifwedividethroughbya
m
,weobtaintheequation
T(b
m
)
am
=
T(b
m−1
)
am−1
+
b
k
a
m
(10.3)
Wecanapplythisequationforothervaluesofm,obtaining
T(b
m−1
)
am−1
=
T(b
m−2
)
am−2
+
b
k
a
m−1
(10.4)
T(bm−2)
am−2
=
T(bm−3)
am−3
+
bk
a
m−2
(10.5)
.
.
.
T(b
1
)
a1
=
T(b
0
)
a0
+
b
k
a
1
(10.6)
Weuseourstandard trickofadding upthe telescoping equations(10.3)through
(10.6).Virtuallyallthetermsontheleftcanceltheleadingtermsontheright,yielding
T(b
m
)
am
=1+
m
i=1
b
k
a
i
(10.7)
=
m
i=0
bk
a
i
(10.8)
Thus
T(N)=T(b
m
)=a
m
m
i=0
b
k
a
i
(10.9)
470
Chapter10 AlgorithmDesignTechniques
Ifa>b
k
,thenthesumisageometricserieswithratiosmallerthan1.Sincethesum
ofinfiniteserieswouldconvergetoaconstant,thisfinitesumisalsoboundedbya
constant,andthusEquation(10.10)applies:
T(N)=O(a
m
)=O(a
log
b
N
)=O(N
log
b
a
)
(10.10)
Ifa=b
k
,theneachterminthesumis1.Sincethesumcontains1+log
b
Ntermsand
a=b
k
impliesthatlog
b
a=k,
T(N)=O(a
m
log
b
N)=O(N
log
b
a
log
b
N)=O(N
k
log
b
N)
=O(N
k
logN)
(10.11)
Finally,ifb
k
,thenthetermsinthegeometricseriesarelargerthan1,andthe
secondformulainSection1.2.3applies.Weobtain
T(N)=a
m
(bk/a)m+1−1
(bk/a)−1
=O(a
m
(b
k
/a)
m
)=O((b
k
)
m
)=O(N
k
)
(10.12)
provingthelastcaseofthetheorem.
Asanexample,mergesorthasa=b=2andk=1.Thesecondcaseapplies,giving
theanswerO(NlogN).Ifwesolvethreeproblems,eachofwhichishalftheoriginalsize,
andcombinethesolutionswithO(N)additionalwork,thena=3,b=2,andk=1.Case
1applieshere,givingaboundofO(N
log
2
3
)=O(N
1.59
).Analgorithmthatsolvedthree
half-sizedproblems,butrequiredO(N
2
)worktomergethesolution,wouldhaveanO(N
2
)
runningtime,sincethethirdcasewouldapply.
TherearetwoimportantcasesthatarenotcoveredbyTheorem10.6.Westatetwo
moretheorems,leaving theproofsasexercises.Theorem10.7generalizes theprevious
theorem.
Theorem10.7
ThesolutiontotheequationT(N)=aT(N/b)+(Nklog
p
N),wherea≥1,b> 1,
andp≥0is
T(N)=
O(N
log
b
a
)
ifa>b
k
O(N
k
log
p+1
N) ifa=b
k
O(N
k
log
p
N)
ifa<b
k
Theorem10.8
If
k
i=1
α
i
<1,thenthesolution totheequationT(N) =
k
i=1
T
i
N)+O(N)is
T(N)=O(N).
10.2.2 Closest-PointsProblem
The input toour first problem is alist of points in aplane.Ifp
1
= (x
1
,y
1
)and
p
2
=(x
2
,y
2
),thentheEuclideandistancebetweenp
1
andp
2
is[(x
1
x
2
)
2
+(y
1
y
2
)
2
]
1/2
.
10.2 DivideandConquer
471
Wearerequiredtofindtheclosestpairofpoints.Itispossiblethattwopointshavethe
sameposition;inthatcase,thatpairistheclosest,withdistancezero.
IfthereareNpoints,thenthereareN(N−1)/2pairsofdistances.Wecancheckall
ofthese,obtainingaveryshortprogram,butattheexpenseofanO(N2)algorithm.Since
thisapproachisjustanexhaustivesearch,weshouldexpecttodobetter.
Letusassumethatthepointshavebeensortedbyxcoordinate.Atworst,thisadds
O(NlogN)tothefinaltimebound.SincewewillshowanO(NlogN)boundfortheentire
algorithm,thissortisessentiallyfree,fromacomplexitystandpoint.
Figure10.29showsasmallsamplepointset,P.Sincethepointsaresortedbyxcoor-
dinate,wecandrawanimaginaryverticallinethatpartitionsthepointsetintotwohalves,
P
L
andP
R
.Thisiscertainlysimpletodo.Nowwehavealmostexactlythesamesituation
aswesawinthemaximumsubsequencesumprobleminSection2.4.3.Eithertheclosest
pointsarebothinP
L
,ortheyarebothinP
R
,oroneisinP
L
andtheotherisinP
R
.Letus
callthesedistancesd
L
,d
R
,andd
C
.Figure10.30showsthepartitionofthepointsetand
thesethreedistances.
Wecancomputed
L
andd
R
recursively.Theproblem,then,istocomputed
C
.Sincewe
wouldlikeanO(NlogN)solution,wemustbeabletocomputed
C
withonlyO(N)addi-
tionalwork.Wehavealreadyseenthatifaprocedureconsistsoftwohalf-sizedrecursive
callsandO(N)additionalwork,thenthetotaltimewillbeO(NlogN).
Letδ = = min(d
L
,d
R
).Thefirstobservationisthatweonlyneedtocomputed
C
ifd
C
improvesonδ.Ifd
C
issuchadistance,thenthetwopointsthatdefined
C
mustbewithin
δofthedividingline;wewillrefertothisareaasastrip.As shownin Figure10.31,
this observationlimits thenumber ofpointsthatneed tobeconsidered(in ourcase,
δ=d
R
).
Therearetwostrategiesthatcanbetriedtocomputed
C
.Forlargepointsetsthatare
uniformlydistributed,thenumberofpointsthatareexpectedtobeinthestripisvery
small.Indeed,itiseasytoarguethatonlyO(
N)pointsareinthestriponaverage.Thus,
wecouldperformabrute-forcecalculationonthesepointsinO(N)time.Thepseudocode
Figure10.29 Asmallpointset
Documents you may be interested
Documents you may be interested