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
Step by stepSolved in 4 steps with 2 images
- Solve by Algorithmarrow_forwardI need the algorithm, proof of correctness and runtime analysis for the problem. No code necessary ONLY algorithm. And runtime should be O(n log n) as stated in the question.arrow_forwardConsider the problem of making change for n cents using the fewest number of coins. Assume that we live in a country where coins come in k dierent denominations c1, c2, . . . , ck, such that the coin values are positive integers, k ≥ 1, and c1 = 1, i.e., there are pennies, so there is a solution for every value of n. For example, in case of the US coins, k = 4, c1 = 1, c2 = 5, c3 = 10, c4 = 25, i.e., there are pennies, nickels, dimes, and quarters. To give optimal change in the US for n cents, it is sufficient to pick as many quarters as possible, then as many dimes as possible, then as many nickels as possible, and nally give the rest in pennies. Design a bottom-up (non-recursive) O(nk)-time algorithm that makes change for any set of k different coin denominations. Write down the pseudocode and analyze its running time. Argue why your choice of the array and the order in which you fill in the values is the correct one. Notice how it is a lot easier to analyze the running time of…arrow_forward
- There 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_forwardInput: An odd integer B, and a set A= {a_1, . .. , a_2n} of 2n distinct positive integers. Question: Decide whether A can be partitioned inton disjoint pairs (a_i, a_j), where 1 s iarrow_forwardProblem 3: Median of two sorted arrays. Finding the median of a sorted array is easy:return the middle element. Suppose we are given two sorted arrays A and B; the array Aconsists of m not necessary different integers, while B consists of n not necessary differentintegers. Suppose that A and B are disjoint, that is, there does not exist an element whichis in A and B.(i) Describe a naive algorithm which in time O(m + n) finds the median of all integersin A and B.(ii) If m = n, describe an algorithm which in time O(log n) finds the median of all integersin A and B.arrow_forwardAppendix A 10-Fold Cross Validation for Parameter Selection Cross Validation is the standard method for evaluation in empirical machine learning. It can also be used for parameter selection if we make sure to use the training set only. To select parameter A of algorithm A(X) over an enumerated range d E [A1,..., A] using dataset D, we do the following: 1. Split the data D into 10 disjoint folds. 2. For each value of A e (A1,..., Ar]: (a) For i = 1 to 10 Train A(A) on all folds but ith fold Test on ith fold and record the error on fold i (b) Compute the average performance of A on the 10 folds. 3. Pick the value of A with the best average performance Now, in the above, D only includes the training data and the parameter A is chosen without the knowledge of the test data. We then re-train on the entire train set D using the chosen A and evaluate the result on the test set.arrow_forwardAlgorithm for LLP-GAN training algorithmInput: The training set L = {(Bi, pi)}n i=1; L: number of total iterations; λ: weight parameter.Input: The parameters of the final discriminator D.Set m to the total number of training data pointsarrow_forwardWe can specify the PageRank algorithm's convergence threshold using proc networks. This figure has to be positive. Default value is 1E-9. When the difference between the PageRank scores of the current iteration and the previous iteration is less than or equal to the tolerance set, the PageRank algorithm ceases iterating. We can use the PAGERANKTOLERANCE= parameter to specify the convergence tolerance. Write The example code demonstrates how to calculate PageRank centrality using a proc network built on a directed graph with unweighted links.arrow_forward5. You are given a set of n positive numbers A = {a₁,..., an} and a positive integer t. Design a dynamic programming algorithm running in O(nt) time that decides whether there exists a subset A' CA such that Σ x = t. Note that each element of A can be xЄA' used at most once. Is the run-time of your algorithm polynomial with respect to the size of the input?arrow_forwardProblem 3: A day at the beach. A group of n people are lying on the beach. The beach is represented by the real line R and the location of the i-th person is some integer r; e Z. Your task is to prevent people from getting sunburned by covering them with umbrellas. Each umbrella corresponds to a closed interval I = [a, a + L] of length L e N, and the i-th person is covered by that umbrella if æ¡ € I. Design a greedy algorithm for covering all people with the minimum number of umbrellas. The input consists of the integers x1,..., En, and L. The output of your algorithm should be the positions of umbrellas. For example, if the input is r1 = 1, x2 = 3, r3 = 5, and L = 2, then an optimum solution is the set of two umbrellas placed at positions 2 and 5, covering intervals [1,3] and [4,6]. 1 2 3 4 5 6 Prove that your algorithm is correct and that it runs in time polynomial in n.arrow_forward10 by 10 grid, . The agent in the top right corner, fast route to left bottom corner, some cells = easy terrain = 1 time unit. Some cells = rough terrain = 5 time units. Some cells = impassible terrain and cannot be traversed. -Write a Breathe first search Python function: A function that generates a list of lists to represent the 2D grid, where each grid cell contains the number of time units taken to traverse through it. Each cell should have a probability of 0.4 of being easy terrain, 0.4 of being rough terrain and 0.2 of being untraversable. E.g, map = RandomMap()arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- 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