1 / 16

Best-fit bin packing in O(n log n) time

Best-fit bin packing in O(n log n) time. The search tree will contain one element for each bin which is in use and has non-zero available capacity. Notice! It is possible that for two or more bins to have the same available capacity. Best-fit bin packing in O(n log n) time. Example

etoile
Download Presentation

Best-fit bin packing in O(n log n) time

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Best-fit bin packing inO(n log n) time • The search tree will contain one element for each bin which is in use and has non-zero available capacity • Notice! It is possible that for two or more bins to have the same available capacity

  2. Best-fit bin packing inO(n log n) time • Example • Suppose that when object i is to be packed, there are nine bins (a through i) in use. • Available capacity of these bins are 1, 3, 12, 6, 8, 1, 20, 6 and 5, respectively. • The nine bins may be stored in a binary tree with duplicates, using as key the available capacity of a bin.

  3. e 8 Best-fit bin packing inO(n log n) time • A possible binary search tree. h 6 b c 3 12 a i g d 20 1 5 6 f 1

  4. e 8 Best-fit bin packing inO(n log n) time • Object I that is to be packed requires s[i] = 4. h • Root h fits, proceeds to the left subtree. 6 b c 3 12 a i g d 20 1 5 6 f 1

  5. e 8 Best-fit bin packing inO(n log n) time • Object I that is to be packed requires s[i] = 4. h 6 b c 3 12 a i g d 20 1 5 6 f 1

  6. e 8 Best-fit bin packing inO(n log n) time • Object I that is to be packed requires s[i] = 4. h • b fails, proceeds to the right subtree of b. 6 b c 3 12 a i g d 20 1 5 6 f 1

  7. e 8 Best-fit bin packing inO(n log n) time • Object I that is to be packed requires s[i] = 4. h 6 b c 3 12 a i g d 20 1 5 6 f 1

  8. e 8 Best-fit bin packing inO(n log n) time • Object I that is to be packed requires s[i] = 4. h • i fits, proceeds to the left subtree of i. 6 b c 3 12 a i g d 20 1 5 6 f 1 • idoesn’t have any left child, it is the best candidate.

  9. e 8 Best-fit bin packing inO(n log n) time • Another example, object I that is to be packed requires s[i] = 7. h • h fails, proceeds to the right subtree of h. 6 b c 3 12 a i g d 20 1 5 6 f 1

  10. e 8 Best-fit bin packing inO(n log n) time • Another example, object I that is to be packed requires s[i] = 7. h 6 b c 3 12 a i g d 20 1 5 6 f 1

  11. Best-fit bin packing inO(n log n) time • Another example, object I that is to be packed requires s[i] = 7. h • c fits, proceeds to the left subtree of c. 6 b c 3 12 a i g d 20 1 5 6 f e 8 1

  12. Best-fit bin packing inO(n log n) time • Another example, object I that is to be packed requires s[i] = 7. h 6 b c 3 12 a i g d 20 1 5 6 f e 8 1

  13. Best-fit bin packing inO(n log n) time • Another example, object I that is to be packed requires s[i] = 7. h • d fails, proceeds to the right subtree of d. 6 b c 3 12 a i g d 20 1 5 6 f e 8 1

  14. Best-fit bin packing inO(n log n) time • Another example, object I that is to be packed requires s[i] = 7. h 6 b c 3 12 a i g d 20 1 5 6 f e 8 1

  15. Best-fit bin packing inO(n log n) time • Another example, object I that is to be packed requires s[i] = 7. h • e fits, proceeds to the left subtree of e. 6 b c 3 12 a i g d 20 1 5 6 f e 8 1 • e has no left child, so e is the best candidate.

  16. Best-fit bin packing inO(n log n) time • When we find the best bin, we can delete it from the search tree, reduce its capacity by s[i], and reinsert it (unless its remaining capacity is zero). • If we do not find a bin with enough capacity, we can start a new bin.

More Related