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
- Consider eight points on the Cartesian two-dimensional x-y plane. a g C For each pair of vertices u and v, the weight of edge uv is the Euclidean (Pythagorean) distance between those two points. For example, dist(a, h) : V4? + 1? = /17 and dist(a, b) = v2? + 0² = 2. Because many pairs of points have identical distances (e.g. dist(h, c) V5), the above diagram has more than one minimum-weight spanning tree. dist(h, b) = dist(h, f) Determine the total number of minimum-weight spanning trees that exist in the above diagram. Clearly justify your answer.arrow_forwardYour training set is made up of the following 2-dimensional points: A={a', a², a³, a², a³} {(1,0), (1,3), (3,0), (0,-2), (-2,0)}, where a', a², and a³ belong to class 1, and at, a5 to class 2. (a) Plot all samples into a 2-dimensional Cartesian axis system Calculate the Manhattan distance 1 between the test sample b=(0,0) and every a of the (b) training set (c) Use the K- Nearest Neighbor algorithm with K=1 to assign a class to 'b'. Explain (d) Classify 'b' using K=5. Explain 'Manhattan(a, b) = E; la² – b' , Vi = 1,2arrow_forwardCorrect answer will be upvoted else Multiple Downvoted. Don't submit random answer. Computer science. You are given an integer k and n particular focuses with integer facilitates on the Euclidean plane, the I-th point has arranges (xi,yi). Consider a rundown of all the n(n−1)2 sets of focuses ((xi,yi),(xj,yj)) (1≤i<j≤n). For each such pair, work out the separation from the line through these two focuses to the beginning (0,0). You will likely work out the k-th most modest number among these distances. Input The principal line contains two integers n, k (2≤n≤105, 1≤k≤n(n−1)2). The I-th of the following n lines contains two integers xi and yi (−104≤xi,yi≤104) — the directions of the I-th point. It is ensured that all given focuses are pairwise particular. Output You should output one number — the k-th littlest separation from the beginning. Your answer is considered right if its outright or relative blunder doesn't surpass 10−6. Officially, let your answer be…arrow_forward
- About a set X of numbers we say that it is almost sum-free if the sum of two different elements of X never belongs to X. For instance, the set {1, 2, 4} is almost sum-free. Almost-Schur number A(k) is the largest integer n for which the interval {1, . . . , n} can be partitioned into k almost sum-free sets. Use clingo to find the exact values of A(1), A(2), A(3) and try to find the largest lower bound for A(4), i.e., the largest number l such that A(4) ≥ l. Hint: you do not need to find all partitions to find the values of A(k). PLEASE USE CLINGO.arrow_forward; 3. Let T U V and S: V W. We have that SoT: U → W. Prove that (SoT)* = T* o S*. 4. Let v₁,.., Un EV be a basis of V. (a) Define the dual basis vi,.., v € V*. (b) Prove that formula: a = Σi-na (v₁) vi for every a € V*. i=1:n (c) Prove the reciprocal formula: v= Ei=1:n v (v) v₁ for every v € V.arrow_forwardThere are n people who want to carpool during m days. On day i, some subset si ofpeople want to carpool, and the driver di must be selected from si . Each person j hasa limited number of days fj they are willing to drive. Give an algorithm to find a driverassignment di ∈ si each day i such that no person j has to drive more than their limit fj. (The algorithm should output “no” if there is no such assignment.) Hint: Use networkflow.For example, for the following input with n = 3 and m = 3, the algorithm could assignTom to Day 1 and Day 2, and Mark to Day 3. Person Day 1 Day 2 Day 3 Limit 1 (Tom) x x x 2 2 (Mark) x x 1 3 (Fred) x x 0arrow_forward
- I need the algorithm, proof of correctness and runtime analysis for the problem. No code necessary ONLY algorithm. And runtime should be O(n + m) as stated in the question.arrow_forwardGIVEN: n red points and n blue points in the plane in general position (i.e., no 3 points are on the same line) PROVE: there exists a matching (i.e., 1-1 correspondence) between red and blue points such that the segments connecting the corresponding points do not intersect. EXTRA/HINT: describe an algorithm for finding such matchingarrow_forwardAlgorithm : Testing MembershipInput : a group G acting on f~ = { 1,2 ..... n };a permutation g of f~ = { 1,2 ..... n };a base and strong ~enerating set for G;Schreier vectors v (i) , 1 < i < k, for the stabiliser chain;Output: a boolean value answer, indicating whether g ~ G;arrow_forward
- 4) Prove that SUT=SnT for all sets S and T.arrow_forwardDevelop a dynamic programming algorithm for the knapsack problem: given n items of know weights w1, . . . , wn and values v1, . . . ,vn and a knapsack of capacity W, find the most valuable subset of the items that fit into the knapsack. We assume that all the weights and the knapsack’s capacity are positive integers, while the item values are positive real numbers. (This is the 0-1 knapsack problem). Analyze the structure of an optimal solution. Give the recursive solution. Give a solution to this problem by writing pseudo code procedures. Analyze the running time for your algorithms.arrow_forward· Tonsider a set S of 4 elements. Prove that we can choose any two subsets óf S of size 3, say A and B, and construct a matroid M = (S, 1) such that A and B are the only maximum independent sets in M.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education