MIT OpenCourseWare: Free Courses from the institute

18. Dynamic Programming, Part 4: Rods, Subset Sum, Pseudopolynomial

MIT OpenCourseWare: Free Courses from the institute

Summary

The final lecture of the dynamic programming course focuses on the concept of pseudopolynomial time and its application to two key problems: rod cutting and subset sum. The discussion begins with a review of the importance of defining subproblems correctly, emphasizing that the choice of subproblems is critical to developing efficient algorithms.

In the rod cutting problem, participants learn to maximize the total value obtained from cutting a rod of a given length into smaller pieces. The approach involves determining the best way to partition the rod based on the values assigned to each possible length. The lecture illustrates this with an example, demonstrating that while a greedy heuristic might suggest one optimal solution, a more thorough examination reveals a better combination that yields a higher total value.

The subset sum problem is introduced next, where the goal is to determine if any subset of a given set of integers sums to a specified target. The discussion highlights the binary choices involved in including or excluding each integer in the subset and how this leads to a recursive structure that can be efficiently solved using dynamic programming techniques. The lecture concludes with a reflection on the broader implications of these dynamic programming techniques, noting the distinctions between polynomial, pseudopolynomial, and strongly polynomial time complexities, and their relevance in algorithm design.

Show Notes

MIT 6.006 Introduction to Algorithms, Spring 2020Instructor: Erik DemaineView the complete course: https://ocw.mit.edu/6-006S20YouTube Playlist: https://www.youtube.com/playlist?list=PLUl4u3cNGP63EdVPNLG3ToM6LaEUuStEYUploaded 13-09-21This is the fourth and final lecture on dynamic programming. This class focusses on integer subproblems and pseudopolynomial time. Two worked examples are given: rod cutting and subset sum.License: Creative Commons BY-NC-SAMore information at https://ocw.mit.edu/termsMore courses at https://ocw.mit.eduSupport OCW at http://ow.ly/a1If50zVRlQWe encourage constructive comments and discussion on OCW’s YouTube and other social media channels. Personal attacks, hate speech, trolling, and inappropriate comments are not allowed and may be removed. More details at https://ocw.mit.edu/comments. Learn more about your ad choices. Visit megaphone.fm/adchoices Learn more about your ad choices. Visit megaphone.fm/adchoices

More from MIT OpenCourseWare: Free Courses from the institute

Dec 6, 2026

MIT 14.12 Economic Applications of Game Theory, Fall 2025 Instructor: Ian Ball View the complete course: https://ocw.mit.edu/courses/14-12-economic-applications-of-game-theory-fall-2025/YouTube Playlist: https://www.youtube.com/playlist?list=PLUl4u3cNGP63quuKvMHCt3cmTmt0O2qpvUploaded 18-05-26This lecture explores how companies compete and decide what prices to charge. Using real-world examples like oil production and cell phone companies, the instructor explains why some markets have one dominant player (like a local monopoly) while others have many competitors. License: Creative Commons BY-NC-SAMore information at https://ocw.mit.edu/termsMore courses at https://ocw.mit.eduSupport OCW at http://ow.ly/a1If50zVRlQWe encourage constructive comments and discussion on OCW’s YouTube and other social media channels. Personal attacks, hate speech, trolling, and inappropriate comments are not allowed and may be removed. More details at https://ocw.mit.edu/comments. Learn more about your ad choices. Visit megaphone.fm/adchoices Learn more about your ad choices. Visit megaphone.fm/adchoices

Dec 6, 2026

