1 / 15

School of Computing Clemson University Fall, 2013

Sweep Line Algorithms, Problem Visualization, Etc. CpSc 212: Algorithms and Data Structures Brian C. Dean. School of Computing Clemson University Fall, 2013. Warm-Up.

abrodersen
Download Presentation

School of Computing Clemson University Fall, 2013

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sweep Line Algorithms, Problem Visualization, Etc. CpSc 212: Algorithms and Data Structures Brian C. Dean School of Computing Clemson University Fall, 2013

  2. Warm-Up • You are told the locations of N houses on a long one-dimensional street, along with the quality of candy each one gives out on Halloween. • Where should you start “trick-or-treating” so that you maximize the total candy quality within a one-mile radius of your starting point? 9 4 6 7

  3. Warm-Up • You are told N intervals on the number line, each with an associated value. • Find a point of maximum overlap (i.e., maximizing the sum of interval values overlapping at that point). 9 4 6 7

  4. A “Sweep Line” Approach • You are told N intervals on the number line, each with an associated value. • Find a point of maximum overlap (i.e., maximizing the sum of interval values overlapping at that point). 9 4 6 7

  5. Give N rectangular buildings sharing a common base, find the area of the “skyline” they form. Sweep line + binary heap (or balanced BST). N inserts, N deletes, 2N find-max: O(N log N) Example: The Skyline Problem

  6. Counting Intersection Points Among Axially-Aligned Segments

  7. Counting Intersection Points Among Axially-Aligned Segments 1, 3, 5, 7 7 5 3 1 • Sweep line on x + balanced BST of “active” horizontal segments, keyed on y. • ≤ 2N inserts, ≤ 2N deletes, ≤ N range counting queries: O(N log N)

  8. Non-Dominated Points

  9. Non-Dominated Points • Reverse sweep line on x + running max on y. • O(N log N)

  10. Non-Dominated Points • Forward sweep line on x + balanced BST on y. • N inserts, ≤ N deletes: O(N log N)

  11. Given a set of points in 2D, compute the “domination count” for each point. Given N intervals on the number line, compute for each one the number of intervals contained within it. Count the number of crossings to the right… Three Interesting Problems 13 3 1 2 2 3 3 4 4 1

  12. Visualizing Problems Graphically b a b c a a2 + b2 = c2 sum of first n odd numbers = n2

  13. Robot Arms, Databases, and “Parameter Space” • Suppose a robot arm has 4 movable joints, each with one degree of freedom. You want to move the arm from its current state to a new “goal” state, where certain joint configurations are not valid.  path finding in a 4D space. • Consider a database of N records where each contains fields (height, age, income).  set of points in 3D space.

  14. Ballroom Matching • You are given the height and weight of N boys and N girls. • In a ballroom matching class, you want to match each girl with a boy who is taller and heavier than he is (to allow for easy lifts). • How quickly can you determine a valid matching between the boys and girls (or that none exists)?

  15. Pumpkin Catching • You are told when and where N pumpkins will fall from a pumpkin tree onto a number line. (e.g., “Pumpkin #1 lands at time t = 4 at the point x = 5). • You are also told where your N friends are standing on the number line at time t = 0. • Each friend can move at one unit of distance per second and can catch at most one pumpkin (they are heavy, after all!) • Can your team catch all the pumpkins?

More Related