Homework Exam 1, second chance, Geometric Algorithms, 2015

advertisement
Homework Exam 1, second chance, Geometric Algorithms, 2015
Distributed on Thursday, March 19. Hand in on paper on Thursday, March 26, 2015, at 15.15
(start of class, or earlier if you don’t come to class). Be precise, correct, and succinct (but
complete) in your explanations, algorithms, and running time analyses. This homework exam
is 25% of the final mark. If your score is below 5, you fail the course because this is already the
second and last chance.
You may not collaborate with other students, although you may discuss an approach on a
high level in an initial stage. Thinking about the technical details and the complete write-up
must be done individually. You may ask questions to the lecturer up to March 27 at 17.00, and
this will not influence your score for this exam.
1. (3 points) Given a planar subdivision S in doubly-connected edge list representation. The
underlying graph (vertices and edges of the subdivision) is not necessarily connected, but
you may assume that all vertices have degree at least 2. Write a piece of code that can
remove an edge from the subdivision S, that is, write the body of a method that takes as
a parameter a half-edge ~e from the DCEL, and removes it and its twin from the DCEL.
You must update the DCEL to the correct representation of the resulting subdivision. In
the code, use the names of the fields as in the book, like Twin, IncidentFace, etc.
Be careful not to forget any steps or assignments to fields. Your code should be efficient
(meaning: not unnecessarily inefficient). Explain your code where you think this is needed.
2. (2 points) A polygonal chain of length n consists of a set of n vertices {p1 , . . . , pn } and a
set of n − 1 edges {(pi , pi+1 ) | 1 ≤ i < n}.
(a) Given two x-monotone polygonal chains P and Q of length n. Prove that P and Q
intersect O(n) times.
(b) Given an x-monotone polygonal chain P of length n and a y-monotone polygonal
chain Q of length n. Does the bound of (a) still apply to P and Q? Justify your
answer.
3. (3 points) Given a simple polygon P with n vertices and a set S of m points that all lie
inside polygon P . The points of S do not lie on edges or vertices of P . We are interested
in pairs of points from S that can see each other inside the polygon. Here the outside of
the polygon blocks visibility, but the other points of S do not, and the boundary of P also
does not block visibility.
(a) Let q be one of the points in S. Give an algorithm that determines in O((n +
m) log(n + m)) time which points of S are seen by q. Your algorithm should be a
rotating sweep-line algorithm. Define the status, describe the status structure and
the event list, give pseudo-code for event handling and for the whole algorithm itself.
Also prove the running time.
(b) Suppose we are interested in the question whether every point in S can see every
other point of S. Give an algorithm for this problem that is as efficient as possible.
Give and prove the running time as well.
4. (2 points) Given a set P of n points in the plane, give an efficient algorithm to decide
whether there is any subset of (at least) four points in P that lie on some circle (are
co-circular). Analyse the running time of your algorithm.
1
Download