Login
Search   Moderators Wanted: If you're interested please send your portfolio to info[at]itechforums.com
Welcome to the iTechForums.
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
To register now click here.
Latest Threads
Advertisements
Forum Statistics
Threads:
Posts: 3
Members:
Number of Users Online:
Welcome to our newest member,
Reply
 
Thread Tools Display Modes
  #1  
Old 06-06-2008, 06:07 PM
lilacmagic15 lilacmagic15 is offline
Junior Member
 
Join Date: Jun 2008
Posts: 4
Default

First fit sorting algorithm?


First fit sorting algorithm?

Hi can anyone tell me whether I have completed the question below correctly. If I have done it wrong could you please let me know what I have done wrong. Thankyou.

First-fit Methods
The bin-packing and ferry loading problems

Ferry loading problem

A small car-ferry has four lanes, each 18m long. The following vehicles are waiting to be loaded. Can all these vehicles be taken on one trip?

Note: The length of each type of vehicle is assumed to be as follows:
Motorbike = 2m
Car = 4m
Van = 6m
Lorry = 8m

Van Car Car Motorbike Car Lorry Car Lorry Van Car Van Lorry Van Motorbike

There are two common algorithms (or sets of instructions) that can be used to solve problems like these:

1)First-fit algorithm
Here you take the vehicles in the order listed and place each vehicle in the first available lane that the vehicle will fit into.
In general, when you are trying to sort more general items into slots, you fit the next item into the first available slot that the item will fit into.

Lane 16m4m4m2m
Lane 24m8m4m
Lane 38m6m4m
Lane 46m8m2m

The van doesn’t fit in
I don't get your answer?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2  
Old 06-06-2008, 06:08 PM
mikey mikey is offline
Junior Member
 
Join Date: Jun 2008
Posts: 8
Default

erm the answer is 0.67.5.4.6.5.4.5.
))
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 06-06-2008, 06:09 PM
Vicky S Vicky S is offline
Junior Member
 
Join Date: May 2008
Posts: 2
Default

If you use the first fit algorithm, then its true that van doesnt fit..

Try to useFirst fit decreasing method..

The solutions are:

Lane 1: 2m+8m+8m=18m
Lane 2: 6m+4m+8m=18m
Lane 3: 6m+6m+6m=18m
Lane 4: 4m+4m+4m+2m=18m
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I have found a new sorting algorithm? What should i do next? Sajal Software Design & Algorithms 0 09-03-2009 01:23 AM
Sorting algorithm pseudocode.? rjdfhorn Software Design & Algorithms 0 01-27-2009 11:04 PM
Sorting algorithm questions? oasisjoel Software Design & Algorithms 1 10-11-2008 09:51 PM
help solve algorithm problem,, please.. SORTING ALGORITHM: inputs are 7, 9, Nina Software Design & Algorithms 0 09-21-2008 05:29 PM
Sorting algorithm help PLEASE!? Jessica Software Design & Algorithms 0 05-13-2008 05:06 PM

Your Ad Here

All times are GMT. The time now is 11:50 AM.