8 views

Uploaded by djoseph_1

from MIT OCW

save

- CS1325-F16-HW6-1(1).pdf
- InsertionSort
- DS Lec 16 Heap
- Rr210301 Data Structures Through c
- Complexity Python
- Insertion Sort Bubble Sort Selection Sort
- Unplugged Activity
- Design and Analysis of Algorithms - VTU Life [20ebooks.com]
- final.pdf
- 702_present.ppt
- 29a63c1475ec19b0ff5b5ce9c9f91e37_6884742ec2317fb8fa2c54248b863d7b
- B6803A16(1)
- Data Structure
- 102 Syllabus BCA Programme Details
- Problem Solving and Python Programming - 2 Marks
- Algorithm Ch6 Heapsort
- CreateSpace.Elements.of.Programming.Interviews.in.Java.The.Insiders.Guide.2nd.Edition.1517435803.pdf
- Computer Science Paper 2 Final Revision Questions - 2017
- Algorithm - Flowchart
- Lesson 1 .1 - Introduction
- Polygon
- Principles of Programming
- Circle Puzzles
- AIME2004A
- Towards tolerating faults by triple modular redundancy
- Como ponerla en Tinder
- Intro to Programming1
- Heap Sort
- Radical Axis
- ronilyn aquino first written formal observation
- MIT6_851S12_ps2sol
- MIT21M_030S13_exam2review
- MIT6_851S12_ps5
- MIT9_85F12_brochureblank
- MIT9 85F12 Cr Guidelines
- MIT9 85F12 Cr Tips
- MIT6_851S12_ps3sol
- MIT9 85F12 Brochure
- MIT9 85F12 Final Project
- MIT9 85F12 Proposal
- MIT6_851S12_ps4sol
- MIT6_851S12_ps4
- MIT6_851S12_ps3
- MIT21M_030S13_exam1review
- MIT9 85F12 Practicum
- MIT6_851S12_ps6
- MIT6_851S12_ps9
- MIT6_851S12_ps1
- MIT6_851S12_ps10sol
- MIT6_851S12_ps10
- MIT6_851S12_ps8
- MIT6_851S12_ps6sol
- MIT6_851S12_ps7sol
- MIT6_851S12_ps2
- MIT6_851S12_ps8sol
- MIT6_851S12_ps7
- MIT17_871S12_Intro
- MIT6_851S12_ps1s
- MIT6_851S12_ps9sol

You are on page 1of 2

Erik Demaine Problem 5 Sample solution

Orthogonal line segment intersection. We can solve this problem using distribution sweeping in the same manner as we solved batched orthogonal range searching in lecture. However, an even simpler approach is to reduce this problem directly to batched orthogonal range searching, which N takes O( N B logM/B B ) time. Our set of points will be the endpoints of the vertical endpoints, and we will have one query rectangle for each horizontal segment. A horizontal segment with endpoints (x1 , y ) and (x2 , y ) will correspond to a rectangle with vertices (x1 , y ), (x2 , y ), (x2 , ∞), and (x1 , ∞). Any vertical segment intersecting a rectangle will have its top end point inside the corresponding rectangle and its bottom end point outside the corresponding segment. Furthermore, if a vertical segment’s bottom end point is contained by a rectangle, then its top end point must also be. Thus, for a given rectangle, if a is the number of top end points it contains, and b is the number of bottom end points it contains, a − b vertical segments intersect the corresponding horizontal segment. Line segment visibility from a point. There are three simple solutions to this problem:

1. The standard non-external memory algorithm for this problem is a sweep line algorithm. First sort the points by their angle to p. Then walk around the points in sorted order, maintaining a priority queue of the line segments currently intersected by the sweep line, sorted by distance from p. The priority queue tells us exactly which line segment is visible at any point. This algorithm easily extends to the cache-oblivious external memory model because we have a cache-oblivious priority queue and sorting algorithm that achieve the desired bounds. 2. We can use a distribution sweeping algorithm with no presorting in which we lazy funnel sort over the angle to p. At each stage, we output the (partial) line segments visible to p from the set of segments in the given range. The key insight is that when merging two such sets, at most two line segments overlap at any point (since there is no overlap within each set) thus we can essentially perform the sweep line algorithm without a priority queue, as the size of the priority queue would always be at most two. 3. We can use a distribution sweeping algorithm analogous to batched orthogonal range searching, in which we sort the points by angle to p, and then lazy funnel sort over the distance to p.

