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

I am stuck on problem set 8 , question 4. I've tried studying the maxVal function from lecture 13, i've thrown print statments all over it, but i cant figuew out exactly how and why it works. It doesn't return all the values that my pen and paper decision tree returns. I am at the stage where i can use the slightly modified maxVal function to get me the highest Value for hours of study, but becasue I don't understand how it works completely, I can't begin to try and make it so that it also returns the subjects that provide that max value. Help?

OpenStudy (owlfred):

Hoot! You just asked your first question! Hang tight while I find people to answer it for you. You can thank people who give you good answers by clicking the 'Good Answer' button on the right!

OpenStudy (anonymous):

paste your code at dpaste.com then post the link here. I spent a very long time on that one and almost understand how it works. - I'm pretty sure my implementation works.

OpenStudy (goodbye):

Sorry for the delay, but I have completed the problem set now. I used a method that I shamelessly copied from a blog by some guy called mike coderama, who explains the knapsack problem and provides code to solve it with dynamic programming. (There are some youtube videos i watched that explain it nicely using this method also). But this method is not recursive (so i coudn't count numcalls) like the Professor's MaxVal method (which i gave up trying to use to solve the problem) http://dpaste.com/hold/552412/ ^My code for problem set 8 (neated it up as best I could, and gave it a cool menu for the user to use to navigate through the functions!!) http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/video-lectures/lecture-13/lec13.pdf ^Handout with the maxVal functions from lecture 13. I stilll cant follow the recursive method that I think we were being pushed to implement. http://dpaste.com/hold/552417/ ^My attempt at trying to figure out how maxVal works(the simple one, not with memo) I'd like to hear back from you,bwCA, and maybe check your solution aswell.

OpenStudy (anonymous):

Here is my solution - If I remember correctly I used the example in the lecture and modified it to keep track of all the list indices that were chosen - not just the value.

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!