0% found this document useful (0 votes)
0 views

HW3

This document outlines Problem Set 3 for the CS 3510 course, focusing on graphs and algorithms. It includes various tasks such as running DFS, finding strongly connected components, and designing algorithms for seating arrangements and reachability in graphs. The assignment emphasizes clear explanations, specific runtime requirements, and justifications for answers.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

HW3

This document outlines Problem Set 3 for the CS 3510 course, focusing on graphs and algorithms. It includes various tasks such as running DFS, finding strongly connected components, and designing algorithms for seating arrangements and reachability in graphs. The assignment emphasizes clear explanations, specific runtime requirements, and justifications for answers.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CS 3510: Design & Analysis of Algorithms January 28th 2025

Problem Set 3: Graphs


YOUR NAME HERE Due: February 3rd 2025

• Please type your solutions using LATEX or any other software. Handwritten solutions will not
be accepted for this assignment.

• Your algorithms must be in plain English & mathematical expressions. Pseudo-code without
sufficient explanation will receive no credit.

• If we ask for an algorithm with a specific runtime, we will only accept answers with that
specific runtime, even if a faster solution exists. If we ask for an “efficient” algorithm, we
will not accept answers if a faster algorithm than the one provided exists.

• Unless a question explicitly states that no work is required to be shown, you must provide
an explanation or justification for your answer.
1.) Reference this graph for both parts of this problem:

F J

H C

A B

I G

E D

Part A

For this part, in the event of a tie, choose the node that is alphabetically first.
a.) Run DFS on this graph and list the pre and post labels of each vertex. Show your work; we
do not require a specific format but we want to see that some work was performed.

Solution: [Write your answer here]

Part B

For this part, we run the SCC algorithm on the above graph. When running DFS on the re-
verse graph, use the alphabetical order of vertices.
a.) Write the strongly connected components in the order you found them. Show your work; we
do not require a specific format but we want to see that some work was performed.

Solution: [Write your answer here]

b.) List all the sink components and all the source components. Provide a short justification.

Solution: [Write your answer here]

c.) Give the minimum number of edges that must be added to the graph above to make it
strongly connected. Justify your answer.
Solution: [Write your answer here]

d.) Topologically sort the metagraph using the technique described in class. List the components
in that order. No work is required.

Solution: [Write your answer here]


2.) For each of the questions below, either answer True or False. If you answer False, provide
a counter example and a 1-2 sentence justification. If your counter-example is a graph, the graph
can have at most 4 nodes. If you answer True, provide a short 3-4 sentence explanation/proof.

a) The vertex with the smallest post-order number in a depth-first search must belong to a sink
strongly connected component (sink meta-node) of the graph.

Solution: [Write your answer here]

b) In a directed acyclic graph, if a vertex is a source, then it must have the largest post-order
number in a depth-first search.

Solution: [Write your answer here]

c) The meta-graph of a directed acyclic graph is the same as the original graph.

Solution: [Write your answer here]

d) If a back edge is found during a depth-first search traversal, the graph contains a cycle.

Solution: [Write your answer here]


3.) You are planning a wedding where some guests have had past disagreements. Due to these
conflicts, certain pairs of guests absolutely cannot sit at the same table. Represent each guest as a
vertex in a graph, and place an edge between two vertices if those guests have a known disagree-
ment.

Your task is to determine if you can split all the guests into exactly two tables in such a way that
no conflicting pair of guests ends up at the same table. Concretely, you want to see if there is
a way to label each vertex (guest) as belonging to one of two groups—think of them as “Table
A” and “Table B”—so that whenever two vertices are connected by an edge, they are assigned to
different tables.

Design an algorithm that checks whether such a two-table arrangement exists and, if it does,
outputs the arrangement. If no valid split is possible, the algorithm should report that the guests
cannot be separated without causing a conflict at one of the tables (more tables will be needed).

1. Describe your algorithm to a degree where someone could implement it if given your answer.

Solution: [Write your answer here]

2. Argue why your algorithm is correct (given any input, why does your algorithm produce the
correct outputs).

Solution: [Write your answer here]

3. Provide the runtime of your algorithm. Justify your answer.

Solution: [Write your answer here]


4.) Given an undirected graph, Gu = (Vu , Eu ), give an efficient algorithm that determines if there
exists a vertex su ∈ Vu from which all other vertices are not reachable.

(a.) Describe your algorithms to a degree where someone could implement it if given your answer.

Solution: [Write your answer here]

(b.) Argue why your algorithm is correct (given any input, why does your algorithm produce the
correct outputs).

Solution: [Write your answer here]

(c.) Provide the runtime of your algorithm. Justify your answer.

Solution: [Write your answer here]

(d.) Now with a directed graph Gd = (Vd , Ed ), give an efficient algorithm that determines whether
or not there is a vertex sd ∈ Vd from which all other vertices are reachable. Describe just the
algorithm in 4-5 sentences (no correctness or runtime).

Solution: [Write your answer here]

You might also like