You are on page 1of 3

COMP 5045 Assignment 1

As a first step go to the third page and read the section: Advice on how to do
the home work.
1. Let S be a set of n points in the plane sorted with respect to their ycoordinate from bottom to top. Give an algorithm that computes the
convex hull of S in O(n) time. Argue its time complexity. [10 points]
2. You are given two x-monotone polygonal chains P and Q. Prove that
the number of times P and Q can intersect is O(n), where n is the total
number of vertices of P and Q, see Figure 1(a). [10 points]
3. Let ` be a line in the plane and let p be a point. The orthogonal projection
of p onto ` is the point q on ` such that the line segment (p, q) is orthogonal
to `, as shown in Fig. 1(b).
(a) Given a convex polygon P and a point q within P prove that q has
an orthogonal projection onto the perimeter of P . [6 points]
(b) What if P is not convex? Prove or disprove the statement. [4 points]

Q
`
(a)

(b)

Figure 1: (a) Two x-monotone paths P and Q. (b) Illustrating the orthogonal
projection q of p onto `.

4. Let R be a set of n red segments in the plane and let B be a set of m


blue segments in the plane. Design an algorithm that counts the number
of intersections between the segments in R and the segments in B. Prove
the running time, space requirement and correctness of your algorithm.
For full points the algorithm should use O((n + m) log(n + m)) time and
O(n + m) space. [10 points]

5. Consider the following algorithm to compute the convex hull of a set S of


n points in the plane.
Step 1: Sort the points in S by increasing x-coordinate.
Step 2: Recursively compute the convex hull of the left half of the point
set. The resulting convex hull is denoted H1 .
Step 3: Recursively compute the convex hull of the right half of the point
set. The resulting convex hull is denoted H2 .
Step 4: From H1 and H2 compute the convex hull H of the entire point
set.
(a) Assume that step 4 can be implemented in time O(n). What is the
running time of the algorithm? Prove your time bound. [2 points]
(b) Consider the edge e connecting the highest point in H1 with the
highest point in H2 . Will the edge e be an edge in H? Prove your
answer. [2 points]
(c) Consider the points clockwise along H1 between the highest point
of H1 to the lowest point of H1 . Can any of these points be in the
convex hull, H, of the entire set? Prove your answer. [2 points]
(d) Give a correct implementation of step 4, that runs in O(n) time.
Prove the correctness and the running time of your algorithm. [4
points]
6. Let C be a set of n cats and let D be a set of m dogs modelled as points
in the plane. Determine in O(n + m) expected time if there exists a line
` such that all the cats are on one side of ` and all the dogs are on the
other side of `. Prove the time complexity and the correctness of your
algorithm. [10 points]
7. Suppose you are given a set S of n points in the plane. Define the fatness of
S to be the largest Euclidean distance between two points in S. Describe
an efficient algorithm for determining the fatness of S. Prove the running
time, space requirement and correctness of your algorithm. For full points
the algorithm should use O(n log n) time and O(n) space. [10 points]
8. Let S be a set of n vertical segments and let P be a set of m points in
the plane. For a segment s S and a point p P denote by (s, p)
the triangle defined by s as its base and p as its opposite corner. Design
an algorithm that finds the smallest area (s, p) for all s S and p
P . Prove the running time, space requirement and correctness of your
algorithm. For full points the algorithm should use O((n + m) log(n + m))
time and O(n + m) space. Recall that the area of a triangle is 21 base
height. [10 points]

Advice on how to do the home work


Be careful with giving multiple or alternative answers. If you give multiple
answers, then we will give you marks only for your worst answer, as this
indicates how well you understood the question.
Some of the questions are very easy (with the help of the lecture notes or
book). You can use the material presented in the lecture or book (without
proving it). You do not need to write more than necessary (see comment
above).
When giving answers to questions, we always would like you to prove/
explain/motivate your answers.
When giving an algorithm as an answer, the algorithms does not have to
be given as (pseudo-)code.
If you do give (pseudo-)code, then you also have to explain your code and
your ideas.
Unless otherwise stated, we always ask about worst-case analysis, worst
case running times etc. (for example, hashing does not guarantee anything
in the worst case, in general).
As done in the lecture, and as it is typical for an algorithms course, we
are interested in the most efficient algorithms. Hence, the faster your
algorithm, the more points we can give you.
It might help you (and us) if you briefly describe your general idea, and
after that you might want to develop and elaborate on details. If we dont
see/understand your general idea, we cannot give you points for it.
If you use further resources (books, scientific papers, the internet,...) to
formulate your answers, then add references to your sources.

You might also like