a
To prove the problem of determining the minimum number of bins required is NP-HARD.
a
Explanation of Solution
Suppose and are the same (indeed if the answer is yes for. Then there exists . On the other hand if the answer is yes for , so if
Note that
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
Now
b
To argue that the optimal number of bins required is at least
b
Explanation of Solution
Consider the packing ofn objects with sizes
Let
Therefore,
Since bis an integer number,
c
To argue that the first-fit heuristic leaves at most one bin less than half full.
c
Explanation of Solution
The first- fit heuristic places each object in the first available bin. Suppose by contradiction that two bins
d
To prove that the number of bins used by the first-fit heuristic is never more than
d
Explanation of Solution
Consider a bin- packing solution provided by the first-fit HEURISTIC.
Using similar notation as in (b) (let
It can be assumed without loss of generality that
e
To prove an approximation ratio of 2 for the first-fit heuristic.
e
Explanation of Solution
Letb be the number of the bins used the first-fit HEURISTIC and let
e
To give an efficient implementation of the first-fit heuristic, and analyze its running time.
e
Explanation of Solution
1.
2. initialize data structures
3. fori = 1 to ndo
4. letjbe the first bin that can fit objecti with size
5. ifjexists then
6. inserti at the list (list
7.update data structures
8.else
9.
10. insertiat the list
11.update data structures II
12.endif
13. endfor
Each of the above steps can be done in
Want to see more full solutions like this?
Chapter 35 Solutions
Introduction to Algorithms
- Please answer the following question in detail. With all the proofs and assumptions explained. We have seen various search strategies in class, and analyzed their worst-case running time. Prove that any deterministic search algorithm will, in the worst case, search the entire state space. More formally, we define a search problem by a finite set of states S, a set of actions A, and a cost function c : S ×A×S → {1,∞} (i.e. the cost is uniform, but some states cannot be reached from some others, or equivalently have a cost of ∞), and a starting state s0 ∈ S. We assume that every state s ∈ S is reachable from s0, i.e. that there is a sequence of actions one can take from state s0 such that one reaches the state s after performing this sequence of actions, and such that the cost of reaching s is finite. Prove the following theorem. Theorem1. LetAlgbesomecomplete, deterministic uninformed search algorithm. Then for any search problem defined as above, there exists some choice of a state…arrow_forwardConsider the problem of finding a maximum weight spanning tree of a given weighted connected undirected graph. Another words, you would like to have an algorithm that finds a spanning tree with the largest possible total edge weight. Describe such algorithm in pseudocode, give a justification of correctness of your algorithm, and discuss the running time. For this use “reduce to known” technique: assume that you can call Prim’s algorithm as described in class, but you can not modify the algorithm to adjust it to your problem (however, you a free to modify the given input graph).arrow_forwardSolve the problems below using the pigeonhole principle: A) How many cards must be drawn from a standard 52-card deck to guarantee 2 cardsof the same suit? Note that there are 4 suits. B) Prove that if four numbers are chosen from the set {1, 2, 3, 4, 5, 6}, at least onepair must add up to 7.Hint: Find all pairs of numbers from the set that add to 7.C) Prove that for any 10 given distinct positive integers that are less than 100, thereexist two different non-empty subsets of these 10 numbers, whose members have the samesum.An example of the 10 given numbers could be 23, 26, 47, 56, 14, 99, 94, 78, 83, 69. Onesubset of the 10 numbers could be {23, 26, 47, 56}, and another subset could be {83, 69}.The sum of the elements in the first set is 152, and it is equal to the sum of the elements inthe second subset.Hint: identify how many pigeons and how many holes you have before using the pigeonholeprinciple.arrow_forward
- Single Point based Search: Fair share problem: Given a set of N positive integers S={x1, x2, x3,…, xk,… xN}, decide whether S can be partitioned into two sets S0 and S1 such that the sum of numbers in S0 equals to the sum of numbers in S1. This problem can be formulated as a minimisation problem using the objective function which takes the absolute value of the difference between the sum of elements in S0 and the sum of elements in S1. Assuming that such a partition is possible, then the minimum for a given problem instance would have an objective value of 0. A candidate solution can be represented using a binary array r=[b1, b2, b3,…, bk,… bN], where bk is a binary variable indicating which set the k-th number in S is partitioned into, that is, if bk =0, then the k-th number is partitioned in to S0, otherwise (which means bk =1) the k-th number is partitioned in to S1. For example, given the set with five integers S={4, 1, 2, 2, 1}, the solution [0,1,0,1,1] indicates that S is…arrow_forwardCan anyone help me with this question? Assume there is a villiage with 3 houses whose owner's strongly dislike eachother. So they wish to make sure not to run into each other on their daily shopping trips to the four different shops in the villiage. a, can they build a road from every house to every shop such that 2 roads never cross? (roads do not have to be straight) b, what is the maximal number of shops for which the house owners could build non intersecting roads? Justify the answer. Thank youarrow_forwardWe have to create a seating plan for conference. As an input, we have: All people - set named AP Set of people, that has to sit together - set named ST Set of people, that can't sit together - set named NST Number of tables - named NT Number of seats at the table - named NS Relation between elements of sets NT and NP is binary ireflexive. Prove, that out problem P is NP-complete problem. Reduce from Graph Coloring Problem to our P problem. I think, we have to construct a Turing machine working in polynomial time (there is no need to construct, just describe the working process of Touring machine). Also describe the reduction function. In my opinion, output should be string <AP>/<ST>/<NST>/<NT>/<NS>. The number of tables NT should be determined from graph, also the number of seats at the table NS. That's what I think. Thank you!arrow_forward
- 4. Reducibility, NP-completeness 4a. Recall that linear ax + b = 0 is reducible to the quadratic ax²+bx+c=0. Show that the quadratic ax2+bx+c=0 is reducible to quartic ax*+bx+cx+dx+e=0 (Lec14.1). Is quartic reducible to quadratic? 4b. Consider the 4-way Partition Problem: Given a set S of positive integers, determine whether S can be partitioned into four subsets S1, S2, S3, and S4 such that the sum of the numbers in S, is equal to S2, S3, and S4. Demonstrate that the problem is NP-complete based on NP-completeness of the 2-way Partition Problem. 4c. Prove that P != NP.arrow_forwardCorrect answer will be upvoted else downvoted. Computer science. change b1,b2,… ,bn permits a stretch [l′,r′] to holds its shape if for any pair of integers (x,y) with the end goal that l′≤x<y≤r′, we have bx<by if and provided that ax<ay. A change b1,b2,… ,bn is k-comparative if b permits all stretches [li,ri] for all 1≤i≤k to hold their shapes. Yuu needs to sort out all k-comparable changes for Touko, however it turns out this is an exceptionally hard undertaking; all things considered, Yuu will encode the arrangement of all k-comparable stages with coordinated acylic diagrams (DAG). Yuu likewise authored the accompanying definitions for herself: A change b1,b2,… ,bn fulfills a DAG G′ if for all edge u→v in G′, we should have bu<bv. A k-encoding is a DAG Gk on the arrangement of vertices 1,2,… ,n with the end goal that a stage b1,b2,… ,bn fulfills Gk if and provided that b is k-comparative. Since Yuu is free today, she needs to sort out the base number of…arrow_forwardConsider the following problem for path finding where S is the source, G is the Goal and O are obstacles. We can only move horizontally and vertically (not diagonally). We will not re-visit an already visited cell. - Simulate the application of Breadth-first search tree to find all paths from S to G. Provide the order of visit for each node. - Simulate the application of Depth-first search tree to find all paths from S to G. Provide the order of visit for each node. S O G Oarrow_forward
- Given a set S of integers, we say that S can be partitioned if it can be split into two disjoint sets Uand Vwhose sums are equal–in other words, we can take sets ? and ? so that ?∪?=?, ?∩?=∅, and ∑??∈?=∑??∈?. Let PARTITION= { <S> | Scan be partitioned }. a.Show that PARTITION NP by writing either a verifier or an NDTM. b.Show that PARTITIONis NP-complete by reduction from SUBSET-SUM.arrow_forwardIf sets A={10,20,30,40} B ={30,40,50,60} C= {50,60,70} U = {10,20,30,40,50,60,70}What is the cardinality of A? DO NOT FORGET TO ENCLOSE YOUR ANSWERS IN A BRACKET { } IF IT IS A SET.arrow_forwardfor G such that1. cq,0c2 ..... cx r e A, and2. G c~l,0h ..... ct, is the pointwise stabilizer of A in G.Applying the base change algorithm if necessary, we may assume a strong generating set S ofU relative to B is known.Let us return to the above example where G is the symmetries of the square acting on pairs ofpoints and A is A 1 , the set of edges of the square. The points (x I =1 and cz2=3 form a base forG, so G1,3 = G1,3,4,6 = < identity > (and s=0). Hence, ~1 =1 and ~2=2 form a base for imrThe stabiliser G 1 is generated by b• so {a,b,bxa} is a strong generating set of Grelative to the chosen base. Furthermore, the stabiliser of 1 in imr is generated by bxa=(2,3).Hence, the set of images { -d, b, bxa } = { (1,3,4,2), (1,2)(3,4), (2,3) } is a strong generatingset of im(p relative to the base [1,2]. The kernel of the homomorphism is the trivial subgroup,< identity > perform each of the basic tasks :arrow_forward
- Operations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks Cole