+1 vote
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 <= i <= j <= 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 goal is to minimize the rental cost. Give the most efficient algorithm you can for this problem. Prove that your algorithm yields an optimal solution and analyze the time complexity.

Please provide the Notation, optimality, recurrence, and algorithm.
in Dynamic Programming by AlgoMeister (684 points)

2 Answers

0 votes
I think if we begin with the notation, it might something like:

C(j) = Minimum cost of arriving at post # j, starting from # 1.

Now, we can try to write C(j) in terms of minimum C(i), where i < j.

Once that recurrence relation is there, that should do it.
by AlgoMeister (1.6k points)
0 votes
I guess this is a example of All Pair Shartest Path Dynamic Programming algorithm where we have to return the Shortest Path from 1 to N
by Active (312 points)
Using APSP will take O(n^3) time.  Using the simpler notation C(j), we can do this in O(n^2) time.

Related questions

+2 votes
3 answers
asked Mar 3, 2018 in Dynamic Programming by jmlitfi AlgoMeister (684 points)
0 votes
3 answers
asked Apr 16, 2023 in CSP by Amrinder Arora AlgoMeister (1.6k points)
The Book: Analysis and Design of Algorithms | Presentations on Slideshare | Lecture Notes, etc
...