Consider the following two problems: Bin Packing: Given n items with positive integer sizes s1, s2, . . . , sn, a capacity C for bins and a positive integer k, is it possible to pack the n items using at most k bins? Partition: Given a set S of n integers, is it possible to partition S into two subsets S1 and S2 so that the sum of the integers in S1 is equal to the sum of the integers in S2? Show that Partition polynomial-time reduces to Bin Packing.
Consider the following two problems: Bin Packing: Given n items with positive integer sizes s1, s2,...
Consider the following four problems: Bin Packing: Given n items with positive integer sizes s1,s2,...,sn, a capacity C for bins and a positive integer k, is it possible to pack the n items using at most k bins? Partition: Given a set S of n integers, is it possible to partition S into two subsets S1 and S2 so that the sum of the integers in S1 is equal to the sum of the integers in S2? Longest Path: Given...
Give an algorithm that minimizes the maximum load of bins for the following description: We are given a list of n items with sizes s1, 82,. . , Sn A sequential bin packing of these at in sad ins (That is, each bin has items si, si+1,. , s, for some indices i < j.) Bins have unbounded capacities. The load of a bin is the sum of the elements in it. Give an algorithm that determines a sequential packing...
In the bin packing problem, items of different weights (or sizes) must be packed into a finite number of bins each with the capacity C in a way that minimizes the number of bins used. The decision version of the bin packing problem (deciding if objects will fit into <= k bins) is NP-complete. There is no known polynomial time algorithm to solve the optimization version of the bin packing problem. In this practice problem you will be examining three...
Prove or disprove that INDEPENDENT-SET ?p SET-PACKING, that is, these two problems are computationally equally hard. Please use an illustration if it helps. The definitions of these two decision problems are summarized below. We already proved that INDEPENDENT-SET ?p SETPACKING, so assume this given. - INDEPENDENT-SET: Given a graph G = (V, E) and an integer k, is there a subset of vertices such that and, for each edge in E, at most one - but not both - of...
You are given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum 2 product you can get. (Example Input: 10, Output: 36, Explanation: 10 = 3 3 4 = 36). What is your answer for n = 82. Write a python code for this
I randomly pick two integers from 1 to n without replacement (n a positive integer). Let X be the maximum of the two numbers. (a) Find the probability mass function of X. (b) Find E(X) and simplify as much as possible (use formulas for the sum and sum of squares of the first n integers which you can find online).
Computer science Implement these below questions in C++: 1. Given two-bit strings of length n, find the bitwise AND, bitwise OR, and bitwise XOR of these strings. 2. Looking for positive integers that are not the sum of the cubes of nine different positive integers. 3. Given subsets A and B of a set with n elements, use bit strings to find A, A ∪ B, A ∩ B, A − B, and A ⊕ B. 4. Given a finite...
C++ program which partitions n positive integers into two disjoint sets with the same sum. Consider all possible subsets of the input numbers. This is the sample Input 1 6 3 5 20 7 1 14 Output 1 Equal Set: 1 3 7 14 This is the sample Input 2 5 10 8 6 4 2 Output 2 Equal Set: 0
5. The Hitting Set Problem (HS) is the following decision problem. Input. A finite set S, a collection (s1, s2,... , sn) of subsets of S, and a positive integer K. Question. Does there exist a subset t of S such that (a) t has exactly K members and (b) for i 1,..., n, sint6For example, suppose S # {1, 2, 3, 4, 5, 6, 7. the collection of subsets is (2.45), (34).(1,35) and K - 2. Then the answer...
Q4) [5 points] Consider the following two algorithms: ALGORITHM 1 Bin Rec(n) //Input: A positive decimal integer n llOutput: The number of binary digits in "'s binary representation if n1 return 1 else return BinRec(ln/2)) +1 ALGORITHM 2 Binary(n) tive decimal integer nt io 's binary representation //Output: The number of binary digits in i's binary representation count ←1 while n >1 do count ← count + 1 return count a. Analyze the two algorithms and find the efficiency for...