CISC 320 Algorithms and Advanced Programming, Fall, 2002.
Homework set #4.                     Due Tue, Dec 10.

  1. Textbook problem R-9.2.

  2. Textbook problem R-9.3.

  3. Textbook problem R-9.5.

  4. Textbook problem C-12.18. Your example must have more than 3 points. Hint: it will have at least one case where 3 or more of the points are colinear.

  5. Consider this "boxing out" convex hull algorithm:
    vector convexHull(vector A)
    Input: A -- vector of n points, the points are sorted in increasing order by x coordinate
    Output: H -- vector consisting of the vertices of the convex hull of the points in A.
    {
    0.   int n = A.size();
    1.   MergeSort A by x-coordinate.
         Let p_1 =A[0], p_3 = A[n-1].
    2.   MergeSort A by y-coordinate.
         Let p_2 =A[0], p_4 = A[n-1].
    3.   Eliminate all points strictly inside the quadrilateral 
         formed by p_1, p_2, p_3, and p_4.  
    4.   Find and return the convex hull H of the remaining points by the GiftWrap method.
    }
         
    
    (a) Explain why the algorithm is correct.

    (b) Compute a reasonable big-O estimate of the worst case cost of the algorithm.

    (c) What do you think the expected case cost of the Gift Wrap convex hull algorithm when the input data consists of n points chosen randomly within a circle of radius 1. Measure the cost as number of comparisons used to find the anchor and number of comparisons using the radial comparator. Explain your thinking. You do not have to produce a rigorous argument for this cost.

    (d) What do you think will be the expected case cost of the above boxing out algorithm on the same random-in-circle data? Include the comparisons from the MergeSorts in the cost. Explain. Compare it to the gift wrap method.

    (d) Concerning the same random-in-circle data, do you think it would be better to use Graham Scan than Gift Wrap in step 4? Explain why or why not.

    Remark: area of circle = pi*r2, circumference of circle = 2*pi*r, area of square of side sqrt(2r) is 2r2.

  6. Textbook problem R-13.15.