Calculate the optimal position of the large pipeline

Assignment Help JAVA Programming
Reference no: EM13167304

• Oil company is planning a large pipeline from east to west (x-axis) across its oil field
• The field has n wells
• The company wants to connect each well directly to the large pipeline with smaller pipelines, running north-south (y-axis)

• Your task is to calculate the optimal position (on the y-axis) of the large pipeline, so that the total length of all smaller pipelines is shortest

• (If the large horizontal pipeline has the same y-coorindate as a well, length of smaller pipeline that is needed for that well is 0)

• You have the information about the positions of each well on the y-axis

110_Pipeline problem.png

• takes as input
• on the first Hne, the number of wells n, n>=2, n<1000000
• on each consecutive line (from 2nd to (n+1)-th line), the y-coordinate of one well (integers in the range 0 to 1000000000)
• returns on output
• a single number: the y-coordinate where the pipeline should be built (an integer in the range 0 to 1000000000)
• only this one number, no comments, prompts for input etc,
• Use Standard I/O to read input and write the result
• In Java, it's System.in for input, System.out for output
• Usage in Linux/MacOS:
> javac cmsc401.java
> cat someInput.txt lava cmsc401> result.txt
• Make sure the program compiles

Example of a correct result:

1099_Pipeline problem1.png

Length of connecting pipelines: 10. There are no y-positions for the large pipeline with total length of connecting pipelines smaller than 10. However, some other results also lead to 10.

Length of connecting pipelines: 7.

There is a better y-position, with the total length of connecting pipelines equal to 5.

100_Pipeline problem2.png

• OLJ should go through two phases:
• Abstract problem solving
• What is the general rule that leads to the solution
• Go through a couple of examples, try to come with a simple rule
• Algorithm design & coding
• Once you know what your solution is mathematically, think about howto find it quickly using an algorithm
• Threat the y-coordinates for n wells as an array A of the size n
• Design a divide & conquer method to solve the problem
• On Ar the algorithm should use Partition function from quicksort
• The whole structure should be recursive but different from quicksort
• Try to use the asymptotically fastest method possible B in terms of the expectedlaverage-case running time - aim at expected linea time
• slow methods vvill get lower score even if correct
• There may be several correct solutions that are equally good, return on output only one of them

Reference no: EM13167304

Questions Cloud

How will government regulation impact decision making : How will government regulation impact decision making and will the community's makeup be a consideration for decision makers?
What is the thickness\ : 1 oz of gold (density=19.3 g/ml) can be hammered into a sheet which would cover a 1.00 x 10^2 ft^2 area what is the thickness.
State the standard reaction enthalpy for the decomposition : The standard reaction enthalpy for the decomposition of CaCl2_NH3 into CaCl2 and NH3 is nearly constant at +78 kJ/mol between 350 K and 470 K.
What biochemical changes are required to convert tyrosine : What biochemical changes are required to convert tyrosine to (a) norepinephrine and (b) epinephrine? and 3- Some bacterial signaling systems involve kinases that transfer a phosphoryl group to a His side chain. Draw the phospho-His side chain.
Calculate the optimal position of the large pipeline : Your task is to calculate the optimal position (on the y-axis) of the large pipeline, so that the total length of all smaller pipelines is shortest
Unethical power : I have been exposed to unethical power and can tell you it is a very difficult situation to be involved in. However, sometimes we have to wonder if these situations are necessary to have these types of interactions to fortify our organizations and ou..
Define the reaction of a phenol and an anhydride : Asprin, whose structure can be found in the introduction, can be made from the reaction of a phenol and an anhydride. Give the phenol and anhydride that could be used to make aspirin?
Marie-elisabeth vigee-lebrun : What was the most notable achievement of Marie-Elisabeth Vigee-Lebrun?
Compute the theoretical yield of the complex : Assuming that all "other" reactants used in the synthesis of the complex are in excess, calculate the theoretical yield of the complex.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Implement simple java program to input syllabus grades

To implement simple Java program to input (hypothetical) syllabus grades, computing and displaying both normal Mean and Harmonic Mean.

  Java tv''s newest owner! java tv is the greatest tv channel

Java TV's newest owner! Java TV is the greatest TV channel ever, and it prides itself in its 24 hour interesting ' programming'. To help you run this channel you will need to write a  dynamic  program that uses  Data Lists  to store all its TV show i..

  Java application to display multiple choice questions

Write down the application which displays series of TEN(10) multiple choice questions: questions must cover all the Java. Each question must have four possible answers and only one answer must be correct.

  What is overloading and what is overriding

What is overloading and what is overriding? Please use code to explain it.

  Implement the lexical and syntactic analysis

Implement the lexical and syntactic analysis of Minifun programming language.

  Write down ijvm code to remove top two words from stack

Write down IJVM code which will remove these top two words, multiply and put their product back on stack. You are allowed to use existing IJVM instructions only.

  Design an application for pizza order process

Create an application to take and procedure a pizza order. The user should be able to make pizza order choices from listboxes, and the application should show the order price.

  Implement a shopping cart class with user interface

project will be to implement a shopping cart class with user interface (UI) that contains main() in Net Beans. The UI class will be used to perform user input/output and to invoke the appropriate methods of shopping cart class. When your program star..

  Write an application that takes in an array of 30 grades

Write an application that takes in an Array of 30 Grades (integer) and returns the maximum grade, minimum grade, average of all grades, and prints a Bar Chart to show the grade distribution.

  Develop java package comprising of class using encapsulation

Develop the Java package comprising of Class and Student with the given requirements. Encapsulation, Method to print student details alone.

  To translate infix mathematical expression

Write a program in java to translate infix mathematical expression into postfix expression and a program to evaluate the postfix expression

  Construct java program named collegelist

Construct a set of classes for a college to use in many student service and personnel applications. Classes you require to design include following:

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd