-2

Write a program to find the processes which utilize the memory optimally, given the list of the processes with their memory usage and the total memory available.

Example:- Total memory :- 10

First column denotes process id's and 2nd column is the memory consumption of respective process.

1 2
2 3
3 4
4 5

Answer should be processes {1,2,4} with memory consumption {2,3,5} as 2+3+5=10

Zephyr
  • 1,521
  • 3
  • 22
  • 42

1 Answers1

0

This question is Knapsack problem

I believe you can find many sample code on Google

CSK
  • 352
  • 1
  • 6
  • I know it resembles knapsack that's the reason I have tagged it...but its not exactly same right? – Zephyr Jun 22 '16 at 20:34
  • it is the same question on http://stackoverflow.com/questions/3420937/algorithm-to-find-which-number-in-a-list-sum-up-to-a-certain-number – CSK Jun 22 '16 at 20:55