If you want to pack files / folders onto one CD-R disc, then you can do this optimally in pseudo-polynomial time. To do this, you need to combine the file / folder sizes in the sectors and calculate the sectors available on the CD-R.
After that, we get the discrete packing problem for a 1-D backpack , which can be easily solved using dynamic programming, with complexity O (n),
More specific:
- O (n) = O (nW), the reason W in your case is constant - W is the number of sectors on the CD-R.
- n number of files / folders.
For best performance, you can always override the size of sectors, for example, setup:
- overly approximate sector size of 70 thousand
- making 700M / 70k = 10k of all sectors on a CD-R
- which should be calculated in seconds when the number of files is less than (1G / 10k = 100k) 100k - n <100'000
- in minutes when n <10'000'000
What else:
- Decision
- can be well matched.
Perhaps applying this algorithm in the greedy way of "pack one CD, pack next cd" will it work?
source share