Learn faster and stay on-track by joining this free class with other self-learners.
Register for MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming now.
|
MIT OpenCourseWare 6.00 Introduction to Computer Science and ProgrammingClass length: 24 weeks. Start anytime. Creator: duallain Status: Established |
Join this class! |
|
Solution to part 4 of problem set 8Hi. I am looking for a solution to PS8. Where can I find a list of submitted solutions? I've found solutions by doing a web search on 'dpAdvisor'. There are some posted here and at least one posted at MIT. [edit: inaccurate statement removed. Apologies to all.] Guttag even mentions during lecture that solving similar problems may involve changing the memo or the constraints or both. I've created a solution that uses the lecture's fastMaxVal() function as a starting point. The trick, if there is one, is to modify the memo to track the subjects that makeup the maximum. As an indicator of the value of the solution, my greedyAdvisor gets a result in 2.2 seconds; the dpAdvisor gets the result shown in the problem set in 0.05 seconds. Hope this helps. George How do the solutions listed here not follow dynamic programming? A few, if not all that have #4 solved do it by breaking the problem down into smaller problems (usually by recursion) and memoizing the result so that it does not have to be calculated again. I retract my comment - I did not read closely enough. Thus I violated the one of the debug principles in Lectures 11 & 12: READ THE CODE. For this I apologize. An unnecessary rudeness on my part. I'll submit my solution although it's incomplete - it does not include any commentary on performance. At least one can see where I was coming from. g No problem, I just wanted to make sure I did not misunderstand the concept The only real difference, I suspect, between our solutions is that your variable names are longer! And my attention span is getting too short. Regards, g Where did you post your solution? Can I see it? http://curiousreef.com/class/mit-opencourseware-600-introduction/lesson/14/assgn/1/ Click on Lecture 14 in column on the left side of the screen. Below the video lecture is a link to posted assignments. g I see now. Thanks!
* Markdown Cheatsheet:
Link:
New Paragraph:
Main heading:
Sub-heading:
List:
Italics:
Bold:
YouTube:
|