Question

There are n trading posts along a river. At any of the posts you can rent...

There are n trading posts along a river. At any of the posts you can rent a canoe to be returned at any other post downstream. (It is next to impossible to paddle against the current.) For each possible departure point i and each possible arrival point j the cost of a rental from i to j is known. However, it can happen that the cost of renting from i to j is higher than the total cost of a series of shorter rentals. In this case you can return the first canoe at some post k between i and j and continue your journey in a second canoe. There is no extra charge for changing canoes in this way. Give an efficient algorithm to determine the minimum cost of a trip by canoe from each possible departure point i to each possible arrival point j. In terms of n, how much time is needed by your algorithm?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer :

Consider the following data :

  • x is the departure point.
  • y is the arrival point.
  • A[x,y] is the cost of renting a canoe to travel from post x to post y.
  • There may be many routes to travel from post x to post y. But we need to assume the cheapest cost for the trip.
  • Let T[1, z] be the cheapest cost of travelling from post 1 to post z where z=1,2,3...n.

The algorithm to find the T[1, z], where k=2 to n is as shown below :

Algorithm:

T[1,1]= 0 //the cost of travelling from post 1 to post 1 is 0.

//to find the cost of travelling from post 1 to post z

for z = 2 to n do

T[1,z]= miny-1..z-1{T[1,y] + A[y,z]}

The running time of the algorithm is O(n2).

Similarly, we can find the T [2,z] where z=3 to n, T [3,z] where z=4 to n and so on.

We can find the minimum cost by adding the cheapest costs between the posts along the path from post x to post y.

Thus, the running time is O(n3).

Add a comment
Know the answer?
Add Answer to:
There are n trading posts along a river. At any of the posts you can rent...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You are canoeing down a river and there are n renting posts along the way. Before...

    You are canoeing down a river and there are n renting posts along the way. Before starting your journey, you are given, for each 1 lessthanorequalto i lessthanorequalto j lessthanorequalto n, the fee f(i, j) for renting a canoe from post i to post j. These fees are arbitrary. For example it is possible that f(1, 3)= 10 and f(1, 4) = 5. You begin at trading post 1 and must end at trading post n (using rented canoes). Your...

  • There are n trading posts numbered 1 to n as you travel downstream. At any trading...

    There are n trading posts numbered 1 to n as you travel downstream. At any trading post i you can rent a canoe to be returned at any of the downstream trading posts j, where j >= i. You are given an array R[i, j] defining the costs of a canoe which is picked up at post i and dropped off at post j, for 1 ≤ i ≤ j ≤ n. Assume that R[i,i] = 0 and that you...

  • There are n trading posts numbered 1 to n as you travel downstream. At any trading...

    There are n trading posts numbered 1 to n as you travel downstream. At any trading post i you can rent a canoe to be returned at any of the downstream trading posts j>i. You are given a cost array R(i,j) giving the cost of these rentals for all 1≤i<j≤n. We can assume that R(i,i)=0, and that you can't go upriver (so perhaps R(i,j)= ∞ if i>j). For example, one cost array with n=4 might be the following. The problem...

  • You are a visitor at a political convention with n delegates; each delegate is a member...

    You are a visitor at a political convention with n delegates; each delegate is a member of exactly one political party. It is impossible to tell which political party any delegate belongs to; in particular, you will be summarily ejected from the convention if you ask anyone. However, you can determine whether any pair of delegates belong to the same party by introducing them to each other. Members of the same political party always greet each other with smiles and...

  • a) Formulate a cost function along with constraints, if any, for the following optimization problems. You don't nee...

    a) Formulate a cost function along with constraints, if any, for the following optimization problems. You don't need to solve any of these problems i) Two electric generators are interconnected to provide total power to meet the load. Suppose each generator's cost (C) is a function of its power output P (in terms of units), and costs per unit are given by: C2 = 1 + 0.6P2 + P22 (for Generator 2). -1-P -Pi2 (for Generator 1), If the total...

  • Solve it for java Question Remember: You will need to read this assignment many times to...

    Solve it for java Question Remember: You will need to read this assignment many times to understand all the details of the you need to write. program Goal: The purp0se of this assignment is to write a Java program that models an elevator, where the elevator itself is a stack of people on the elevator and people wait in queues on each floor to get on the elevator. Scenario: A hospital in a block of old buildings has a nearly-antique...

  • You are running a physics experiment with n complicated steps that you must do in order,...

    You are running a physics experiment with n complicated steps that you must do in order, and students sign-up for some steps to help. Your experiment requires n steps, and each of the m students gives you a list of which steps they can help out with (steps require special skills). From experience, you know things run most smoothly when you have as little switching of shifts as possible. For example, if your experiment has <1, 2, 3, 4, 5,...

  • if possible can you write answer in this type of layout as well so i can...

    if possible can you write answer in this type of layout as well so i can clearly see where each numbers go so when doing a dif problem thanks :) Che Lamonda Corp. uses a job order cost system. On April 1, the accounts had balances as shown in the T-accounts below: The following transactions occurred during April points (a) Purchased materials on account at a cost of $233,370 (b) Requisitioned materials at a cost of $110,500, of which $15,500...

  • I need to answer these test questions Choose all of the following which are benefits of...

    I need to answer these test questions Choose all of the following which are benefits of using meaningful names in writing clean code. Always use abbreviations to keep things short Clearly differentiate names Make as similar as possible Be descriptive and imply type Use descriptive names but don't include details about implementation Is __init_. a magic method? TRUE FALSE True or False: Functions should bring multiple actions together so they are more efficiently run. TRUE FALSE What are some considerations...

  • Java 1 Some help Please...... 1. Before You Begin Anticipate where things can go wrong Consider...

    Java 1 Some help Please...... 1. Before You Begin Anticipate where things can go wrong Consider how to gracefully shut down the program and save the users data and close files properly. Typically there are two scenarios to make a distinction between: The first is one that which you have absolutely no control over; such as if all the files are where they should be, and that the user has not deleted one or accidentally moved it rather than copied...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT