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: 80% (15 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.
-
A 4.0- resistor has a current i = 2.5 sin t (A). Find the voltage, power, and energy over one cycle, given that = 500 rad/s.
-
Consider the following cash flow profile, and assume MARR is 10 percent/year. a. What does Descartes' rule of signs tell us about the IRR(s) of this project? b. What does Norstrom's criterion tell us...
-
Financial data for Joel de Paris, Inc., for last year follow: The company paid dividends of $15,000 last year. The Investment in Buisson, S.A., on the balance sheet represents an investment in the...
-
An economic consultant for a fast-food chain has been given a random sample of the chains service workers. In her model, A, the length of time y between the time the worker is hired and the time a...
-
Multiple Choice Questions 1. Halifax Corporation has a December 31 fiscal year-end. As of December 31, Year 1, the company has a debt covenant violation that results in a 10-year note payable to Nova...
-
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...
-
Evaluate the dot product of the three pairs of vectors in a. b. c. 110 5
-
Ms. Morrison is divorced and maintains a residence far from her former spouse. She has custody of the two children from the marriage. They are aged 7 and 10 and in good health. Her Net Income For Tax...
-
1. Draw a precise graph that represents the demand and supply functions: Qd = 300-0.5Pi-2Pp+0.4Y Qs = 1.5Pi Where Y=500 and Pp=50
-
A roller coaster car has a speed of vo= 5.5 m/s as it reaches the crest of a h = 20.5 m drop. What is the car's speed at the bottom of the drop, vf in m/s?
-
Clementine's Designs is looking to create a new product. The variable cost of manufacturing the new product is estimated at $65 per unit. The proposed selling price is $95. The fixed costs are...
-
Iona Industries acquired a packaging machine used in its factory operations for $160,000. The machine was originally estimated to have a useful life of 5 years and a salvage value of $40,000. Iona...
-
What is the purpose of a bank reconciliation? Who should prepare it? Why is it important to have the appropriate person prepare it?
-
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?
-
Of 15,000 individuals aged 18 years living in Ontario, 5,000 visited their family doctor in the past year and of these individuals 1,875 were diagnosed with lifelong depression. Assuming everyone was...
-
If A = 9 3 -5 -8 -7 01-87 2 00-765 000-4 3 0 0 0 0 -9 then det (A) =
-
To improve the effectiveness of its teaching staff, the administration of a high school offered the opportunity for all teachers to participate in a workshop. They were not required to attend;...
Study smarter with the SolutionInn App