Problem Set 4: Graphs: CS 3510: Design & Analysis of Algorithms
Problem Set 4: Graphs: CS 3510: Design & Analysis of Algorithms
• 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:
10 3
A F C
5 8 4
4 6 3
4
H B D
3 4
2 1
3
G E
Part A
In the event of a tie, choose the node that is alphabetically first. Run Dijkstra’s on this graph to
find the shortest distance from node A to every other node. Show your work; we do not require a
specific format but we want to see that some work was performed.
Part B
a) Run Kruskal’s algorithm on the given graph. Show your work and your final answer (the
MST).
b) Suppose you are given an undirected graph. Show that if all the edge weights on the graph as
positive, then any subset of edges that connects all vertices and has a minimum total weight
must be a tree.
a) Graph G has a single negative weighted edge e with weight w. We can find the shortest path
through G by adding |w| to all edges and running Dijkstra’s.
b) Weighted graph G has a maximum spanning true M . If all edge weights in G are negated
to form G′ , M will be the minimum spanning tree in G′ .
c) In every connected, undirected graph where each vertex has distinct edge weights, there are
multiple possible Minimum Spanning Trees.
d) The Union-Find data structure is commonly used in Prim’s algorithm to help detect cycles
when building a Minimum Spanning Tree (MST).
(a.) Describe your algorithms to a degree where someone could implement it if given your answer.
(b.) Argue why your algorithms are correct (given any input, why does your algorithm produce
the correct outputs).
(c.) Give the runtime of your algorithm and explain the reasoning.
You are given a weighted undirected graph G = (V, E), where the vertices V represent planets and
the edges E represent intergalactic routes that directly connect planets. Each edge e has a weight
w(e) equal to the time required to travel between the two planets. You are also given a vertex p,
representing your starting location, and a vertex q, representing your sibling’s starting location.
Describe and analyze an algorithm to find the target vertex t that allows you and your sibling to
meet as quickly (minimum total travel time) as possible.
(a.) Describe your algorithms to a degree where someone could implement it if given your answer.
(b.) Argue why your algorithms are correct (given any input, why does your algorithm produce
the correct outputs).
(c.) Give the runtime of your algorithm and explain the reasoning.