Introduction to Algorithms
Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
Question
Book Icon
Chapter 35, Problem 1P

a

Program Plan Intro

To prove the problem of determining the minimum number of bins required is NP-HARD.

a

Expert Solution
Check Mark

Explanation of Solution

Suppose S={x1,x2,.......,xk} and x=1ikxi . It can be assumed that tx12 because the answer to and are the same (indeed if the answer is yes for. Then there exists C' such that xi=t and then there is xi(S/S')xi=Xt and so the answer is yes for. On the other hand if the answer is yes for , so if t<x/12 , it can be considered t;<xtx/2 . Then compute x=1ikxi and compare it with t .

Note that

  1inSi=1ikxi/t=1t1inxi+(2tx)/t=x/t+(2tx)/2=2

So, the answer of derived bin-packing problem can-not be less than 2 . First assume that the answer to the given instance of sub set -sum problem is “yes”.

Now, there is S'={xi1,xi2,.......,xil} so that ijlxij=t . Thus, the result is ijlSij=1<j<lxij/t=t/t=1 .

Now {Si1,Si2,.......,Sil} can be packed in one bin and the remaining objects in the other bin (the sum of all object sizes is 2. So, the sum of remaining object sizes are1). Since it is known that the answer to this bin-packing problem can’t be less than 2, so the answer to it will be 2. Now assume that the answer to the derived instance of bin-packing problem is 2. Assume {Si1,Si2,.......,Sil} be the sizes of the objects in one of two bins that does not contain the object with the size Sk+1=(2tx)/t we have ij<lSij=1

  1<j<lxij/t=11<j<lxij=t . So a subset S'={xi1,xi2,.......,xil} of S is found so that 1<j<lxij=t . Thus the answer to the given instance of the subset-sum problem is “yes”.

b

Program Plan Intro

To argue that the optimal number of bins required is at least S .

b

Expert Solution
Check Mark

Explanation of Solution

Consider the packing ofn objects with sizes S1,S2,........,SN intob bins. Let S=i=1NSi

Let e1,e2,........,eb be the unused space in each bin and let e=i=1bei

Therefore,

  b=totalspaceinbinssizeofeachbin=spaceusedinbins+spaceunusedinbins1=S+eS (sincee0).

Since bis an integer number, b[S] . This is true in particular for the optimal solution b*[S] .

c

Program Plan Intro

To argue that the first-fit heuristic leaves at most one bin less than half full.

c

Expert Solution
Check Mark

Explanation of Solution

The first- fit heuristic places each object in the first available bin. Suppose by contradiction that two bins bi and bj are half full and supposei < j. All object in would fit into since both and are half full. Therefore, the first-fit heuristic would have placed these objects in bi . Therefore, it is not possible that two bins may be half empty under the first-fit heuristic.

d

Program Plan Intro

To prove that the number of bins used by the first-fit heuristic is never more than 2S

d

Expert Solution
Check Mark

Explanation of Solution

Consider a bin- packing solution provided by the first-fit HEURISTIC.

Using similar notation as in (b) (let S=i=1NSi and e=i=1bei )

  b=S+e=S+i=1bei .......(1)

It can be assumed without loss of generality that b2 for the case whereb = 1 is easily satisfied. If all the bins are at least half full, then b=S+eS+b2 which implies b2S[2S]

e

Program Plan Intro

To prove an approximation ratio of 2 for the first-fit heuristic.

e

Expert Solution
Check Mark

Explanation of Solution

Letb be the number of the bins used the first-fit HEURISTIC and let b* be the optimal number of bins. By part (d) [S]b* . Combining both inequalities, the result is b2S[2S]2b* , therefore bb*2 that is, the approximation ratio is 2 .

e

Program Plan Intro

To give an efficient implementation of the first-fit heuristic, and analyze its running time.

e

Expert Solution
Check Mark

Explanation of Solution

Algorithm First-fit (n,S1,S2,........,SN) :

1. b0

2. initialize data structures

3. fori = 1 to ndo

4. letjbe the first bin that can fit objecti with size Si(*)

5. ifjexists then

6. inserti at the list (list L[i] of objects in bin)

7.update data structures

8.else

9.

  bb+1

10. insertiat the list L[b]

11.update data structures II

12.endif

13. endfor

Each of the above steps can be done in O(logb) basic steps. Therefore, the total running time for this algorithm is O(nlogb)O(nlogh) .

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
The Partitioning Problem: Given a set ofnpositive integers, partition the integers into two subsets of equal or almost equal sum. The goal is to partition the input numbers into two groups such that the difference between the sums of the elements in the two group is minimum or as small as possible. a)  Since no polynomial solutions are known for the above problem, implement an exponential algorithm for finding the optimal solution for any instance of the problem and test it for small input samples. Identify the maximum input size for which an optimal solution is possible to obtain using your algorithm in reasonable time (for example 3 hours). Hint: Every possible partition (solution) can be represented by a binary array of sizen
Correct answer will be upvoted else Multiple Downvoted. Computer science. Polycarp accepts that a bunch of k sections is acceptable in case there is a fragment [li,ri] (1≤i≤k) from the set, with the end goal that it converges each portion from the set (the convergence should be a point or section). For example, a bunch of 3 fragments [[1,4],[2,3],[3,6]] is acceptable, since the portion [2,3] meets each section from the set. Set of 4 fragments [[1,2],[2,3],[3,5],[4,5]] isn't acceptable.    Polycarp ponders, what is the base number of sections he has to erase so the remaining portions structure a decent set?    Input    The primary line contains a solitary integer t (1≤t≤2⋅105) — number of experiments. Then, at that point, t experiments follow.    The primary line of each experiment contains a solitary integer n (1≤n≤2⋅105) — the number of portions. This is trailed by n lines depicting the fragments.    Each section is portrayed by two integers l and r (1≤l≤r≤109) — coordinates of the…
Suppose a candidate solution p, where p is a phenotype consisting of 4 vertices. Suppose that minimum fitness occurs when no pair of vertices in p are connected, and maximum fitness occurs when all pairs of vertices in p are connected. Write a pseudocode on how to calculate the fitness F of p.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole