Homework: 4.25, 4.28, 6.4, 6.6, 6.12, Read Chapter 6
Bellman-Ford and Dynamic Programming
Take an $N\times M$ grid, how many ways can the robot take to go from $(0,\,0)$ to $(m,\,n)$.
${n+m \choose m}$
Blueprint of Dynamic Programming:
- Break up your problem into subproblems
- What am I guessing when combining solutions from subproblems into solution for the main problem
- Write a recursive solution
- Convert to non recursive solution (fill in the table?)
- Establish a topological order of filling the table
Coin Change Problem
Take coins $S_1,\,S_2,\,…,\,S_m$ each with some value. Given these coins and an infinite supply of each, use the smallest number of coins to get change for $N$.
$M(N) = \min_{1<i<M} M[(N-S_i)] + 1$
How many bits does it take to write down number $N$, $\log N$, so this is a pseudo-polynomial algorithm, or NP-incomplete. (Works for small $\log N$ however.)
Job Scheduling
Take the greedy Job Scheduling problem, but now assign weights to each job. How do we assign jobs that maximize weight?
- Sort jobs by their finishing time
- Define $\mathrm{OPT}(J)$ as the profit of the optimal selection of jobs $1\, …\,j$
- $\mathrm{OPT}(N) = \mathrm{MAX}\{\mathrm{OPT}(N-1),\, w(N) + \mathrm{OPT}(P(N))\}$ where $w$ is the weight of some job $N$ and $P$ is the predecessor function of job $N$ (the previous job that will not overlap with job $N$)