MIT 8.701 Introduction to Nuclear and Particle Physics, Fall 2020Instructor: Markus Klute View the complete course: https://ocw.mit.edu/8-701F20YouTube Playlist: https://www.youtube.com/playlist?list=PLUl4u3cNGP60Do91PdN978llIsvjKW0auUploaded 24-06-21Discussion of the early history and people in nuclear and particle physics from the 1820s to 1939.License: Creative Commons BY-NC-SAMore information at https://ocw.mit.edu/termsMore courses at https://ocw.mit.eduSupport OCW at http://ow.ly/a1If50zVRlQWe encourage constructive comments and discussion on OCW’s YouTube and other social media channels. Personal attacks, hate speech, trolling, and inappropriate comments are not allowed and may be removed. More details at https://ocw.mit.edu/comments. Learn more about your ad choices. Visit megaphone.fm/adchoices Learn more about your ad choices. Visit megaphone.fm/adchoices

Dec 6, 2026

MIT 18.404J Theory of Computation, Fall 2020Instructor: Michael SipserView the complete course: https://ocw.mit.edu/18-404JF20YouTube Playlist: https://www.youtube.com/playlist?list=PLUl4u3cNGP60_JNv2MmK3wkOt9syvfQWYUploaded 06-10-21Quickly reviewed last lecture. Discussed a connection between games and quantifiers. Described the formula game and showed that generalized geography is PSPACE-complete. Introduced log space: L and NL. Defined the configuration graph to prove NL is a subset of P.License: Creative Commons BY-NC-SAMore information at https://ocw.mit.edu/termsMore courses at https://ocw.mit.eduSupport OCW at http://ow.ly/a1If50zVRlQWe encourage constructive comments and discussion on OCW’s YouTube and other social media channels. Personal attacks, hate speech, trolling, and inappropriate comments are not allowed and may be removed. More details at https://ocw.mit.edu/comments. Learn more about your ad choices. Visit megaphone.fm/adchoices Learn more about your ad choices. Visit megaphone.fm/adchoices

Dec 6, 2026

MIT 2.997 Direct Solar/Thermal To Electrical Energy Conversion Technologies, Fall 2009Instructor: Prof. Gang ChenUploaded 26-06-24View the complete course: https://ocw.mit.edu/courses/2-997-direct-solar-thermal-to-electrical-energy-conversion-technologies-fall-2009/YouTube Playlist: https://www.youtube.com/playlist?list=PLUl4u3cNGP62sv7_wYRKqvf1HsL4p54KjRichardson formulaThermionic engines: vacuum, solid-stateSchottky barrier and diodepn junction and diodeLicense: Creative Commons BY-NC-SAMore information at https://ocw.mit.edu/termsMore courses at https://ocw.mit.eduSupport OCW at http://ow.ly/a1If50zVRlQWe encourage constructive comments and discussion on OCW’s YouTube and other social media channels. Personal attacks, hate speech, trolling, and inappropriate comments are not allowed and may be removed. More details at https://ocw.mit.edu/comments. Learn more about your ad choices. Visit megaphone.fm/adchoices Learn more about your ad choices. Visit megaphone.fm/adchoices

Dec 6, 2026

MIT 14.12 Economic Applications of Game Theory, Fall 2025 Uploaded 18-05-26Instructor: Ian Ball View the complete course: https://ocw.mit.edu/courses/14-12-economic-applications-of-game-theory-fall-2025/YouTube Playlist: https://www.youtube.com/playlist?list=PLUl4u3cNGP63quuKvMHCt3cmTmt0O2qpvIn this lecture, Ian Ball discusses infinitely repeated games, which are scenarios where players engage in the same stage game indefinitely, allowing for cooperation that wouldn't exist in one-shot games. License: Creative Commons BY-NC-SAMore information at https://ocw.mit.edu/termsMore courses at https://ocw.mit.eduSupport OCW at http://ow.ly/a1If50zVRlQWe encourage constructive comments and discussion on OCW’s YouTube and other social media channels. Personal attacks, hate speech, trolling, and inappropriate comments are not allowed and may be removed. More details at https://ocw.mit.edu/comments. Learn more about your ad choices. Visit megaphone.fm/adchoices Learn more about your ad choices. Visit megaphone.fm/adchoices

See all episodes →