CS计算机代考程序代写 algorithm CSE 101 Homework 5

CSE 101 Homework 5

Winter 2021

This homework is due on gradescope Friday February 26th at 11:59pm pacific time. Remember to justify
your work even if the problem does not explicitly say so. Writing your solutions in LATEXis recommend
though not required.

Question 1 (Minimum Spanning Subgraph, 30 points). When introducing the Minimum Spanning Tree
problem, we considered the problem of finding the least costly set of edges that connects a graph G. We
showed that if the edge weights are all non-negative that these edges would necessarily form a tree. However,
if negative edge weights are allowed, this no longer needs to be the case. Give an algorithm that given a
weighted, undirected graph G, provides a subset S of edges so that any vertex in G can be reached from any
other using only edges in S and so that subject to this, the total weight of S is as small as possible. For full
credit, your algorithm should run in time O(|V | log(|V |) + |E|) or better.

Question 2 (Multiple MSTs, 40 points). (a) Give an example of a graph that has more than one minimum
spanning tree. [5 points]

(b) Show that for any graph G with minimum spanning trees T and T ′ that for each weight w, T and T ′

contain the same number of edges of weight w. Hint: Run an exchange-like argument to slowly turn T
into T ′ without changing the number of edges of any weight. [35 points]

Question 3 (LCSS without Double Letters, 30 points). Say that a string has a double letter if two consecutive
letters in the string are the same. Give an algorithm that given two strings of length n, A = a1a2 . . . an and
B = b1b2 . . . bn, finds the longest sequence C = c1c2 . . . cm so that C is a subsequence of both A and B and
has no double letters. For full credit, your algorithm should run in time O(n3) or better.

Question 4 (Extra credit, 1 point). Approximately how much time did you spend working on this homework?

1