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

PS8#2: Greedy advisor. I've implemented a greedy advisor program. However, it's more brute force than elegance. I think the intuitive approach would be to do pre-processing and create sorted lists of tuples (where the tuple is (subject string, value/work/ratio). Then the program would simply read down the list. However, it seems that's not the approach the professor's wanted us to use as they specified that the function should take the comparator as an argument. Here's my implementation http://codepad.org/AjXZL6jD Did anyone come up with a simpler approach?

OpenStudy (anonymous):

to understand how greedyAdvisor works, getDictMax runs through the entire dictionary each time it's called and returns the maximum value using the comparator. It's pretty simply, it cycles through the dictionary, puts the dictionary entry into the comparator, and saves it if value the comparator says it great. http://codepad.org/g9HD6B3J

OpenStudy (anonymous):

i just went thru the dictionary and picked the best subject, amended maxWork then did it again and again ... til it was done here is mine with a small subject dictionary and a test function http://pastebin.com/HdZ9ssQM

OpenStudy (anonymous):

bwCA , my solution is similar to yours but I feel there is a better solution that just seeing if the given comparator is cmpWork , but I still can't find it :( http://pastebin.com/NbmEMHLn

OpenStudy (maitre_kaio):

To do this preprocessing, you would have to sort the whole subjects dictionary, right ? Complexity is O(n log n) in the best case, I think. With the solution proposed in the assignment, you just have to go through the whole list k times, k being the number of selected subjects, which is very small. Complexity is roughly O(kn). So the second solution is better when k is << n, which is the case.

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!
Latest Questions
Graysonunderwoods: Have you even been beaten by a wet spaghetti noodle by your girlfriend because sh
3 minutes ago 5 Replies 0 Medals
AsianPanda08: What should i eat for dinner tonight? I can't choose
1 hour ago 51 Replies 2 Medals
Nina001: Trying 2 figure out what is the square root of 8746685
16 minutes ago 30 Replies 2 Medals
SnowyBreaks: Is it bad to lose 3.8 pounds in less than 2 days?
47 minutes ago 43 Replies 0 Medals
kaelynw: tried a lil smt, the arm is off but i like the other stuff
58 seconds ago 15 Replies 2 Medals
laylasnii13: Who wanna write or make a song with me???
5 hours ago 8 Replies 0 Medals
kaelynw: art igg
13 hours ago 13 Replies 2 Medals
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!