Bulloil company is planning a large pipeline from east to

Assignment Help JAVA Programming
Reference no: EM13376425

• 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: EM13376425

Questions Cloud

Business solutions inc is an accounting firm that is owned : business solutions inc. is an accounting firm that is owned and managed by chad lomax chicago illinois. it is a small
Data array a has data series from 1000000 to 1 with step : data array a has data series from 1000000 to 1 with step size 1 which is in perfect decreasing order.data array b has
What effect does the media have on body imagefinal draft : what effect does the media have on body image?final draft specifications length 1300-1500 words not including citation
You have been part of the orthopedic center for 5 years in : you have been part of the orthopedic center for 5 years. in that time you have seen the center grow and the need for
Bulloil company is planning a large pipeline from east to : bulloil company is planning a large pipeline from east to west x-axis across its oil fieldbullthe field has n
1 in each case below prove or disprove that the subgroup h : 1. in each case below prove or disprove that the subgroup h is normal in the group g.if h is normal in g determine
Propose a social enterprise that will contribute to local : propose a social enterprise that will contribute to local economic development within a rural canadian community that
1 the model classes define and compile the following two : 1 the model classes define and compile the following two classes that will represent seats in a stadium public class
Given grammar grammar m following1nbspnbsp : given grammar grammar m following1nbspnbsp ltprogramgtnbspnbsp - - gt begin ltstatement listgtnbsp end2nbspnbsp

Reviews

Write a Review

JAVA Programming Questions & Answers

  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.

  Write a one-class java program

Write a one-class Java program with at least one method (besides main) to determine if the data in your dataset (i.e., in data.txt) follows Benford's law.

  Write java program to store values retrieved from user-array

Write a Java program named Arrays6_2GF.java Use an array to store values retrieved from user input. The number of integers to be entered (the length of the array )should also be retrieved through user input.

  Program will read parameters plaintext and ciphertextfrom

Specifically, your program will read parameters, plaintext and ciphertextfrom a file named "input.txt" (under the same directory).Then your program needs tocreate a file named "output.txt" (under the same directory) and prints the public key, private..

  Teaching software componentization

Describe one way in which one could apply Java graphics in education. Provide one example of such use to support your response and analyze at least three commands that you would use in order to draw a bar chart. Provide a rationale for your respons..

  The menu is displayed and the user must select

The menu is displayed and the user must select an option (a number between 0 and 7). The action corresponding to the selection is performed, then the menu is displayed again and the user can choose another option.

  String that contains at least five letters

Write an application that prompts the user for a String that contains at least five letters and at least five digits. Continuously reprompt the user until a valid String is entered. Display a message indicating whether the user was successful or did ..

  Develop java code to compute monthly rent for housing units

Develop a java code that computes monthly rent for 3 housing units namely Bungalows,Apartments and hostels. All housing units have got size,color and monthly rental rate.

  Aims1 to understand actual communication with an smtp

aims1. to understand actual communication with an smtp server can be achieved using tcp sockets.2. to understand the

  Eax contains the given contents before the instruction

For each add instruction in this problem, assume that EAX contains the given contents before the instruction is executed, and give the contents of EAX as well as the values of the CF, OF, SF, and ZF flags after the instruction is executed:

  Technical community blog

Write a blog article for a coding/technical community blog

  Create a recursive factorial program

Assignment 1: Create a recursive factorial program that prompts the user for an integer  N  and writes out a series of equations representing the calculation of  N !. For example, if the input is 4, the output could be:

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