A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 4 years ago
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 preprocessing 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?
anonymous
 4 years ago
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 preprocessing 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?

This Question is Closed

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0to 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

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0i 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

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0bwCA , 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

maitre_kaio
 4 years ago
Best ResponseYou've already chosen the best response.0To 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.
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.