Sie sind auf Seite 1von 3

AMS 345/CSE 355 (Spring, 2006) Joe Mitchell

COMPUTATIONAL GEOMETRY
Homework Set # 4 – Solution Notes
(1). O’Rourke, problem 4, section 3.2.3, page 68. In two dimensions, the affine hull of two points is the line
through the two points, of three noncolinear points is the plane <2 , of n > 3 points not all on the same line
is also the plane <2 . The affine hull of n ≥ 3 points that are collinear is the line through the points.
In three dimensions, the affine hull of two points is the line through the two points, of three noncolinear
points is the plane through the three points, of four points in general position is all of space, < 3 , of n > 4
points in general position (or at least some subset of four of them in general position) is all of space, < 3 .
The affine hull of n ≥ 3 points that are collinear is the line through the points. The affine hull of n ≥ 4
points that are coplanar is the plane through the points.
(2). O’Rourke, problem 5, section 3.4.1, page 72. When we call QuickHull(a, b, S), we spend time O(|S|) ≤
O(n) looping through the points of S to find that point c which is farthest from ab (or possibly finding more
than one such point and selecting c to be the leftmost or rightmost among them). We know that c is a hull
vertex; thus, we have just spent O(n) time to find one vertex. We charge this work off to c (and note that
we will never charge c again, later in the algorithm); in total, we charge O(n) to each hull vertex, for a total
of O(nh) work.
(3). O’Rourke, problem 3, section 3.5.7, page 86. In the figure on the right below, we illustrate the case in
which the points indexed 0 through n − 2 are in convex position, but the point indexed n − 1 is positioned so
that the convex hull of all n points is a triangle, (0,1,n − 1). Then, Algorithm 3.6 will enter the while loop
with i = 2 and push points 2, 3, . . . , n − 2, each time incrementing i by 1. Once i = n − 1, when we enter
the while loop next, we pop n − 2 (no change to i), then pop n − 3 (no change to i), etc, until we pop point
indexed by 2 (and i = n − 1 still). In the final iteration of the while loop, we push point n − 1, set i = n,
and the while loop has ended (since i < n is false). In total there were n − 3 iterations of the while loop
that do a push, then n − 2 iterations that do a pop, then 1 iteration that pushes; in total, there are 2n − 5
iterations. Note that the same will happen in any case in which the convex hull has only 3 vertices (h = 3),
even of the points that are interior to the hull are not in convex position (as in the figure below): all but 3
points will be both pushed and popped.
1 1
2 2
3 3

n−1 0 n−2
n−1 0
(4). Let S be the set of points {(3,1), (4,4), (5,-1), (2,-1), (2,2), (2,1), (4,-1), (6,1), (8,1), (8,5), (7,4),
(3,3)}. When the Graham Scan code of Section 3.5 is run on this data, what is the sorting (as in Table 3.1)
and what is the history of the stack (as in the example on page 86)? Plot the points and the resulting convex
hull.
We consider the points to be indexed 0–11, in the order S is given. By running the code, the sorting
gives the list below (which also indicates the three points that are deleted):
After sorting, ndelete = 3:
Points:
vnum= 2, x= 5, y= -1, delete=0
vnum= 8, x= 8, y= 1, delete=0
vnum= 7, x= 6, y= 1, delete=1
vnum= 9, x= 8, y= 5, delete=0
vnum= 10, x= 7, y= 4, delete=0
vnum= 1, x= 4, y= 4, delete=0
vnum= 11, x= 3, y= 3, delete=0
vnum= 0, x= 3, y= 1, delete=1
vnum= 4, x= 2, y= 2, delete=0
vnum= 5, x= 2, y= 1, delete=0
vnum= 6, x= 4, y= -1, delete=1
vnum= 3, x= 2, y= -1, delete=0

The stack history is:


i=2: 8, 2
i=3: 9, 8, 2
i=4: 10, 9, 8, 2
i=4: 9, 8, 2
i=5: 1, 9, 8, 2
i=6: 11, 1, 9, 8, 2
i=6: 1, 9, 8, 2
i=7: 4, 1, 9, 8, 2
i=8: 5, 4, 1, 9, 8, 2
i=8: 4, 1, 9, 8, 2

Finally, at the bottom of the while loop, the stack is


i=9: 3, 4, 1, 9, 8, 2

The hull is given by:


Hull:
vnum=3 x=2 y=-1
vnum=4 x=2 y=2
vnum=1 x=4 y=4
vnum=9 x=8 y=5
vnum=8 x=8 y=1
vnum=2 x=5 y=-1

9
1
10
11
4

5 0
7 8

3 6 2

(5). Assume that we execute Melkman’s convex hull algorithm on the vertices of P in the order v 0 , v1 , v2 ,
v3 , etc. (In the figure, I label vi with “i”.) Show the deque, indicating the “top” dt and “bottom” db at the
instant just after having computed the hull of the first 8 vertices (v0 –v7 ) and also just after the first 9 vertices
(v0 –v8 ).
Using the convention of the handout on Melkman’s algorithm, I give the deque as < d b , . . . , dt >.
The evolution of the deque during the algorithm is: < 2, 1, 0, 2 >, < 3, 2, 1, 0, 3 >, < 3, 2, 1, 0, 3 >, <
3, 2, 1, 0, 3 >, < 3, 2, 1, 0, 3 >, < 3, 2, 1, 0, 3 >, < 8, 2, 1, 0, 8 >, < 9, 8, 2, 1, 9 >. (A careful examination of
the figure reveals that point v9 lies to the right of the segment v1 v0 .) See the figure below. (If you continue
beyond what you were asked, the deque is: < 2, 1, 0, 2 >, < 3, 2, 1, 0, 3 >, < 3, 2, 1, 0, 3 >, < 3, 2, 1, 0, 3 >,
< 3, 2, 1, 0, 3 >, < 3, 2, 1, 0, 3 >, < 8, 2, 1, 0, 8 >, < 9, 8, 2, 1, 9 >, < 10, 8, 2, 1, 9, 10 >, < 11, 10, 8, 2, 1, 11 >,
< 12, 11, 10, 8, 2, 1, 12 >, < 12, 11, 10, 8, 2, 1, 12 >, < 14, 11, 10, 8, 2, 1, 14 >.)

(6). The algorithm below is proposed to find the convex hull of a simple polygon P that has n vertices, in
O(n) time. The goal is to avoid the need to sort, by using the order given by the vertices of P , which are
assumed to be given in clockwise order around the boundary of P . The algorithm is essentially just doing a
variant of the Graham Scan, using the order of the vertices about P in the incremental insertion.
Show that this algorithm can fail by finding a counterexample in which the output is erroneous.
Algorithm: Let the stack Q be initialized as (q0 , q1 ), where q0 is the leftmost point of the polygon and q1
is the (clockwise) successor of q0 in the list of points of the polygon. March around the polygon (clockwise),
starting with the successor of q1 . If at some stage the stack is Q = (q0 , . . . , qi ), with i ≥ 1, then let p be the
successor of qi . If (qi−1 , qi , p) is a right turn, then push p onto the stack Q; otherwise, pop Q (and continue
popping Q) until this right-turn condition is satisfied or until there is only one point remaining in the stack,
and then push p onto Q. Stop when you return to point q0 .
The flaw is that, while the algorithm does maintain the “right turning” property of the chain that is
stored in the stack (the chain that purports to be the “hull so far”), it does not guarantee that this chain
does not self intersect! For example, the input on the left below gives rise to the output on the right, all
of whose turns are “right”. (You should step through the algorithm to verify this!)
1

3
2
0 5

Das könnte Ihnen auch gefallen