Starting from:

$30

CSE211 Homework 3 Solved

Problem 1: Representing Graphs                                                                                                                              (10 points)
Represent the graph in Figure 1 with an adjacency matrix. Explain your representation clearly.

 

Figure 1: The graph for Problem 1

(Solution)

1

Problem 2: Hamilton Circuits                                                                                                               (10+10+10=30 points)
Determine whether there is a Hamilton circuit for each given graph (See Figure 2a, Figure 2b, Figure 2c ). If the graph has a Hamilton circuit, show the path with its vertices which gives a Hamilton circuit. If it does not, explain why no Hamilton circuit exists.

 

                                       (a) The graph G1                                                                                                                       (b) The graph G2

 

(c) The graph G3

Figure 2: The graphs to find Hamilton circuits for Problem 1

(a)

(Solution)

(b)

(Solution)

(c)

(Solution)

Problem 3: Applications on Graphs                                                                                                                          (20 points)
Schedule the final exams for Math 101, Math 243, CSE 333, CSE 346, CSE 101, CSE 102, CSE 273, and CSE 211, using the fewest number of different time slots, if there are no students who are taking:

•    both Math 101 and CS 211,

•    both Math 243 and CS 211,

•    both CSE 346 and CSE 101,

•    both CSE 346 and CSE 102,

•    both Math 101 and Math 243,

•    both Math 101 and CSE 333,

•    both CSE 333 and CSE 346

but there are students in every other pair of courses together for this semester. Note: Assume that you have only one classroom.

Hint 1: Solve the problem with respect to your problem session notes.

Hint 2: Check the website

(Solution)


Problem 4: Applications for Hasse Diagram of Relations                                                                                (40 points)
Remember the Problem 3 in Homework 2.

Write an algorithm to draw Hasse diagram of the given relations in ”input.txt” which is given for HW2.

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

•    Read the relations from the text file ”input.txt”. You can use your code from HW2 if you implemented to read the file. If you didn’t implement it, please check HW2 to learn how to read the relations from the file.

•    Determine each relation in ”input.txt” whether it is reflexive, symmetric, anti-symmetric and transitive with your algorithm from HW2.

•    In order to draw Hasse diagram, each relation must be POSET. Hence, the relation obeys the following rules:

–    Reflexivity

–    Anti-symmetric

–    Transitivity

If the relation is not a POSET, your algorithm is responsible to CONVERT it to POSET.

–    If the relation is not reflexive, add new pairs to make the relation reflexive.

–    If the relation is symmetric, remove some pairs which make the relation symmetric. For instance, if the relation has (a, b) and (b, a), remove one of them randomly.

–    If the relation is not transitive, add new pairs which would make the relation transitive.

•    After the relation becomes POSET, your algorithm should obtain Hasse diagram of the relation and write the diagram with the following format.

–    An example of the output format is given in ”exampleoutput.txt”. The file has the result of the first relation in ”input.txt”.

–    In ”output.txt”, each new Hasse diagram starts with ”n”.

–    The relation is (a, a), (a, b), (a, e), (b, b), (b, e), (c, c), (c, d), (d, d), (e, e)

–    The relation is already a POSET so we don’t need to add or remove any pairs.

–    After ”n”, write the POSET in the next line as it is shown in ”exampleoutput.txt”.

–    Since the relation is POSET, it becomes (a, b), (b, e), (c, d) after removing reflexive and transitive pairs.

–    The following lines give each pair of Hasse diagram.

•    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 file (file name is problem1.{.c,.java,.py,.cpp}) and output.txt into your homework zip file (check Course Policy).

More products