Decide where to build a Chain of Restaurants along a linear highway.
Where should you place the restaurants to maximize profit? (Algorithm)
Dynamic Programming.
Add node-weights = p(i) for every node i
Given a sequence of numbers, find the Longest Increasing Subsequence
Dynamic Programming
Given a sequence of numbers that can be negative,
Find the Maximum Contiguous Subsequence
Dynamic Programming
Make it so the node weight = number value at index i
2. Find the LONGEST NODE-weighted path with an OPEN start and an OPEN end
What is the algorithm to find the shortest path in a DAG with a FIXED start?
Initialize all dist(u) = infinity
dist(s) = 0
for each v in V \ {s} (all nodes in set except for start) in LINEARIZED ORDER
dist(v) = min((u,v) in E) {dist(u) + l(u,v)}
Or dist(v) = 0 if there’s no incoming edges
What is the algorithm to find the shortest path in a DAG with an OPEN start?
Initialize all dist(u) = infinity
dist(s) = 0
for each v in V \ {s} (all nodes in set except for start) in LINEARIZED ORDER
dist(v) = min {min((u,v) in E) {dist(u) + l(u,v)},
OR 0}
How do you modify a DAG path algorithm to return the sequence/subproblems?
2. Inside the for loop, do “prev(i)= j” for the j value that was chosen in the condition