100% found this document useful (1 vote)
30 views

Computer Science Assignment Help

I am Irene M. I am a Computer Science Assignment Expert. I hold a Ph.D. in Computer Science from, City University of New York. I have been helping students with their homework for the past 8 years. I solve assignments related to Computer Science.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
30 views

Computer Science Assignment Help

I am Irene M. I am a Computer Science Assignment Expert. I hold a Ph.D. in Computer Science from, City University of New York. I have been helping students with their homework for the past 8 years. I solve assignments related to Computer Science.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Computer Science Assignment Help

Both exercises and problems should be solved, but only the problems
should be turned in. Exercises are intended to help you master the
course material. Even though you should not turn in the exercise
solutions, you are responsible for material covered by the exercises.
Mark the top of the first page of your solution with your name, the
course number, the problem number, your recitation section, the date,
and the names of any students with whom you collaborated. The
homework template (LATEX) is available on the course website. You will
often be called upon to “give an algorithm” to solve a certain problem.
Your write-up should take the form of a short essay. A topic paragraph
should summarize the problem you are solving and what your results
are. The body of the essay should provide the following:

1. A description of the algorithm in English and, if helpful, pseudo-code.

2. At least one worked example or diagram to show more precisely how


your algorithm works.

3. A proof (or indication) of the correctness of the algorithm.

4. An analysis of the running time of the algorithm

© 2022 All Rights Reserved . Programming Homework Help


Exercise 2-1. Do Exercise 21.1-2 on page 564 of CLRS.

Exercise 2-2. Do Exercise 23.1-2 on page 629 of CLRS.

Exercise 2-3. Do Exercise 23.1-5 on page 629 of CLRS.

Exercise 2-4. Do Exercise 23.1-10 on page 630 of CLRS.

Exercise 2-5. Do Exercise 23.1-11 on page 630 of CLRS.

Exercise 2-6. Do Exercise 23.2-4 on page 637 of CLRS.

Exercise 2-7. Do Exercise 23.2-8 on page 637 of CLRS.

Exercise 2-8. Do Problem 23-4 on page 641 of CLRS.

In Lecture 3, we saw the claim that any weighted undirected graph with
distinct edge weights has exactly one minimum spanning tree. In this
problem, your goal will be to show that this claim is true by proving a
more general theorem.

© 2022 All Rights Reserved . Programming Homework Help


Let G = (V, E) be a connected, weighted undirected graph whose edges
weight may or may not be distinct. Given a cut (S, V − S) of S, recall
that an edge (u, v) ∈ E is said to cross the cut if exactly one of u and v
is in S. An edge (u, v) is a light edge crossing the cut (S, V − S) if its
weight is the smallest of any edge crossing (S, V − S). There can be
more than one light edge crossing a single cut in the case of ties. An
edge (u, v) is a unique light edge if there are no ties.

(a) Show that if an edge (u, v) is the unique light edge crossing some
cut of the connected, weighted undirected graph G, then (u, v)
must be included in all minimum spanning trees of G.

(b) Suppose that we have a connected, weighted undirected graph G


= (V, E) such that every cut of G has a unique light edge crossing
the cut. Show that G has exactly one minimum spanning tree.

In a graph with no duplicate edge weights, there cannot be any ties


for the light edge crossing a cut. As a result, any graph with distinct
edge weights will satisfy the requirements for the theorem in part (b),
and will therefore have exactly one minimum spanning tree

© 2022 All Rights Reserved . Programming Homework Help


Problem 2-2. Shortest Paths and Minimum Spanning Trees

In this problem, you will examine the relationship between minimum


spanning trees and shortest path trees. As a reminder, given a weighted
undirected graph G = (V, E) with edge weights w, the shortest path tree
rooted at s ∈ V is a subgraph G′ = (V ′ , E′ ) of G such that:

1. The vertex set V ′ ⊆ V is the set of nodes in G reachable from s.

2. The graph G′ is a tree, with |E′ | = |V ′ | − 1.

3. For any u ∈ V ′ , the distance from s to u in G′ is the same as the


distance from s to u in G.

Note that as with minimum spanning trees, there is more than one
shortest path tree per graph. In addition to the variation introduced by the
choice of root, it’s possible to get different shortest path trees even for the
same root vertex.

(a) Given any connected undirected graph G with positive edge


weights w, does there always exist a shortest path tree S such that S is
a minimum spanning tree of G? Prove your answer.

(b) Does there exist some connected undirected graph G with positive
edge weights w such that G has a shortest path tree S and a minimum
spanning tree T that do not share any edges? Prove your answer.

© 2022 All Rights Reserved . Programming Homework Help


Solutions
In Lecture 3, we saw the claim that any weighted undirected graph with
distinct edge weights has exactly one minimum spanning tree. In this
problem, your goal will be to show that this claim is true by proving a
more general theorem.

Let G = (V, E) be a connected, weighted undirected graph whose edges