1

mit.MIT OpenCourseWare http://ocw.edu/terms.edu 6. . visit: http://ocw.mit.851 Advanced Data Structures Spring 2012 For information about citing these materials or our Terms of Use.

- CS1325-F16-HW6-1(1).pdfUploaded byNah Blah
- InsertionSortUploaded byMuhammad Junaid Anjum
- DS Lec 16 HeapUploaded bywilliamsock
- Rr210301 Data Structures Through cUploaded bySRINIVASA RAO GANTA
- Complexity PythonUploaded byAbdullah
- Insertion Sort Bubble Sort Selection SortUploaded byJether Pactol Tero
- Unplugged ActivityUploaded bypinocchio
- Design and Analysis of Algorithms - VTU Life [20ebooks.com]Uploaded byrsi127287
- final.pdfUploaded byAmudhan Kandasame
- 702_present.pptUploaded byJohn Michael Bayocot
- 29a63c1475ec19b0ff5b5ce9c9f91e37_6884742ec2317fb8fa2c54248b863d7bUploaded byalgo_tn
- B6803A16(1)Uploaded byAnkush Sharma
- Data StructureUploaded byPoonal Asas
- 102 Syllabus BCA Programme DetailsUploaded byoptimistic_harish
- Problem Solving and Python Programming - 2 MarksUploaded byvignesh
- Algorithm Ch6 HeapsortUploaded bymao
- CreateSpace.Elements.of.Programming.Interviews.in.Java.The.Insiders.Guide.2nd.Edition.1517435803.pdfUploaded byKun
- Computer Science Paper 2 Final Revision Questions - 2017Uploaded bybrighton
- Algorithm - FlowchartUploaded byகோபிநாத் நித்தியானந்தம்
- Lesson 1 .1 - IntroductionUploaded byMona Khan
- PolygonUploaded bylhadymhalditah_03
- Principles of ProgrammingUploaded byBassantMohamad
- Circle PuzzlesUploaded byrueljp5th
- AIME2004AUploaded bytheelectromaniac
- Towards tolerating faults by triple modular redundancyUploaded byDr Muhamma Imran Babar
- Como ponerla en TinderUploaded byRodrigo Ferreyra
- Intro to Programming1Uploaded byradebp
- Heap SortUploaded byVimal Prakash
- Radical AxisUploaded byksr131
- ronilyn aquino first written formal observationUploaded byapi-241358660

- MIT6_851S12_ps2solUploaded bydjoseph_1
- MIT21M_030S13_exam2reviewUploaded bydjoseph_1
- MIT6_851S12_ps5Uploaded bydjoseph_1
- MIT9_85F12_brochureblankUploaded bydjoseph_1
- MIT9 85F12 Cr GuidelinesUploaded bydjoseph_1
- MIT9 85F12 Cr TipsUploaded bydjoseph_1
- MIT6_851S12_ps3solUploaded bydjoseph_1
- MIT9 85F12 BrochureUploaded bydjoseph_1
- MIT9 85F12 Final ProjectUploaded bydjoseph_1
- MIT9 85F12 ProposalUploaded bydjoseph_1
- MIT6_851S12_ps4solUploaded bydjoseph_1
- MIT6_851S12_ps4Uploaded bydjoseph_1
- MIT6_851S12_ps3Uploaded bydjoseph_1
- MIT21M_030S13_exam1reviewUploaded bydjoseph_1
- MIT9 85F12 PracticumUploaded bydjoseph_1
- MIT6_851S12_ps6Uploaded bydjoseph_1
- MIT6_851S12_ps9Uploaded bydjoseph_1
- MIT6_851S12_ps1Uploaded bydjoseph_1
- MIT6_851S12_ps10solUploaded bydjoseph_1
- MIT6_851S12_ps10Uploaded bydjoseph_1
- MIT6_851S12_ps8Uploaded bydjoseph_1
- MIT6_851S12_ps6solUploaded bydjoseph_1
- MIT6_851S12_ps7solUploaded bydjoseph_1
- MIT6_851S12_ps2Uploaded bydjoseph_1
- MIT6_851S12_ps8solUploaded bydjoseph_1
- MIT6_851S12_ps7Uploaded bydjoseph_1
- MIT17_871S12_IntroUploaded bydjoseph_1
- MIT6_851S12_ps1sUploaded bydjoseph_1
- MIT6_851S12_ps9solUploaded bydjoseph_1