Differences

This shows you the differences between two versions of the page.

Link to this comparison view

courses:cs211:winter2012:journals:richard:chap6 [2012/03/28 03:07] – created marmorsteinrcourses:cs211:winter2012:journals:richard:chap6 [2012/03/28 03:22] (current) marmorsteinr
Line 10: Line 10:
 Then, they write the recursive algorithm like that, but uh oh...turns out to be exponential because you have to recalculate the value every time. But then comes along memoization to save the day, which just stores the value of every run of OPT(j) so it doesn't have to be recalculated in later calls. Brilliant. Last, they cover tracing back through the memoization array to identify the components of the solution instead of just the value. Then, they write the recursive algorithm like that, but uh oh...turns out to be exponential because you have to recalculate the value every time. But then comes along memoization to save the day, which just stores the value of every run of OPT(j) so it doesn't have to be recalculated in later calls. Brilliant. Last, they cover tracing back through the memoization array to identify the components of the solution instead of just the value.
  
 +Readability: 8/10
 ==6.2== ==6.2==
 This section just points out that the whole recursion thing is unnecessary. You can't compute the final values of the solution (the end of the memoization array) unless you have the first value--so you might as well quit trying to start from the end and doing all those backwards calls--just start constructing the array iteratively from the beginning. This section just points out that the whole recursion thing is unnecessary. You can't compute the final values of the solution (the end of the memoization array) unless you have the first value--so you might as well quit trying to start from the end and doing all those backwards calls--just start constructing the array iteratively from the beginning.
Line 18: Line 19:
 "(iii) There is a natural ordering on subproblems from "smallest" to "largest," together with an easy-to-compute recurrence that allows one to determine the solution to a subproblem from the solutions to some number of smaller subproblems." "(iii) There is a natural ordering on subproblems from "smallest" to "largest," together with an easy-to-compute recurrence that allows one to determine the solution to a subproblem from the solutions to some number of smaller subproblems."
  
 +Readability: 8/10
  
 ==6.3== ==6.3==
Line 29: Line 30:
 OPT(j) = min {1<i<j} (e_{i, j} + C + OPT(i - 1)). OPT(j) = min {1<i<j} (e_{i, j} + C + OPT(i - 1)).
  
-The algorithm is possible to run in O(n^2). Exciting!+The algorithm is possible to run in O(n^2).  
 + 
 +Readability 10/10 (I was surprised it was so easy to follow even though I skipped lecture)
  
 ==6.4== ==6.4==
 +This section introduces the knapsack problem, but first  a scheduling problem where you want to pack as many jobs with given weights onto a machine so it's as busy as possible. They demonstrate that some intuitive greedy solutions don't work, and then try doing it the same way as they solved Weighted Interval scheduling--but that doesn't work out either because removing an job from consideration doesn't just narrow the set of remaining jobs--it also decreases the available weight. But all is not lost--you just have to add another variable to the OPT, and get a lot more subproblems--which you can iterate through, and you get a two-dimensional memoization array. The algorithm is O(nW), where n is the num of jobs and W is the amount of time you're trying to fill up.
  
 +The knapsack problem is a little different, because instead of just trying to fill up something to the max, each item you have has a value, and you're trying to maximize value. The subset sums is pretty much a special case of the knapsack problem where the value of every item is equal to its weight.
  
- +Readability: 7/10
courses/cs211/winter2012/journals/richard/chap6.1332904052.txt.gz · Last modified: 2012/03/28 03:07 by marmorsteinr
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0