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
udent question   Consider m rectangles, where the i-th rectangle is represented by the x- and y-coordinates Xil < Xi2 and Yil < Yi2 of its vertices. Here we assume that Yil is negative and Yi2 is positive to simplify the solution, i.e., all rectangles intersect with the x-axis. You are further given a set of n >= m points (a1, b1),(a2,b2),...,(an,bn), and would like to know whether each point is covered by at least one of the rectangles. Design an algorithm for this problem with a running time faster than O(mn), and analyze its correctness and running time.Hint: First use a divide-and-conquer algorithm to find the area covered by the rectangles, so that for any x-coordinate you can find the maximum and minimum y-coordinates covered by the rectangles. Then, process the points one by one.
In the maximum coverage problem, we have a set of n elements E, a set of m sets (whichare subsets of E), S1, S2, .., Sm. We are also given an integer m ≥ k ≥ 1. Our goal is to pick k sets thatcover the maximum number of elements. We say an element is covered if we pick at least one set fromS1, S2, .., Sm in our solution that contains that element. Devise a greedy algorithm that is a (1 −1/e) approximation. That is if there is an optimum solution thatcan cover OPT number of elements, the greedy algorithm is guaranteed to cover at least  (1 −1/e) *OPT elements. Here e is the base of natural logarithm. Use the following relation (1-1/k)k ~1/e.
Let E = {0, &} and let A = {s | s = Yı&y2& • . . &yk for k > 0, each y; E 0*, and y; Y; for i + j}. Prove that A is not regular.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education