Question: Power distribution company is planning a main power line from east to west (x-axis) across its distribution area. The area has n houses The

Power distribution company is planning a main power line from east to west (x-axis) across its distribution

Write a program cmsc401.java that takes as input   - in the first line, the number of houses n, n>=2, n

Input 6 1 8 3 6 2 27 Output 5 y=5 y=1 y=8 y=3 y=6 EB y=7 Total length of smaller power lines: 15 This is the  

Think about the solution over examples  Consider the y-coordinates of houses as an array of size n  Hints  

Power distribution company is planning a main power line from east to west (x-axis) across its distribution area. The area has n houses The company wants to connect each house directly to the main power line with smaller power lines in north-south direction (y-axis) Your task is to estimate the optimal position (on the y-axis) of the main power line, so that the total length of smaller power lines is the shortest. 9/27/16 89 BB 63 81 A G Write a program cmsc401.java that takes as input - in the first line, the number of houses n, n>=2, n

Step by Step Solution

3.43 Rating (150 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

As n house are on y axis so we have to find median of all ... View full answer

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 Algorithms Questions!