weight may or may not be distinct. Given a cut (S, V − S) of S, recall that
an edge (u, v) ∈ E is said to cross the cut if exactly one of u and v is in S.
An edge (u, v) is a light edge crossing the cut (S, V − S) if its weight is the
smallest of any edge crossing (S, V − S). There can be more than one light
edge crossing a single cut in the case of ties. An edge (u, v) is a unique
light edge if there are no ties.

(a) Show that if an edge (u, v) is the unique light edge crossing some cut
of the connected, weighted undirected graph G, then (u, v) must be
included in all minimum spanning trees of G.

Solution: Suppose for contradiction that there is some MST T that does
not contain the light edge (u, v) crossing a cut C. Because T is a
connected tree, there is some path in T connecting the vertices u and v,
and therefore adding the edge (u, v) to T forms a cycle.
Following this cycle, there must be at least one other edge in the cycle
crossing the cut C. Removing this edge, and leaving (u, v), we now have a
tree with a lower total weight than the original T. Because T was
assumed to be an MST, this is a contradiction. Therefore, any unique
light edge of a cut must be part of every MST.
© 2022 All Rights Reserved . Programming Homework Help
(b) Suppose that we have a connected, weighted undirected graph G =
(V, E) such that every cut of G has a unique light edge crossing the cut.
Show that G has exactly one minimum spanning tree.

Solution: From problem 2-1(a), we know that for every cut of G, the
unique light edge crossing the cut must be part of every MST of G.
Consider the set T of edges, containing the unique light edge crossing
each cut C of G. By the previous part, we know that T is a subset of
every MST.
Now we can show that T must be equal to every MST. Because there is
exactly one edge of T crossing every cut of G, the graph (V, T) must have
exactly one connected component: if there were two unconnected
components V1 and V − V1, then the cut

(V1, V − V1) would not be crossed by any edge of T, which contradicts


the definition of T. In addition, T cannot contain any cycles: the heaviest
edge on a cycle in T cannot be the unique lightest edge in any cut. Then
T itself must be a spanning tree of G. Because T is a subset of all
minimum spanning trees of G, it must be the unique MST of G, as any
additional edge added to T would form a cycle, making it no longer be a
tree.

In a graph with no duplicate edge weights, there cannot be any ties for
the light edge crossing a cut. As a result, any graph with distinct edge
weights will satisfy the requirements for the theorem in part (b), and will
therefore have exactly one minimum spanning tree.

© 2022 All Rights Reserved . Programming Homework Help


Problem Shortest Paths and Minimum Spanning Trees

In this problem, you will examine the relationship between minimum


spanning trees and shortest path trees. As a reminder, given a weighted
undirected graph G = (V, E) with edge weights w, the shortest path tree
rooted at s ∈ V is a subgraph G′ = (V ′ , E′ ) of G such that:

1. The vertex set V ′ ⊆ V is the set of nodes in G reachable from s.

2. The graph G′ is a tree, with |E′ | = |V ′ | − 1.

3. For any u ∈ V ′ , the distance from s to u in G′ is the same as the


distance from s to u in G

Note that as with minimum spanning trees, there is more than one
shortest path tree per graph. In addition to the variation introduced by
the choice of root, it’s possible to get different shortest path trees even
for the same root vertex.

(a) Given any connected undirected graph G with positive edge


weights w, does there always exist a shortest path tree S such that S is a
minimum spanning tree of G? Prove your answer.

Solution: Here is a counterexample:

© 2022 All Rights Reserved . Programming Homework Help


In the above graph, the outside edges each have a weight of 2, and
the diagonal inner edges each have a weight of 3.
The minimum spanning trees of this element are any three of the
weight-2 edges, as highlighted in red below:

(b) Does there exist some connected undirected graph G with positive
edge weights w such that G has a shortest path tree S and a minimum
spanning tree T that do not share any edges? Prove your answer.

Solution: Assuming that G has more than one vertex, there is no such
graph. Given any source vertex s, consider the light edges leaving s,
defined as the edges (s, v) of minimum weight (where v is some
neighbor of s).

© 2022 All Rights Reserved . Programming Homework Help


Lemma 1 Every MST of G must contain at least one of these light edges.

PROOF. Suppose there is some MST T containing none of the light


edges leaving s. Consider any light edge (s, u). There is some path from
s to u in T, and therefore adding (s, u) to T forms a cycle. There must be
some other edge (s, v) in the cycle such that w(s, u) < w(s, v), as we
have assumed that there are no light edges leaving s contained in T.
Removing (s, v) from T and replacing it with (s, u) forms a spanning tree
of smaller total weight than T, contradicting our assumption that T is an
MST.

Lemma 2 All of the light edges leaving s must be contained in all


shortest path trees rooted at s.

PROOF. If (s, u) is a light edge leaving s, then because G has positive


edge weights, the single edge (s, u) must be the unique shortest path
from s to u. Any other path from s to u must go through some edge (s,
v), and by definition we know that w(s, v) ≥ w(s, u); therefore, all other
paths from s to u must have strictly greater weight than the single edge
(s, u).

These two lemmas together show that, for any source node s, all
shortest path trees from s must share some edge with all MSTs of G,
so there is no shortest path tree S and MST T that share no edges.

© 2022 All Rights Reserved . Programming Homework Help

You might also like