A5.dviSchool of Computer ScienceUniversity of GuelphCIS*3490 The Analysis and Design of AlgorithmsWinter 2023Instructor: Fangju WangAssignment 5 (100%)For this assignment, you are...

Programming in C










A5.dvi School of Computer Science University of Guelph CIS*3490 The Analysis and Design of Algorithms Winter 2023 Instructor: Fangju Wang Assignment 5 (100%) For this assignment, you are required to write programs in C. No pseudocode. Question 1: Subset-Sum Problem (50%) The subset-sum problem is to find a subset of a given set A = {a1, a2, ..., an} of n positive integers, such that the subset’s sum is equal to a given positive integer d. For example, for A = {1, 2, 5, 6, 8} and d = 9, there are two subsets {1, 2, 6} and {1, 8} whose sums are equal to 9 . Write the following programs for finding the number of the subsets whose sums are equal to a given positive integer d. In the above example, the number is 2. 1.1 A program to implement a brute force (exhaustive search) algorithm (15%) 1.2 A possibly more efficient program based on the backtracking technique (35%) Requirements: When a program is executed, it prompts for a file name and a positive integer d, reads in the file containing the set A, and computes and reports the number of the subsets whose sums are equal to d. The program for 1.1 is also required to report the number of all the subsets evaluated. The program for 1.2 is also required to report the number of the dead ends. The programs are not required to list the subsets. A program is required to report the running time for finding the subsets. The running time should not include the time for reading the file. You can use file data A5 Q1 1.txt to develop/test your programs. This file contains 25 integers. A different data file will be used to grade your programs. The numbers of integers and data formats of the two data files will be the same. Question 2: Person-Job Assignment Problem (50%) In an assignment problem, there are n people who need to be assigned to execute n jobs, one person per job. Each person is assigned to exactly one job and each job is assigned to exactly one person. A person creates a value in doing a job. In this assignment problem, V [i.j] in the n × n matrix V stores the value created by person i in doing job j (i, j = 1, 2, ...n). The problem is to find a person-job assignment that maximizes the total value. 1 Write the following programs to solve the assignment problem with a given V . 2.1 A program to implement a brute force (exhaustive search) algorithm (15%) 2.2 A possibly more efficient program based on the branch-and-bound technique (35%) Requirements: When a program is executed, it prompts for a file name, reads in the file containing matrix V , and computes and reports the assignment and the total value created. Please see the guide for the format for reporting and assignment. The program for 2.1 is also required to report the number of all the assignments evaluated. The program for 2.2 is also required to report the maximum upper bound in each step. A program is required to report the running time for finding the assignment. The running time should not include the time for reading the file. You can use file data A5 Q2 1.txt to develop/test your programs. This file contains a 12 × 12 matrix, for 12 persons and 12 jobs. A different data file will be used to grade your programs. The numbers of integers and data formats of the two data files will be the same. Note: Write your own code for this assignment. NO code from any source is allowed. Due time: 08:00am, Monday April 10, 2023. Submit your work as a tar or zip file to Moodle. 2
Mar 30, 2023
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here