Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in PYTHON LANGUAGE. The program prompts the user to input a file name. If there is no file with that name in

Write a program in PYTHON LANGUAGE.

The program prompts the user to input a file name. If there is no file with that name in the working directory, then the program outputs an (arbitrary) error message and exits.

The contents of the file consists of lines with text of the form R(m,n) where m and n are integers (that just represent labels), with possibly spaces before and after the opening and closing parentheses, respectively. It represents a partial order relation R (so an asymmetric and transitive binary relation). For instance, the contents of the file partial_order_1.txt can be represented as:

image text in transcribed

It can be seen that two facts are redundant: the fact R(3, 1), which follows from the facts R(3, 5), R(5, 2) and R(2, 1);

the fact R(4, 1), which follows from the facts R(4, 2) and R(2, 1).

The program outputs the facts that are nonredundant, respecting the order in which they are listed in the file.

Here is a possible interaction:

$ cat partial_order_1.txt R(3,5) R(4,2) R(5,2) R(2,1) R(3,1) R(4,1)
$ python3 nonredundant.py Which data file do you want to use? partial_order_1.txt The nonredundant facts are: 
R(3,5) R(4,2) R(5,2) R(2,1) 
$ cat partial_order_2.txt R(3,5) R(5,2) R(2,6) R(2,1) R(3,6) R(6,1) R(4,2) R(4,1)
$ python3 nonredundant.py Which data file do you want to use? partial_order_2.txt The nonredundant facts are: 
R(3,5) R(5,2) R(2,6) R(6,1) R(4,2) $ cat partial_order_3.txt R(1,2) 
R(2,3) R(3,4) R(1,3) R(2,4) $ python3 nonredundant.py Which data file do you want to use? partial_order_3.txt The nonredundant facts are: 
R(1,2) R(2,3) R(3,4) 

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

Step: 3

blur-text-image

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

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions

Question

5. Have you stressed the topics relevance to your audience?

Answered: 1 week ago