Sort(
,
) where
sorts the elements from
to
. In other words, to sort the entire list of
elements, call Sort(
,
). (Note that Sort(
,
) sorts an empty
list.)
Here is the algorithm:
After this rearrangement, suppose that
winds up in slot
,
where
. Now apply Sort(
,
) and Sort(
,
).
A simple polygon is a closed loop of line segments whose only points in common are the endpoints of adjacent pairs of segments. In other words, the edges of the polygon do not touch each other, except at the vertices, where exactly two edges meet. Note that a simple polygon need not be convex.
In the example above, the triangle includes 6 boundary points and 12
interior points, so its area should be (according to Pick's Theorem)
. You can check that this is right by noticing that
its area is the area of the surrounding rectange (
)
less the areas of the three surrounding triangles: (5/2, 15/2, and
32/2). When we check, we get:
.
Show that
In the solution section, the actual solution is preceeded by a couple of hints.
Hint: Show that: