What is dynamic programming?
How is a problem solved by dynamic programming?
What type of problem are dynamic programming solutions used to typically solve?
Optimisation problems
- that have a maximising or minimising function
- applied where brute force is infeasible
What are the 3 features a problem must have to be effectively solved by dynamic programming?
What is memoisation?
What can make the run time of a dynamic programming solution poor?
Subproblems overlap and recompute the same value over and over which is inefficient
What is the naive dynamic programming runtime of calculating the fibonacci sequence?
O(2^n)
What is the dynamic programming memoisation run time of calculating the fibonacci sequence?
What problems can we solve with dynamic programming?
What is the dynamic programming runtime of the solution for the {0,1} Knapsack problem?
O(n*W)
- where n is the number of elements to be packed
- and W is the max weight the knapsack can hold
- inefficient as run time is exponential as Wmax is exponential?
What is weighted interval scheduling?
What is the time complexity for finding the weighted interval scheduling problem solution using dynamic programming?
O(n*logn) since we use memoisation
What can we use to prove that the dynamic programming solution for the weighted interval scheduling problem is correct?
We can use proof by induction
- since every succeeding task’s optimal solution can be calculated by the optimal solutions of preceeding tasks (computed and stored in the dynamic programming table),
- we can show that the induction base holds and then show the induction step also holds