C-Plus-Plus icon indicating copy to clipboard operation
C-Plus-Plus copied to clipboard

[FEATURE] Reduce space complexity of 0-1 Knapsack problem

Open Manan-09 opened this issue 2 years ago • 6 comments

Detailed description

We can implement 0-1 knapsack problem in O(C) space complexity , where C is weight capacity of items we are allowed to take.

As in DP table we are only interacting with above row , we just have to store one row of information , so we can reduce space complexity here.

Here is reference in which I optimised Java implementation for this problem

Context

Current implementation takes O(N * C) space complexity, which is not the optimal, we can gain same result with same Time complexity and reduced space compexity.

Possible implementation

No response

Additional information

No response

Manan-09 avatar Oct 07 '23 09:10 Manan-09

Please Assign This Issue To Me

AniketShirou avatar Oct 07 '23 16:10 AniketShirou

@AniketShirou , actully I cannot assign this to you but you work on it, No problem.

Manan-09 avatar Oct 08 '23 11:10 Manan-09

I have done this problem and variations of this problem too and I am quite familiar with the concept of using two separate vectors and updating them one by one. Kindly please assign this issue to me.

harjasae2001 avatar Oct 09 '23 05:10 harjasae2001

This issue 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.

github-actions[bot] avatar Nov 09 '23 00:11 github-actions[bot]

?

2021110906 avatar Dec 03 '23 03:12 2021110906

This issue 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.

github-actions[bot] avatar Jan 03 '24 00:01 github-actions[bot]

Please ping one of the maintainers once you add more information and updates here. If this is not the case and you need some help, feel free to ask for help in our Gitter channel or our Discord server. Thank you for your contributions!

github-actions[bot] avatar Jan 10 '24 00:01 github-actions[bot]