Build a program in C that accomplishes the following task:
It reads from a file the names of some certain files and their size in MB, then it distributes these files to some folders each with a maximum of N MB. The way of distribution is such that a minimum number of folders is required and one file is not appearing in two folders. Then the program gives as output a file containing the name of each file and the number of the folder in which it was assigned.

Need an idea :) Thnx in advance!

Recommended Answers

All 3 Replies

>Need an idea
Well, you've got pretty much everything you need to start writing code.

Could you first write some code and post it down?
Also tell use where you've problems with to implement.

Problems in writing code?
Try to break the problem down into separate small problems (this process is also known as the process of abstraction), then you try to solve each small problem, take a pen and write your program out on paper, it will definitely help you to write the code for your program.

Got stuck at some part?
No problem! Just post where you're having difficulties with to implement and we'll be glad to help you.

Well, it sounds like a bin packing problem, which is NP-hard so there's no way to always get the optimal solution. I've done some google search to find any algorithm solving it (I really cant do it on my own, I'm a freshman in C) Here it is a useful link but still I have difficulties understanding it...http://www.cs.arizona.edu/icon/oddsends/bpack/bpack.htm

commented: Good, you know the nature of the problem then +36

Well, it sounds like a bin packing problem, which is NP-hard so there's no way to always get the optimal solution. I've done some google search to find any algorithm solving it (I really cant do it on my own, I'm a freshman in C) Here it is a useful link but still I have difficulties understanding it...http://www.cs.arizona.edu/icon/oddsends/bpack/bpack.htm

If you're in a class, then you should be able to do that at this stage, a teacher won't give you an assignment, you won't be able to complete successfully.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.