**Unformatted text preview: **COMP271H COMP271H
Tutorial 2 Maximal points problem Question – Math meaning Question Question – Geometric meaning Question
y-axis A point set S This is the maximal point among points in S
x-axis Define some terms Define
Q2 P Q3 Q4 Q Term 2: Q is invalidated by P QI P Term 1: Four areas Q1~Q4 Terms: P iis a maximal point if no other points lying in s Q1 Q1 If P is inside Q1 of Q, then Q is invalidated by If P How to tackle this problem? How Brute force For each point p, we check with all other For points. If p is not invalidated by any other point, then If report p as maximal point report
• Running time = O(N^2) Divide-and-conquer How to divide? How to conquer? How How to combine? (Most important!!) First thing to do First We first sort all points according to their x- coordinates Reason? Easier to divide points into two sets Sorting only takes O(nlogn) Do only once, at the very beginning Partial solutions look like….? Partial Observations Observations Assume two partial solutions are Assume sorted by increasing x-coordinates sorted The partial solutions should be in The decreasing order of y-coordinates decreasing Reason: If not, there is only a single Reason: item in the list item Impossible!! All points from the right list must All also appear in the combined solution solution Combine step Combine First thing to do Drops out maximal points (which are no Drops longer maximal in the combined solution) from the left partial solution the Ensures the combined solution is sorted in Ensures increasing x-coordinates increasing Second thing to do My solution My Further discussion Further Suppose we know in advance, there are Suppose only constant number of maximal points in our solution. Can we design a better algorithm to solve the problem? algorithm In our divide-and-conquer algorithm, no In matter how many maximal points are, we still need O(nlogn) time need How to devise a new algorithm to do the job? Q&A Any other questions? ...

View
Full Document

- Spring '10
- may
- English, Order theory, Divide and conquer algorithm, maximal points, maximal point