Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following problem: Set Cover Input: A set I = { i 1 , i 2 , . . . , in } of

Consider the following problem:
Set Cover
Input: A set I ={i1, i2,..., in} of items and a set S ={s1, s2,..., sm} of subsets of I.
Output: All minimum-size set covers of I, i.e., all smallest-possible size subsets S' of S such that the union of all sets in S' is equal to I.
Write and document a Python program that uses a recursive backtracking algorithm to print all minimum-size set covers for a given item-set I and item-subset set S, where the files specifying I and S are input as command-line arguments. This algorithm will consider the set of candidate solutions consisting of all possible subsets of S. An example item-subset set file iset1.txt is as follows:
54
1: 12
2: 234
3: 45
4: 234
Each such file of m item-subsets of a set of n items consists of n +1 lines, where the first line contains the integers n and m, respectively, and the remaining lines contain the item-subsets, one per line, where each item-subset is specified by the number of the item-subset and its elements in ascending order. You may assume that all input files are formatted correctly. Examples of several program runs relative to the item-subset set files iset1.txt, iset2.txt, iset3.txt, iset4.txt, iset5.txt, iset6.txt, iset7.txt, and iset8.txt are given in script file out.script.min. It is these results that your program should be able to replicate. To aid understanding how this program should work, you have also been provided with an expanded version of this script file which shows the program's progress through the search tree of candidate solutions.
Hints
You may find it convenient to determine the optimal solution cost and to print optimal solutions in two separate recursive procedures (see sample Java code for solving the Vertex Cover described in Lecture #1).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago