<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://algorist.com/algowiki_v2/index.php?action=history&amp;feed=atom&amp;title=Graphs-TADM2E</id>
		<title>Graphs-TADM2E - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://algorist.com/algowiki_v2/index.php?action=history&amp;feed=atom&amp;title=Graphs-TADM2E"/>
		<link rel="alternate" type="text/html" href="https://algorist.com/algowiki_v2/index.php?title=Graphs-TADM2E&amp;action=history"/>
		<updated>2026-04-30T19:23:52Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.28.0</generator>

	<entry>
		<id>https://algorist.com/algowiki_v2/index.php?title=Graphs-TADM2E&amp;diff=208&amp;oldid=prev</id>
		<title>Algowikiadmin: Protected &quot;Graphs-TADM2E&quot; ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))</title>
		<link rel="alternate" type="text/html" href="https://algorist.com/algowiki_v2/index.php?title=Graphs-TADM2E&amp;diff=208&amp;oldid=prev"/>
				<updated>2014-09-11T18:43:11Z</updated>
		
		<summary type="html">&lt;p&gt;Protected &amp;quot;&lt;a href=&quot;/algowiki_v2/index.php/Graphs-TADM2E&quot; title=&quot;Graphs-TADM2E&quot;&gt;Graphs-TADM2E&lt;/a&gt;&amp;quot; ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 18:43, 11 September 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='2' style='text-align: center;' lang='en'&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Algowikiadmin</name></author>	</entry>

	<entry>
		<id>https://algorist.com/algowiki_v2/index.php?title=Graphs-TADM2E&amp;diff=199&amp;oldid=prev</id>
		<title>Algowikiadmin: Recovering wiki</title>
		<link rel="alternate" type="text/html" href="https://algorist.com/algowiki_v2/index.php?title=Graphs-TADM2E&amp;diff=199&amp;oldid=prev"/>
				<updated>2014-09-11T18:24:21Z</updated>
		
		<summary type="html">&lt;p&gt;Recovering wiki&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Graph Traversal =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Simulating Graph Algorithms'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-1. &lt;br /&gt;
