Question: Write a program to solve the following problem. Given three integers, n, x, and S; and a set T of n integers, report a subset

Write a program to solve the following problem. Given three integers, n, x, and S; and a set T of n integers, report a subset (you are only required to output one subset even if there are multiple solutions) of size smaller than or equal to x such that the sum of the integers in this subset equals S. Remarks (you MUST follow the instructions below): - Name the program as subset-sum. - The program will read in an input file, called input.txt. The input file contains 3+n lines. The first line is the integer n, the second line is the integer x, and the third line is the integer S. Then, the subsequent n lines containing the elements of the set T, with each line contains one distinct element of T. - You can assume that there is no error in the input file and there are no duplicate elements in T. - If there exists a subset with size
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
