Section 22.10.2 introduced Graham?s algorithm for finding a convex hull for a set of points. Assume that
Question:
Section 22.10.2 introduced Graham?s algorithm for finding a convex hull for a set of points. Assume that the Java?s coordinate system is used for the points. Implement the algorithm using the following method:
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. Here is a sample run:
Transcribed Image Text:
/** Return the points that form a convex hull */ public static ArrayList
/** Return the points that form a convex hull */ public static ArrayList getConvexHul1 (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. } How many points are in the set? 6 -Enter Enter Enter 6 points: 1 2.4 2.5 2 1.5 34.5 5.5 6 6 2.4 5.5 9 The convex hull is (1.5, 34.5) (5.5, 9.0) (6.0, 2.4) (2.5, 2.0) (1.0, 2.4)
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 81% (16 reviews)
Program Plan Create class convexHullGraham In convexHullGraham create methods getConvexHull which returns pointStack placeFirstPoint which places the ...View the full answer
Answered By
Aysha Ali
my name is ayesha ali. i have done my matriculation in science topics with a+ . then i got admission in the field of computer science and technology in punjab college, lahore. i have passed my final examination of college with a+ also. after that, i got admission in the biggest university of pakistan which is university of the punjab. i am studying business and information technology in my university. i always stand first in my class. i am very brilliant client. my experts always appreciate my work. my projects are very popular in my university because i always complete my work with extreme devotion. i have a great knowledge about all major science topics. science topics always remain my favorite topics. i am also a home expert. i teach many clients at my home ranging from pre-school level to university level. my clients always show excellent result. i am expert in writing essays, reports, speeches, researches and all type of projects. i also have a vast knowledge about business, marketing, cost accounting and finance. i am also expert in making presentations on powerpoint and microsoft word. if you need any sort of help in any topic, please dont hesitate to consult with me. i will provide you the best work at a very reasonable price. i am quality oriented and i have 5 year experience in the following field.
matriculation in science topics; inter in computer science; bachelors in business and information technology
_embed src=http://www.clocklink.com/clocks/0018-orange.swf?timezone=usa_albany& width=200 height=200 wmode=transparent type=application/x-shockwave-flash_
4.40+
11+ Reviews
14+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
Programming Exercise finds a convex hull for a set of points entered from the console. Write a program that enables the user to add/remove points by clicking the left/right mouse button, and displays...
-
Section 22.10.1 introduced the gift-wrapping algorithm for finding a convex hull for a set of points. Assume that the Java?s coordinate system is used for the points. Implement the algorithm using...
-
The text introduced Prims algorithm for finding a minimum spanning tree. Kruskals algorithm is another well-known algorithm for finding a minimum spanning tree. The algorithm repeatedly finds a...
-
Dickletton Attorneys' policy is to bank all receipts in its Trust bank account and at the end of each month the bookkeeper transfers the relevant funds due to Dickletton Attorneys from the trust to...
-
Show that the representation in equation (6) is unique, that is, if x = 1x1 + a2x2 +..........+ anxn and also if x = 1x1 + 2x2 +............+ nxn then i = i for all i.
-
According to the Pew Research Center, in 2015, 58% of all American adults had Facebook accounts. Suppose this is true now. If a random sample of 100 Americans is to be taken, use the normal...
-
Ratliff Corporation produces lawn fertilizer spreaders. Ratliffs income statement shown has been prepared for August of the current year. Instructions: 1. Prepare Ratliffs August income statement...
-
Felix & Co. reports the following information about its sales and cost of sales. Draw an estimated line of cost behavior using a scatter diagram, and compute fixed costs and variable costs per unit...
-
Do people on average spend 2.8 hours per day on watching TV (variable:tvhours)? List the null hypothesis and alternative hypothesis. Use SPSS to run a one-sample t-test (please refer to the video for...
-
Prevosti Farms and Sugarhouse pays its employees according to their job classification. The following employees make up Sugarhouse's staff: Employee Number Name and Address Payroll information...
-
Write a program that obtains the execution time for finding all the prime numbers less than 8,000,000, 10,000,000, 12,000,000, 14,000,000, 16,000,000, and 18,000,000 using the algorithms in Listings...
-
Write a program that obtains the execution time for finding the GCD of every two consecutive Fibonacci numbers from the index 40 to index 45 using the algorithms in Listings 22.3 and 22.4. Your...
-
A payday loan is a short-term loan that is repaid on the next payday, often by giving the lender electronic access to a personal checking account. Some states have statutes that regulate the fees...
-
Productivity can also be described as the effectiveness with which the resources input in a plant are translated to customer satisfaction-oriented products. Explain
-
Alex worked for years for MegaCorp. During his employment with MegaCorp, he learned a great deal of confidential information and knew that if this information got into the hands of competitors or the...
-
Maxey & Sons manufactures two types of storage cabinets-Type A and Type Band applies manufacturing overhead to all units at the rate of $152 per machine hour. Production information follows....
-
Suppose S 0 SF / $ = SF 0 . 9 4 9 4 / $ and F 6 - monthSF / $ = SF 0 . 9 4 7 8 / $ . What is the percentage forward premium / discount on the U . S . dollar?
-
21 In the following we consider vectors x = 22 in R3. Determine (with 23 justification) whether the following sets are subspaces of R3. 1. (5pts) V = {x R | x1 = x2 = x3}
-
You have $100,000 to invest in a portfolio containing Stock X and Stock Y. Your goal is to create a portfolio that has an expected return of 11.7 percent. If Stock X has an expected return of 10.8...
-
Give the structural formulas of the alkenes that, on ozonolysis, give: a. (CH3)2C=O and CH2=O b. Only (CH3CH2)2C=O c. CH3CH=O and CH3CH2CH=O d. O=CHCH2CH2CH2CH=O
-
What is the transmission time of a packet sent by a station if the length of the packet is 1 million bytes and the bandwidth of the channel is 200 Kbps?
-
We have a channel with 4 KHz bandwidth. If we want to send data at 100 Kbps, what is the minimum SNR dB ? What is the SNR?
-
We need to upgrade a channel to a higher bandwidth. Answer the following questions: a. How is the rate improved if we double the bandwidth? b. How is the rate improved if we double the SNR?
-
AllCity Inc. is financed 45% with debt, 10% with preferred stock, and 45% with common stock. Its pre-tax cost of debt is 6%; its preferred stock pays an annual dividend of $2.25 and is priced at $30....
-
You have decided to buy a house. The price will be $500,000 and you will put $50,000 down. Your annual interest rate will be 6% and the loan calls for monthly payments for 30 years. You also know...
-
Problem 7-13 Inflation and Nominal Returns [LO4] Suppose the real rate is 3.3 percent and the inflation rate is 4.9 percent. What rate would you expect to see on a Treasury bill? (Do not round...
Study smarter with the SolutionInn App