-
-
Notifications
You must be signed in to change notification settings - Fork 766
fixes #110 #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes #110 #148
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work! 😄👍
Co-authored-by: David Leal <[email protected]>
Co-authored-by: David Leal <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀 Thank you for your contribution! 😄👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your complexity considerations seem off. You forget to elaborate on how the item with the highest efficiency is found (a naive implementation might take quadratic time, a more advanced one would use something like a heap or even a median-based algorithm).
|
||
Given a set of items, each with weight and a value, determine the number of each item included in a collection so that the total weight is less than or equal to the given limit and the total value is as large as possible. | ||
|
||
##### Greedy method will always provide an optimal solution with fractional knapsack problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not supposed to be a heading. Use a different way of emphasis. Please explicitly state that it often finds a suboptimal solution for nonfractional knapsack problems.
|
||
O(1) For iterative approach | ||
O(1) For recursive approach *if tail call optimization is used*, O(log n) due to recursion call stack, otherwise | ||
O(nlog n) Worst Case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a space. Also only the case if you presort the items (which should definitely be mentioned!). Also note that it can be done in O(n) using medians.
This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
My comments were not resolved. |
Hey, @Swastyy! If you have time, could you please address @appgurueu's comments in another PR? Let us know if you need any help! Thanks. 😃 |
Yeah, I'll do it in another PR. |
fixes #110