For the following graphs &amp;lt;math&amp;gt;G_1&amp;lt;/math&amp;gt; (left) and &amp;lt;math&amp;gt;G_2&amp;lt;/math&amp;gt; (right):&lt;br /&gt;
&amp;lt;br&amp;gt;(see book for figure)&lt;br /&gt;
&amp;lt;br&amp;gt;(see book for figure)&lt;br /&gt;
#Report the order of the vertices encountered on a breadth-first search starting from vertex &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt;. Break all ties by picking the vertices in alphabetical order (i.e., &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt; before &amp;lt;math&amp;gt;Z&amp;lt;/math&amp;gt;).&lt;br /&gt;
#Report the order of the vertices encountered on a depth-first search starting from vertex &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt;. Break all ties by picking the vertices in alphabetical order (i.e., &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt; before &amp;lt;math&amp;gt;Z&amp;lt;/math&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.1|(Solution 5.1)]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-2. &lt;br /&gt;
Do a topological sort of the following graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;:&lt;br /&gt;
&amp;lt;br&amp;gt;(see book for figure)&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.2|(Solution 5.2)]] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Traversal'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-3. &lt;br /&gt;
Prove by induction that there is a unique path between any pair&lt;br /&gt;
of vertices in a tree.&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.3|(Solution 5.3)]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-4. &lt;br /&gt;
Prove that in a breadth-first search on a undirected graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, every&lt;br /&gt;
edge is either a tree edge or a cross edge,&lt;br /&gt;
where &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; is neither an ancestor nor descendant of &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;, in cross edge &amp;lt;math&amp;gt;(x,y)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-5. &lt;br /&gt;
Give a linear algorithm to compute the chromatic number of graphs where&lt;br /&gt;
each vertex has degree at most 2.&lt;br /&gt;
Must such graphs be bipartite?&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.5|(Solution 5.5)]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-6. &lt;br /&gt;
In breadth-first and depth-first search,&lt;br /&gt;
an undiscovered node is marked ''discovered'' when it&lt;br /&gt;
is first encountered, and marked ''processed'' when it&lt;br /&gt;
has been completely searched.&lt;br /&gt;
At any given moment, several nodes might be simultaneously in the&lt;br /&gt;
''discovered'' state.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
(a) Describe a graph on &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; vertices and a particular starting vertex &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;&lt;br /&gt;
such that &amp;lt;math&amp;gt;\Theta(n)&amp;lt;/math&amp;gt; nodes are simultaneously in the ''discovered'' state&lt;br /&gt;
during a ''breadth-first search'' starting from &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
(b) Describe a graph on &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; vertices and a particular starting vertex &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;&lt;br /&gt;
such that &amp;lt;math&amp;gt;\Theta(n)&amp;lt;/math&amp;gt; nodes are simultaneously in the ''discovered'' state&lt;br /&gt;
during a ''depth-first search'' starting from &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
(c)  Describe a graph on &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; vertices and a particular starting vertex &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;&lt;br /&gt;
such that at some point&lt;br /&gt;
&amp;lt;math&amp;gt;\Theta(n)&amp;lt;/math&amp;gt; nodes remain ''undiscovered'', while &amp;lt;math&amp;gt;\Theta(n)&amp;lt;/math&amp;gt; nodes&lt;br /&gt;
have been ''processed'' during a ''depth-first search'' starting from &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
(Note, there may also be ''discovered'' nodes.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-7. &lt;br /&gt;
Given pre-order and in-order traversals of a binary&lt;br /&gt;
tree, is it possible to reconstruct the tree?&lt;br /&gt;
If so, sketch an&lt;br /&gt;
algorithm to do it. If not, give a counterexample. Repeat the&lt;br /&gt;
problem if you are given the pre-order and post-order traversals.&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.7|(Solution 5.7)]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-8. &lt;br /&gt;
Present correct and efficient algorithms to convert an undirected graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;&lt;br /&gt;
between the following graph data structures.&lt;br /&gt;
You must give the time complexity of each algorithm, assuming &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; vertices and &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; edges.&lt;br /&gt;
#Convert from an adjacency matrix to adjacency lists.&lt;br /&gt;
#Convert from an adjacency list to an incidence matrix. An incidence matrix &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; has a row for each vertex and a column for each edge, such that &amp;lt;math&amp;gt;M[i,j]=1&amp;lt;/math&amp;gt; if vertex &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is part of edge &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt;, otherwise &amp;lt;math&amp;gt;M[i,j] = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
#Convert from an incidence matrix to adjacency lists.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-9. &lt;br /&gt;
Suppose an arithmetic expression is given as a tree.&lt;br /&gt;
Each leaf is an integer and each internal node is one of the&lt;br /&gt;
standard arithmetical operations&lt;br /&gt;
&amp;lt;math&amp;gt;(+,-,*,/)&amp;lt;/math&amp;gt;.&lt;br /&gt;
For example, the expression &amp;lt;math&amp;gt;2+3*4+(3*4)/5&amp;lt;/math&amp;gt; is represented by&lt;br /&gt;
the tree in Figure (see book)(a).&lt;br /&gt;
&amp;lt;br&amp;gt;(see book for figure)&lt;br /&gt;
&amp;lt;br&amp;gt;(see book for figure)&lt;br /&gt;
Give an &amp;lt;math&amp;gt;O(n)&amp;lt;/math&amp;gt; algorithm for evaluating such an expression, where there are&lt;br /&gt;
&amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; nodes in the tree.&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.9|(Solution 5.9)]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-10. &lt;br /&gt;
Suppose an arithmetic expression is given as a DAG (directed acyclic&lt;br /&gt;
graph) with common subexpressions removed.&lt;br /&gt;
Each leaf is an integer and each internal node is one of the&lt;br /&gt;
standard arithmetical operations&lt;br /&gt;
&amp;lt;math&amp;gt;(+,-,*,/)&amp;lt;/math&amp;gt;.&lt;br /&gt;
For example, the expression &amp;lt;math&amp;gt;2+3*4+(3*4)/5&amp;lt;/math&amp;gt; is represented by&lt;br /&gt;
the DAG in Figure (see book)(b).&lt;br /&gt;
Give an &amp;lt;math&amp;gt;O(n+m)&amp;lt;/math&amp;gt; algorithm for evaluating such a DAG, where there are&lt;br /&gt;
&amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; nodes and &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; edges in the DAG.&lt;br /&gt;
Hint: modify an algorithm for the tree case to achieve the desired efficiency.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-11. &lt;br /&gt;
The war story of '''get-graph''' describes an algorithm&lt;br /&gt;
for constructing the dual graph of the triangulation efficiently,&lt;br /&gt;
although it does not guarantee linear time.&lt;br /&gt;
Give a worst-case linear algorithm for the problem.}&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.11|(Solution 5.11)]] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Algorithm Design'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-12. &lt;br /&gt;
The ''square'' of a directed graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; is the graph &amp;lt;math&amp;gt;G^2=(V,E^2)&amp;lt;/math&amp;gt;&lt;br /&gt;
such that &amp;lt;math&amp;gt;(u,w) \in E^2&amp;lt;/math&amp;gt; iff there exists &amp;lt;math&amp;gt;v \in V&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;(u,v) \in E&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;(v,w) \in E&amp;lt;/math&amp;gt;; i.e., there is a path of exactly two edges from &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
''square of a graph''&lt;br /&gt;
Give efficient algorithms for both adjacency lists and matrices.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-13. &lt;br /&gt;
A ''vertex cover'' of a graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; is a subset of vertices &amp;lt;math&amp;gt;V'&amp;lt;/math&amp;gt;&lt;br /&gt;
such that each edge in &amp;lt;math&amp;gt;E&amp;lt;/math&amp;gt; is incident on at least one vertex of &amp;lt;math&amp;gt;V'&amp;lt;/math&amp;gt;.&lt;br /&gt;
#Give an efficient algorithm to find a minimum-size vertex cover if &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is a tree.&lt;br /&gt;
#Let &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; be a tree such that the weight of each vertex is equal to the degree of that vertex. Give an efficient algorithm to find a minimum-weight vertex cover of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
#Let &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; be a tree with arbitrary weights associated with the vertices. Give an efficient algorithm to find a minimum-weight vertex cover of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.13|(Solution 5.13)]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-14. &lt;br /&gt;
A ''vertex cover'' of a graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; is a subset of vertices &amp;lt;math&amp;gt;V' \in V&amp;lt;/math&amp;gt;&lt;br /&gt;
such that every edge in &amp;lt;math&amp;gt;E&amp;lt;/math&amp;gt; contains at least one vertex from &amp;lt;math&amp;gt;V'&amp;lt;/math&amp;gt;.&lt;br /&gt;
Delete all the leaves from any depth-first search tree of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
Must the remaining vertices form a vertex cover of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;?&lt;br /&gt;
Give a proof or a counterexample.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-15. &lt;br /&gt;
A ''vertex cover'' of a graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; is a subset of vertices &amp;lt;math&amp;gt;V' \in V&amp;lt;/math&amp;gt;&lt;br /&gt;
such that every edge in &amp;lt;math&amp;gt;E&amp;lt;/math&amp;gt; contains ''at least one'' vertex from &amp;lt;math&amp;gt;V'&amp;lt;/math&amp;gt;.&lt;br /&gt;
An ''independent set'' of graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; is a subset of&lt;br /&gt;
vertices &amp;lt;math&amp;gt;V' \in V&amp;lt;/math&amp;gt; such that no edge in &amp;lt;math&amp;gt;E&amp;lt;/math&amp;gt; contains both vertices from &amp;lt;math&amp;gt;V'&amp;lt;/math&amp;gt;.&lt;br /&gt;
An ''independent vertex cover'' is a subset of vertices that is both&lt;br /&gt;
an independent set and a vertex cover of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
Give an efficient algorithm for testing whether &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; contains an&lt;br /&gt;
independent vertex cover.&lt;br /&gt;
What classical graph problem does this reduce to?&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.15|(Solution 5.15)]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-16. &lt;br /&gt;
An ''independent set'' of an undirected graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; is a set of vertices $U&lt;br /&gt;
$&lt;br /&gt;
such that no edge in &amp;lt;math&amp;gt;E&amp;lt;/math&amp;gt; is incident on two vertices of &amp;lt;math&amp;gt;U&amp;lt;/math&amp;gt;.&lt;br /&gt;
#Give an efficient algorithm to find a maximum-size independent set if &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is a tree.&lt;br /&gt;
#Let &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; be a tree with weights associated with the vertices such that the weight of each vertex is equal to the degree of that vertex. Give an efficient algorithm to find a maximum independent set of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
#Let &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; be a tree with arbitrary weights associated with the vertices. Give an efficient algorithm to find a maximum independent set of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.16|(Solution 5.16)]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-17. &lt;br /&gt;
Consider the problem of determining whether a given undirected graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt;&lt;br /&gt;
contains a ''triangle'' or cycle of length 3.&lt;br /&gt;
#Give an  &amp;lt;math&amp;gt;O(|V|^3)&amp;lt;/math&amp;gt; to find a triangle if one exists.&lt;br /&gt;
#Improve your algorithm to run in time &amp;lt;math&amp;gt;O(|V| \cdot |E|)&amp;lt;/math&amp;gt;. You may assume &amp;lt;math&amp;gt;|V| \leq |E|&amp;lt;/math&amp;gt;.&lt;br /&gt;
Observe that these bounds gives you time to convert between&lt;br /&gt;
the adjacency matrix and adjacency list representations of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.17|(Solution 5.17)]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-18. &lt;br /&gt;
Consider a set of movies $M_1, M_2,&lt;br /&gt;
\ldots, M_k$. There is a set of customers, each one of which indicates&lt;br /&gt;
the two movies they would like to see this weekend.&lt;br /&gt;
Movies are shown on Saturday evening and Sunday evening.&lt;br /&gt;
Multiple movies may be screened at the same time.&lt;br /&gt;
You must decide which movies should be televised&lt;br /&gt;
on Saturday and which on Sunday, so that&lt;br /&gt;
every customer gets to see the two movies they desire.&lt;br /&gt;
Is there a schedule where each movie is shown at most once? Design&lt;br /&gt;
an efficient algorithm to find such a schedule if one exists.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-19. &lt;br /&gt;
The ''diameter'' of a tree &amp;lt;math&amp;gt;T=(V,E)&amp;lt;/math&amp;gt; is&lt;br /&gt;
given by&lt;br /&gt;
&amp;lt;math&amp;gt;\max_{u,v\in V} \delta(u,v)&amp;lt;/math&amp;gt;&lt;br /&gt;
(where &amp;lt;math&amp;gt;\delta(u,v)&amp;lt;/math&amp;gt; is the number of edges on the path from &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; to&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;).  Describe an efficient algorithm to compute the diameter of a&lt;br /&gt;
tree, and show the correctness and analyze the running time of your&lt;br /&gt;
algorithm.&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.19|(Solution 5.19)]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-20. &lt;br /&gt;
Given an undirected graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; vertices and &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; edges,&lt;br /&gt;
and an integer &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;, give an &amp;lt;math&amp;gt;O(m+n)&amp;lt;/math&amp;gt;&lt;br /&gt;
algorithm that finds the maximum induced&lt;br /&gt;
subgraph &amp;lt;math&amp;gt;H&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; such that each vertex in &amp;lt;math&amp;gt;H&amp;lt;/math&amp;gt; has degree &amp;lt;math&amp;gt;\geq k&amp;lt;/math&amp;gt;, or&lt;br /&gt;
prove that no such graph exists.&lt;br /&gt;
An induced subgraph &amp;lt;math&amp;gt;F=(U,R)&amp;lt;/math&amp;gt; of a graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; is a subset of &amp;lt;math&amp;gt;U&amp;lt;/math&amp;gt;&lt;br /&gt;
of the vertices &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, and all edges &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; such that both vertices&lt;br /&gt;
of each edge are in &amp;lt;math&amp;gt;U&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-21. &lt;br /&gt;
Let &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; be two vertices in a directed graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt;.&lt;br /&gt;
Design a linear-time algorithm to find the ''number'' of different shortest&lt;br /&gt;
paths (not necessarily vertex disjoint) between &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
Note: the edges in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; are unweighted.&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.21|(Solution 5.21)]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-22. &lt;br /&gt;
Design a linear-time algorithm to&lt;br /&gt;
eliminate each vertex &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; of degree 2 from a graph&lt;br /&gt;
by replacing edges &amp;lt;math&amp;gt;(u,v)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; by an edge &amp;lt;math&amp;gt;(u,w)&amp;lt;/math&amp;gt;.&lt;br /&gt;
We also seek to eliminate multiple copies of edges by replacing them&lt;br /&gt;
with a single edge.&lt;br /&gt;
Note that removing multiple copies of an edge may create&lt;br /&gt;
a new vertex of degree 2, which has to be removed, and that&lt;br /&gt;
removing a vertex of degree 2 may create multiple edges, which&lt;br /&gt;
also must be removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Directed Graphs'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-23. &lt;br /&gt;
Your job is to arrange &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; ill-behaved children in a straight line,&lt;br /&gt;
facing front.&lt;br /&gt;
You are given a list of &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; statements of the form ''&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; hates &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt;''.&lt;br /&gt;
If &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; hates &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt;, then you do not want put &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; somewhere behind &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt;,&lt;br /&gt;
because then &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is capable of throwing something at &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt;.&lt;br /&gt;
#Give an algorithm that orders the line, (or says that it is not possible) in &amp;lt;math&amp;gt;O(m+n)&amp;lt;/math&amp;gt; time.&lt;br /&gt;
#Suppose instead you want to arrange the children in rows such that if &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; hates &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt;, then &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; must be in a lower numbered row than &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt;. Give an efficient algorithm to find the minimum number of rows needed, if it is possible.&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.23|(Solution 5.23)]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-24. &lt;br /&gt;
Adding a single directed edge to a directed graph can reduce the number&lt;br /&gt;
of weakly connected components, but by at most how many components?&lt;br /&gt;
What about the number of strongly connected components?&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-25. &lt;br /&gt;
An ''arborescence'' of a directed graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is a rooted tree such that there&lt;br /&gt;
is a directed path from the root to every other vertex in the graph.&lt;br /&gt;
Give an efficient and correct algorithm to test whether&lt;br /&gt;
&amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; contains an arborescence,&lt;br /&gt;
and its time complexity.&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.25|(Solution 5.25)]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-26. &lt;br /&gt;
A ''mother'' vertex in a directed graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; is a vertex &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; such&lt;br /&gt;
that all other vertices &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; can be reached by a directed path&lt;br /&gt;
from &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
#Give an &amp;lt;math&amp;gt;O(n+m)&amp;lt;/math&amp;gt; algorithm to test whether a given vertex &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is a mother of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|E|&amp;lt;/math&amp;gt;.&lt;br /&gt;
#Give an &amp;lt;math&amp;gt;O(n+m)&amp;lt;/math&amp;gt; algorithm to test whether graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; contains a mother vertex.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-27. &lt;br /&gt;
A ''tournament'' is a directed graph formed by taking the complete&lt;br /&gt;
undirected graph and assigning arbitrary directions on the edges---i.e.,&lt;br /&gt;
a graph &amp;lt;math&amp;gt;G = (V,E)&amp;lt;/math&amp;gt; such that for all &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt;,&amp;lt;math&amp;gt;v \in V&amp;lt;/math&amp;gt;, exactly one of&lt;br /&gt;
&amp;lt;math&amp;gt;(u,v)&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;(v,u)&amp;lt;/math&amp;gt; is in &amp;lt;math&amp;gt;E&amp;lt;/math&amp;gt;.&lt;br /&gt;
Show that every tournament has a Hamiltonian path---that&lt;br /&gt;
is, a path that visits every vertex exactly once.&lt;br /&gt;
Give an algorithm to find this path.&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.27|(Solution 5.27)]] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Articulation Vertices'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-28. &lt;br /&gt;
An articulation vertex of a graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is a vertex&lt;br /&gt;
whose deletion disconnects &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
Let &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; be a graph with &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; vertices and &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; edges.&lt;br /&gt;
Give a simple &amp;lt;math&amp;gt;O(n+m)&amp;lt;/math&amp;gt; algorithm for finding a vertex of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; that is ''not''&lt;br /&gt;
an articulation vertex---i.e., whose deletion does not disconnect &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-29. &lt;br /&gt;
Following up on the previous problem, give an &amp;lt;math&amp;gt;O(n+m)&amp;lt;/math&amp;gt;&lt;br /&gt;
algorithm that finds a deletion order for the &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; vertices such&lt;br /&gt;
that no deletion disconnects the graph.&lt;br /&gt;
(Hint: think DFS/BFS.)&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.29|(Solution 5.29)]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-30. &lt;br /&gt;
Suppose &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is a connected undirected graph.&lt;br /&gt;
An edge &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt; whose removal disconnects the graph is called a ''bridge''.&lt;br /&gt;
Must every bridge &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt; be an edge in a depth-first search tree of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;?&lt;br /&gt;
Give a proof or a counterexample.&lt;br /&gt;
&lt;br /&gt;
'''Interview Problems'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-31. &lt;br /&gt;
Which data structures are used in depth-first and breath-first search?&lt;br /&gt;
&lt;br /&gt;
[[TADM2E 5.31|(Solution 5.31)]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;5-32. &lt;br /&gt;
Write a function to traverse binary search tree and return the &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;th node&lt;br /&gt;
in sorted order.&lt;/div&gt;</summary>
		<author><name>Algowikiadmin</name></author>	</entry>

	</feed>