Question: Graham s algorithm for finding a convex hull ) Section 2 2 . 1 0 . 2 introduced Graham s algorithm for finding a convex
Grahams algorithm for finding a convex hull Section
introduced Grahams algorithm for finding a convex hull for a set of points.
Assume that the Javas coordinate system is used for the points. Implement the
algorithm using the following method: Return the points that form a convex hull
public static ArrayList getConvexHulldouble s
MyPoint is a static inner class defined as follows:
private static class MyPoint implements Comparable
double x y;
MyPoint rightMostLowestPoint;
MyPointdouble x double y
this.x x; this.y y;
public void setRightMostLowestPointMyPoint p
rightMostLowestPoint p;
@Override
public int compareToMyPoint o
Implement it to compare this point with point o
angularly along the xaxis with rightMostLowestPoint
as the center, as shown in Figure b By implementing
the Comparable interface, you can use the Array.sort
method to sort the points to simplify coding.
Write a test program that prompts the user to enter the set size and the points
and displays the points that form a convex hull.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
