CSE 211 Homework #2 Solution

$30.00 $24.00

Problem 1: Relations (15 points) Draw the Hasse diagram for the \greater than or equal to” relation on f0, 1, 2, 3, 4, 5g. Show each step to build the diagram. In order to draw the diagram, you can choose one of the following options: You can use an online drawing tool such as https://app.diagrams.net/.…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

Problem 1: Relations

(15 points)

Draw the Hasse diagram for the \greater than or equal to” relation on f0, 1, 2, 3, 4, 5g. Show each step to build the diagram. In order to draw the diagram, you can choose one of the following options:

You can use an online drawing tool such as https://app.diagrams.net/.

You can draw the diagram by hand, take a picture of it to put on Latex as a gure. Word O ce, Libre O ce are also options to use them as drawing tools.

(Solution)

1

{ Homework #2

Problem 2: Relations

2

(15 points)

Answer these questions for the poset (ff1g, f2g, f4g, f1, 2g, f1, 4g, f2, 4g, f3, 4g, f1, 3, 4g, f2, 3, 4gg, ).

  1. Find the maximal elements. (Solution)

  1. Find the minimal elements. (Solution)

  1. Is there a greatest element? (Solution)

  1. Find all upper bounds of ff2g, f4gg. (Solution)

  1. Find the least upper bound of ff2g, f4gg, if it exists. (Solution)

  1. Find all lower bounds of ff1, 3, 4g, f2, 3, 4gg. (Solution)

  1. Find the greatest lower bound of ff1, 3, 4g, f2, 3, 4gg, if it exists. (Solution)

{ Homework #2

Problem 3: Relations

3

(70 points)

Remember that a relation R on a set A can have the properties re exive, symmetric, anti-symmetric and transitive.

Re exive: R is re exive if (a, a) 2 R, 8 a 2 A.

Symmetric: R is symmetric if (b, a) 2 R whenever (a, b) 2 R, 8 a, b 2 A.

Anti-symmetric: R is antisymmetric if 8 a, b 2 A, (a, b) 2 R and (b, a) 2 R implies that a = b.

Transitive: R is transitive if 8 a, b, c 2 A, (a, b) 2 R and (b, c) 2 R implies that (a, c) 2 R.

For the details about the properties, please check the 4th lecture slide on Moodle.

As we solved the problem 3 in PS4 document – which is available on Moodle – in the problem session, we can determine any given relation if it is re exive, symmetric, anti-symmetric, and transitive.

Write an algorithm to determine if a given relation R is re exive, symmetric, anti-symmetric, and transitive.

Your code should meet the following requirements, standards and tasks.

Read the relations in the text le “input.txt”.

Let R be a relation on a set A where 9a; b 2 A; (a; b) 2 R. Each relation R is represented with the lines in the le:

    1. The rst line says how many relations in R.

    1. The second line gives the elements of the set A.

    1. The following lines give each relation in R.

After determining each relation in input.txt whether it is re exive, symmetric, anti-symmetric and tran-sitive with your algorithm, write its result to the le which is called “output.txt” with the following format.

output.txt:

    1. Start a new line with “n” which indicates a new relation.

    1. The set of R

    1. Re exive: Yes or No, explain the reason if No (e.g. “(a, a) is not found”).

    1. Symmetric: Yes or No, explain the reason if No (e.g. “(b, a) is not found whereas (a, b) is found.”)

    1. Antisymmetric: Yes or No, explain the reason if No (e.g. “(b, a) and (a, b) are found.”)

    1. Transitive: Yes or No, explain the reason if No (e.g. “(a, c) is not found whereas (a, b) and (b, c) are found.”)

An example of the output format is given in “exampleoutput.txt”. The le has the result of the rst relation in “input.txt”.

When explaining why a property does not exist in the relation, one reason is enough to explain if there are more. For example, in “exampleoutput.txt”, the relation is not symmetric because (b, a) and (e, a) are not found. Detecting one of them is enough to explain the reason.

Bonus (20 points): If you can explain why a property exists in the relation, it brings you bonus of 20 points.

Your code is responsible to provide exception and error handling. The input le may be given with a wrong information, then your code must be prepared to detect them. For instance, “The element b of the relation (1, b) is not found in the set A = f1; 2; 3; 4g.”.

You can implement your algorithm in Python, Java, C or C++.

Important: Put comments almost for each line of your code to describe what the line is going to do. You should put your source code le ( le name is problem1.f:c; :java; :py; :cppg) and output.txt into your

homework zip le (check Course Policy).

CSE 211 Homework #2 Solution
$30.00 $24.00