Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 21 Online
OpenStudy (anonymous):

Problem set 8, Problem 4... This is the problem where you find what subjects you should take using dynamic programming. However, I'm really unsure about how to use the memo and how to return the best subjects. My strategy was to use the fastMaxVal function in the lectures, so it returns every subject that it tested. I just don't know how to return the best subjects only. Any help is appreciated! http://pastebin.com/chjstCrQ

OpenStudy (anonymous):

draw a decision tree like in the lecture, run through it by hand. at the same time, step through fastMaxVal 'by hand'. do this till you understand how fastMaxVal works then refactor fasttMaxVal so that it retains the items/subjects as well as the work and value.

OpenStudy (anonymous):

difficult to see what is going on without comments.

OpenStudy (anonymous):

Alright, I'm getting a lot closer... I'm getting the correct best value, but getting the wrong subset... I'm really confused right now, lol! http://pastebin.com/aXMV2AFL

OpenStudy (anonymous):

My implementation is a bit different to the one in the lecture but reading this article about dynamic programming made it a lot clearer for me. http://20bits.com/article/introduction-to-dynamic-programming#knapsack Read the part about the 'Knapsack Problem' especially.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!