



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Starting with Homework 1, homeworks may be done in teams of up to three people. Each team turns in just one solution, and every member of a team gets the same grade. Since 1-unit graduate students are required to solve problems that are worth extra credit for other students, 1-unit grad students may not be on the same team as 3/4-unit grad students or undergraduates.
Neatly print your name(s), NetID(s), and the alias(es) you used for Homework 0 in the boxes above. Please also tell us whether you are an undergraduate, 3/4-unit grad student, or 1-unit grad student by circling U, 3 / 4 , or 1, respectively. Staple this sheet to the top of your homework.
(a) (4 pts) Show that when n mod 3 = 0 or 2, we must examine every bit in the array. that is, give an adversary strategy that forces any algorithm to examine every bit when n = 2, 3 , 5 , 6 , 8 , 9 ,.... (b) (4 pts) Show that when n = 3k + 1, we only have to examine n − 1 bits. That is, describe an algorithm that finds two consecutive 1s or correctly reports that there are none after examining at most n − 1 bits, when n = 1, 4 , 7 , 10 ,.... (c) (2 pts) How many n-bit strings are there with two consecutive ones? For which n is this number even or odd?
The staircase of a set of points. Maximal points are black.
(a) (0 pts) Prove that maximal points are not necessarily on the convex hull. (b) (6 pts) Give an O(n log n) algorithm to find the maximal points. (c) (4 pts) Assume that points are chosen uniformly at random within a rectangle. What is the average number of maximal points? Justify. Hint: you will be able to give an exact answer rather than just asymptotics. You have seen the same analysis before.
A set of points with four convex layers.
(a) Intersection: Extend the basic algorithm to determine if two line segments intersect by taking care of all degenerate cases. (b) Simplicity: Give an O(n log n) algorithm to determine whether an n-vertex polygon is simple. (c) Area: Give an algorithm to compute the area of a simple n-polygon (not necessarily convex) in O(n) time. (d) Inside: Give an algorithm to determine whether a point is within a simple n-polygon (not necessarily convex) in O(n) time.
(b) Suppose you have found both tangents. Give an algorithm to remove the points from the polygon that are within the angle formed by the tangents (as segments!) and the opposite side of the polygon. (c) Use the above to give an algorithm to compute the convex hull on-line in O(n log n)
Two external diagonals Two mouths
(a) Prove that for any configuration of ghosts and ghostbusters, there is such a non-crossing matching. (Assume that no three points are collinear.)
(b) Show that there is a line passing through one ghostbuster and one ghost such that the number of ghostbusters on one side of the line equals the number of ghosts on the same side. Give an efficient algorithm to find such a line. (c) Give an efficient divide and conquer algorithm to pair ghostbusters and ghosts so that no two streams cross.