[algogeeks] Re: Java question

2012-03-12 Thread Gene
This is nearly what malloc() and similar memory allocators do. If you look at an operating system book or web search you'll get lots of approaches. The overall problem of finding the best allocation is NP hard, so you must use some kind of heuristic. The most common ones are called First fit

[algogeeks] Re: Java question

2012-03-10 Thread shruthi sharma
I implemented it by using arraylist. I sorted the trucks according to the free space and when a load comes I iterated till the point, say j where I find a suitable space and then sorted it with the elements till j. I want to know if I can optimize it even further if possible. I want to know if

Re: [algogeeks] Re: Java question

2012-03-10 Thread saurabh singh
Is it possible items are removed from the truck too? Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Sat, Mar 10, 2012 at 9:39 PM, shruthi sharma shruthi.shar...@gmail.comwrote: I implemented it by using arraylist. I sorted the trucks according to the

Re: [algogeeks] Re: Java question

2012-03-10 Thread Bhavani Pradeep
yeah.. they can be removed too On Sat, Mar 10, 2012 at 10:41 PM, saurabh singh saurab...@gmail.com wrote: Is it possible items are removed from the truck too? Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Sat, Mar 10, 2012 at 9:39 PM, shruthi

Re: [algogeeks] Re: Java question

2012-03-10 Thread Bhavani Pradeep
and i guess there can be multiple input loads too... i saw the same question elsewhere too -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send

Re: [algogeeks] Re: Java question

2012-03-10 Thread atul anand
how about going through every truck and doing temp=(free_space - load); if(temp min temp =0) { min=temp; truck = i; } now after traversing we have found the truck where we can add load. no need of sorting complexity =O(n) where n is number of trucks space complexity = constant On