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 22.10.2
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 getConvexHull(double[][] s)
MyPoint is a static inner class defined as follows:
private static class MyPoint implements Comparable {
double x, y;
MyPoint rightMostLowestPoint;
MyPoint(double x, double y){
this.x = x; this.y = y;
}
public void setRightMostLowestPoint(MyPoint p){
rightMostLowestPoint = p;
}
@Override
public int compareTo(MyPoint o){
// Implement it to compare this point with point o
// angularly along the x-axis with rightMostLowestPoint
// as the center, as shown in Figure 22.10b. 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!