Sample Midterm Exam, Computational Geometry, 2011 1. Short answer (2 points each, 12 points total) (a) Draw a picture of a simple polygon and a set of guards, such that the guards can see every point on every edge of the polygon, but the guards cannot see every point in the interior of the polygon. (b) Recall the primitive LeftTurn(a, b, c), which, given three points in the plane, returns TRUE if the points are ordered counterclockwise, and false otherwise. Show how to use this primitive (one or more times) to determine whether a point d lies within the interior of the triangle defined by the points a, b, and c. (You may assume that a, b, and c are oriented counterclockwise.) (c) Let P be a point set consisting of n points (p1 , p2 , p3 , . . .), given in an arbitrary order, in general position on the plane. Give the best bound possible (in big-Oh notation) for algorithms that answer the following questions. Explicitly define any other parameters you need in your answer. (Justify your answers to each with 1-2 sentences). i. Determine if the convex hull of P is a triangle. ii. Calculate the area of the convex hull of P. iii. Determine if the polygonal chain connecting the points in order (p1 , p2 , p3 , . . . pn ) intersects itself. (d) The number of different ways to triangulate a convex polygon with n-sides is (circle your answer): 1, 2, n, O(n) but not exactly n, greater than O(n). 1 2. (12 points) This problems considers and incremental algorithm to create the convex hull. Suppose that before the insertion of the i-th point, the convex hull has h points, sorted in clockwise order, c1 , c2 , c3 , . . . , ch . (a, 4 points ) To think about adding pi , we first need to determine if it is inside or outside the convex hull. Give an O(logh) algorithm to determine if pi is inside the hull or not. Half credit given for a correct O(h) algorithm. (b, 4 points ) Argue that your algorithm is correct, in both the case where pi is inside the hull, and the case where it is outside the hull. (c, 4 points ) If the point is outside the hull, give an O(h) algorithm to fix the hull so that it is correctly represents the hull of points c1 , c2 , c3 , . . . , ch , pi . 2 3. Monotone Chains (4 points) (a) You are given two x-monotone polygonal chains P and Q with a total of n vertices between then. Prove that P and Q can intersect at most O(n) times. (4 points) (b) Does the bound proved in (a) still apply if the two polygonal chains that are monotone with respect to different directions (e.g., one monotone with respect to x and the other monotone with respect to y)? Justify your answer. 3 4. You are given a collection of vertical line segments in the first quadrant of the x, y plane. Each line segment has one endpoint on the x-axis and the other endpoint has a positive y-coordinate. Imagine that from the top of each segment a horizontal bullet is shot to the left. The problem is to determine the index of the segment that is first hit by each of these bullet paths. If no segment is hit, return the index 0. (See the figure below.) The input is a sequence of top endpoints of each segment pi = (xi , yi ), for 1 ≤ i ≤ n, which are sorted in increasing order by x-coordinate. The output is the sequence of indices, one for each segment. Present an O(n) time algorithm to solve this problem. Explain how your algorithm works and justify its running time. 4
© Copyright 2024