Click here to Skip to main content
16,015,393 members
Home / Discussions / C#
   

C#

 
AnswerRe: Why we use the attribute of class or function Pin
DaveyM696-Jun-08 22:06
professionalDaveyM696-Jun-08 22:06 
Questionhow i can handle the close button Of Form Pin
wasimsharp6-Jun-08 20:19
wasimsharp6-Jun-08 20:19 
AnswerRe: how i can handle the close button Of Form Pin
DaveyM696-Jun-08 21:17
professionalDaveyM696-Jun-08 21:17 
GeneralRe: how i can handle the close button Of Form Pin
wasimsharp6-Jun-08 21:30
wasimsharp6-Jun-08 21:30 
GeneralRe: how i can handle the close button Of Form Pin
DaveyM696-Jun-08 22:07
professionalDaveyM696-Jun-08 22:07 
QuestionBest fit algo Pin
deezZ6-Jun-08 19:07
deezZ6-Jun-08 19:07 
AnswerRe: Best fit algo Pin
Guffa7-Jun-08 0:03
Guffa7-Jun-08 0:03 
AnswerRe: Best fit algo Pin
Robert.C.Cartaino7-Jun-08 5:04
Robert.C.Cartaino7-Jun-08 5:04 
You don't define "best fit" based on your needs (i.e. largest first, most-used first, etc) but, based on your example, I'll assume you need a solution to what is called a "bin packing problem" (see google.com). A bin-packing problem solves the problem of fitting different-sized objects (data) into a number of specifically-sized containers without being able to split objects between containers.

The solution you choose will depend on your requirements. The optimum solution (the absolute best possible fit) is computationally complex with longer execution times. A "good enough" solution will be simpler and will likely run in the amount of time you need to complete the task.

Here are some of the simpler solutions:

1. First Fit Decreasing - Sort the items (largest first), then place each item in the first container it will fit in.

2. Best Fit Decreasing - Sort the items (largest first), then place each item in the container that leaves the least room left over (tightest fit).

With these two algorithms, you should need no more than ~120% + 1 more containers than the optimal solution. If you don't sort the items first, I think you need 170% + 1 (or 2?) more containers than the optimum solution.

Best solutions depend on how big the items are in relation to your container (lots of little items in large container or larger items in "close fit" containers) and how much the item sizes and container sizes vary. Then you have to worry about whether you will be adding and removing items on an on-going basis (fragmentation occurs) or if you can move data once it is placed in a container (optimization).

For a start, see if "Best Fit Decreasing" works in your case. It's pretty easy to implement, assuming I even have your problem defined correctly.

Robert C. Cartaino
QuestionSeeing which thread owns a lock Pin
K.L.K6-Jun-08 18:53
K.L.K6-Jun-08 18:53 
QuestionProcess.Start C# Pin
satsumatable6-Jun-08 11:47
satsumatable6-Jun-08 11:47 
AnswerRe: Process.Start C# Pin
PIEBALDconsult6-Jun-08 13:24
mvePIEBALDconsult6-Jun-08 13:24 
QuestionProcess.Start on Vista return invalid Process Pin
dcabrames6-Jun-08 8:37
dcabrames6-Jun-08 8:37 
AnswerRe: Process.Start on Vista return invalid Process Pin
Giorgi Dalakishvili6-Jun-08 9:53
mentorGiorgi Dalakishvili6-Jun-08 9:53 
GeneralRe: Process.Start on Vista return invalid Process Pin
dcabrames6-Jun-08 10:20
dcabrames6-Jun-08 10:20 
GeneralRe: Process.Start on Vista return invalid Process Pin
Giorgi Dalakishvili6-Jun-08 10:32
mentorGiorgi Dalakishvili6-Jun-08 10:32 
GeneralRe: Process.Start on Vista return invalid Process Pin
dcabrames9-Jun-08 3:24
dcabrames9-Jun-08 3:24 
GeneralRe: Process.Start on Vista return invalid Process Pin
Giorgi Dalakishvili9-Jun-08 3:43
mentorGiorgi Dalakishvili9-Jun-08 3:43 
GeneralRe: Process.Start on Vista return invalid Process Pin
dcabrames9-Jun-08 5:01
dcabrames9-Jun-08 5:01 
GeneralRe: Process.Start on Vista return invalid Process Pin
Giorgi Dalakishvili9-Jun-08 5:13
mentorGiorgi Dalakishvili9-Jun-08 5:13 
QuestionWCF DataContractFormat for System.Exception Pin
bit_cmdr6-Jun-08 7:34
bit_cmdr6-Jun-08 7:34 
QuestionFile IO Pin
netJP12L6-Jun-08 5:40
netJP12L6-Jun-08 5:40 
AnswerRe: File IO Pin
Colin Angus Mackay6-Jun-08 5:59
Colin Angus Mackay6-Jun-08 5:59 
GeneralRe: File IO Pin
Spacix One6-Jun-08 9:09
Spacix One6-Jun-08 9:09 
GeneralRe: File IO Pin
Colin Angus Mackay6-Jun-08 9:50
Colin Angus Mackay6-Jun-08 9:50 
AnswerRe: File IO Pin
Spacix One19-Jun-08 2:28
Spacix One19-Jun-08 2:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.