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

Can someone please give me any hints to Q4 in ps8?? I am horribly stuck. I understand how the recursive helper function used in Q3 works and am using a slightly modified version of it. I do not know what to memoize. Right now I am memoizing the counter/index (i) and subsetWork values.

OpenStudy (anonymous):

http://pastebin.com/h3hsKrNN

OpenStudy (anonymous):

if you want to look at my code for Q4, please use the above link

OpenStudy (anonymous):

I will have alook at your code. This was one of th emost tasking problems I've seen in this course so far. Here's how I solved it. (I got clues from looking at other people's soluiton). http://pastebin.com/QQRmkQvS

OpenStudy (anonymous):

srry for double posting.

OpenStudy (anonymous):

thank you so much mercutio22......this problem was certainly killing me. I am wondering if the guys at ocw should consider changing their implementation of bruteforceadvisorhelper function to make life easier for students as it is really very tough to understand that implementation and convert it into one that uses dynamic programming. But maybe my approach was wrong and I should have tried to use my own implementation variant in dpadvisorhelper rather than copying the one provided in bruteforceadvisorhelper. Thanks once again. Now that I know that this problem CAN be solved I will try coding my own implementation variant with dynamic programming.

OpenStudy (anonymous):

Alright, glad to know that was helpful. Tell me if there's anything in my code you don't understand. The trick is creating not only a memo to remember the best value achievable but also another memo to remember the item combo that achieves it.

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!