Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
courses:cs211:winter2014:journals:shannon:chapter6 [2014/03/25 03:45] – [Section 6.2: Principles of Dynamic Programming: Memoization or Iteration over Subproblems] nollets | courses:cs211:winter2014:journals:shannon:chapter6 [2014/03/25 04:59] (current) – [Section 6.4: Subset Sums and Knapsacks: Adding a Variable] nollets | ||
---|---|---|---|
Line 21: | Line 21: | ||
This section helped to clarify some of my questions about the first problem we solved. it was short and provided a solid map for other types of dynamic programming problems. I would give this section a 8/10. | This section helped to clarify some of my questions about the first problem we solved. it was short and provided a solid map for other types of dynamic programming problems. I would give this section a 8/10. | ||
====Section 6.3: Segmented Least Squares: Multi-way Choices==== | ====Section 6.3: Segmented Least Squares: Multi-way Choices==== | ||
+ | |||
+ | This section discussing the problem of finding lines of best fit to represent | ||
+ | We define the penalty of a segment to be Lc + E where L is the number of lines, c is the cost of a line, and E is the error of the line. We want to find a partition of minimum penalty. | ||
+ | Starting at the last point, we know that this point belongs to one segment in the optimal solution and that segment starts at an earlier point. We then develop the algorithm on page 265 of the text. This computes the least squared errors of sequential sets of points | ||
+ | Then to find the values we output the segments with the minimum error. | ||
+ | This algorithm with run in O(n^3) error as there are O(n^2) pairs and O(n) time is needed to compute the error values. | ||
+ | |||
+ | This is important in modeling data sets. | ||
+ | |||
+ | I would give this section a 7/10 as it was a little confusing at first to understand the type of subproblem we needed to divide this problem into. | ||
====Section 6.4: Subset Sums and Knapsacks: Adding a Variable==== | ====Section 6.4: Subset Sums and Knapsacks: Adding a Variable==== | ||
+ | |||
+ | This section discusses the problem where we have a container with a fixed capacity and a number of items with fixed weights and values. We want to fill the container with the objects that will maximize its value. This problem cannot be solved by the " | ||
+ | We create a table with an increasing bag capacity across the top and an increasing number of items down the side. This way we are able to compute the maximum value at any given capacity. | ||
+ | Then, given a capacity, we are able to determine what items would give us the maximized value. The algorithm, given on page 269, or the text outlines how to generate this table and fill it in. | ||
+ | This algorithm runs in O(nW) time which is pseudo-polynomial as it is not just based off of the input size n, but also off of the weight capacity W since we iterate through the possible capacities. | ||
+ | A common version of this problem is the knapsack problem, which we discussed in class. | ||
+ | I thought some of the discussion in class ended up being more confusing in helpful as I think some students were getting themselves lost. However, the book helped make everything very clear. So did running through the complete example in class. | ||
+ | |||
+ | I would give this section a 8/10 because I think this is a cool problem and I can think of real world applications for the algorithm which makes working through them that much easier! |