CS 506: Assignments |
Homework
Problem 1: These are questions about the DCEL data structure discussed in class.
Problem 2: Generalize our segment intersection algorithm (the decision version only) so that it will be applicable to circles. (Note that two circles are not considered to intersect if one is properly nested within the other.) Hint: a crucial property of segments is that they are monotone with respect to the direction of sweep, whereas circles are not, so take measures to handle circles in such a way that the building blocks you use are in fact monotone with respect to the direction of sweep.
Problem 3: Design a sweepline algorithm for the following problem: given a set of non-intersecting segments in the plane and a point not on any of the segments, return (the index of) each segment that is visible from the given point. (A segment s is visible from a point P if and only if there exists a point Q on s such that the segment PQ does not intersect any segment other than s itself.) Your algorithm should run in O((nlogn)) time.
Solution available in HTML.
Problem 1: Use our line segment algorithm to solve the following problem: given a subdivision of the plane with a total of n line segments and given m points, report, for each point, which face (region) of the subdivision contains it. Your algorithm should run in O((m+n)log(m+n)) time.
Problem 2: The following is not a geometric algorithm, but a good first exercise in analyzing the expected running time of an algorithm. Consider the following algorithm for finding the minimum of a set:
procedure weird-minimum(A)
if |A| == 1 then
return x, the single element of A
else
pick uniformly at random an element of A, call it x
A' = A - {x}
x' = weird-minimum(A')
if x' <= x then
return x'
else
for each element y of A'
test (x <= y)
if false, halt and report error
return x
endif
endif
Set up and solve a recurrence relation describing the expected running
time of this procedure; incidentally, what is its worst-case running time?
Problem 3: Given a collection of halfplanes, a redundant halfplane is one that does not contribute an edge to the intersection of the halfplanes in the collection. Show that every redundant halfplane contains the intersection of some pair of halfplanes from the collection.
Solution available in HTML.
Problem 1: a simple polygon is called star-shaped
if there exists a point q in the interior of the polygon from which
every interior point is visible (that is, such that, for any point p
within the polygon, the segment pq does not cross the perimeter).
a. Show that, given a star-shaped polygon and its special point q,
we can store the polygon in such a way that the query "is point r=(x,y)
within the polygon" can be answered in O(log n) time.
b. What if the polygon is in fact star-shaped, but you have not been
given the special point q? How efficiently can a suitable value for q
be obtained?
Problem 2: A Voronoi diagram is really a proximity structure: one can use it to answer all sorts of proximity-related queries. Show that, given the Voronoi diagram, we can compute in O(nlogn) time the nearest neighbor of each site in the set of sites.
Problem 3: We mentioned that Voronoi diagrams and convex
hulls are closely related.
a. Show that, given the Voronoi diagram (as a DCEL inside a bounding
box), we can compute the convex hull of the set of sites in linear time,
in fact, in time linear in the size of the output.
b. Conclude that computing the Voronoi diagram takes Omega(nlogn) time
in the worst case in a comparison-based model of computation.
Solution available in HTML.
Problem 1: Adapt the notion of visibility graph to the case where obstacles are disks (of varying diameters). In particular, prove that the shortest path between two points consists of parts of boundaries of the disks, common tangents of discs, and/or tangents from the endpoints to disks; then appropriately define the visibility graph for such a situation; and finally verify that the O(nlogn) rotational sweep algorithm can easily be adapted to give all visibility edges from one vertex of the visibility graph.
Problem 2: You are given a planar partition into convex polygons (including unbounded polygons on the edges) and told that this partition is the Voronoi diagram of some set of points. Your job is to verify the claim (does there in fact exist a set of points for which this planar partition is the Voronoi diagram) and, as a bonus, return the list of sites in case the answer is yes. Design and analyze and algorithm to answer yes/no, then modify it (if necessary) to return the list of sites when the answer is yes.
Tests
Problem 1 (20pts): Show how to obtain the upper common tangent of two disjoint convex polygons in linear time. While you know that the two hulls are disjoint (share no point), which implies that there exists a line that can be passed between the two without intersecting either, you do not know what that line is. (In that sense, this problem is slightly more general than that encountered in the geometric divide-and-conquer algorithm for 2D convex hulls.) The hint remains the same: use the property that the single inflection point is an extremum in a convex chain to conduct nested binary searches, one on each hull.
Problem 2 (30pts): You are given two sets of points in the plane; each set forms a descending "staircase", in that the next element of the set has (strictly) larger abscissa and (strictly) smaller ordinate than the previous -- you can imagine that each point is the outer corner of a step of the staircase. You are given these sets sorted along the two staircases; you may assume that the two staircases do not cross. Design an algorithm that will quickly identify the closest pair (in terms of the L1 metric, sometimes called the Manhattan metric -- the sum of the absolute differences in abscissae and in ordinates) of points in your collection of points. (It is of course trivial to identify the closest pair on the same staircase, so the problem is to find the closest pair with one point on one staircase and the other point on the other staircase.) Can it be done in linear time? Does your answer change if the two staircases have no specific relationship to each other (e.g., they could cross and recross)?
Problem 3 (20pts): The randomized version of quicksort is one in which the partitioning element is chosen uniformly at random among the elements of the subarray to be partitioned. Consider instead a randomized incremental approach to the problem: we begin by shuffling the values, then we add one value at a time to the growing sorted list. (i) Provide a simple implementation for that idea and analyze its expected running time. (ii) In the randomized incremental version, how would you define a conflict and what would be conflict lists? Are you using them in your implementation? If not, could you, at the same expected cost? (iii) Relate the randomized incremental approach to randomized quicksort (which appears to have nothing incremental about it...)
Problem 4 (30pts): Design and analyze a randomized incremental algorithm for the intersection of halfplanes (to replace our divide-and-conquer deterministic algorithm). Your algorithm should maintain the current intersection figure at every step and use conflict lists between current vertices of the intersection and half-planes yet to be processed.
Solution available in HTML.
Grades ranged from a low of 45 to a high of 96; of the 12 exams turned in, 5 scored above 90, 2 above 80, 1 above 70, 2 (almost 3, really) above 60, plus the lone low score (mostly due to that student's having turned in only three problems -- otherwise it would have been in the previous group). You can roughly translate these into letter grades as follows: the top 5 are As, the next 3 are Bs, the next 3 are Cs, and the lone 45 is a fail. The semester grades should be higher, thanks to the grades on your projects.
| Back to CS 506 home page |