Beruflich Dokumente
Kultur Dokumente
Algorithms
Schalk-Willem Krger 2009 Training Camp 1
presentation.start();
Bruteforce:O(N )tooslow
Initialize h (shortest distance found so far) with the distance between the first two points.
3
h = Euclidian distance between point 1 and 2 = 6.23 units
6.44 units
h
6.26 units
5.45 units
4.30 units
11
Setcontainssegmentsthatarecurrently
intersectingwiththesweepline.
12
Atanendingpointofalinesegment:
Deletesegmentfromset.
Neigboursarenowadjacent.Computetheirintersectionpoint(ifany)and
insertintopriorityqueue.
Atanintersectionpointoftwolinesegments:
Outputpoint.
Swappositionofintersectionsegmentsinset.
Theswappedsegmentshavenewneigboursnow.Insert/deleteintersecting
13
pointsfrompriorityqueue(ifneeded).
Setcontainsalltherectangles
thesweeplineiscrossing.
14
xbetweentwoadjacentverticalevents
Count: 1
16
Count: 2
17
Count: 3
18
Count: 2
19
Count: 1
20
Count: 0
21
Count: 1
22
Count: 0
23
24
25
Usebasicallythesamealgorithm
Horizontalboundaries:wherecountiszeroininner
loop.
26
27
Questions?
?
presentation.end();
28